Class: Gitlab::Graphql::Tracers::TimerTracer
- Inherits:
-
Object
- Object
- Gitlab::Graphql::Tracers::TimerTracer
- Defined in:
- lib/gitlab/graphql/tracers/timer_tracer.rb
Overview
This graphql-ruby tracer records duration for trace events and merges the duration into the trace event’s metadata. This way, separate tracers can all use the same duration information.
NOTE: TimerTracer should be applied last after other tracers, so that it runs first (similar to function composition)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.use(schema) ⇒ Object
13 14 15 |
# File 'lib/gitlab/graphql/tracers/timer_tracer.rb', line 13 def self.use(schema) schema.tracer(self.new) end |
Instance Method Details
#trace(key, data) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/gitlab/graphql/tracers/timer_tracer.rb', line 17 def trace(key, data) start_time = Gitlab::Metrics::System.monotonic_time yield ensure data[:duration_s] = Gitlab::Metrics::System.monotonic_time - start_time end |