Module: Datadog::Tracing::Contrib::Hanami::RouterTracing

Defined in:
lib/datadog/tracing/contrib/hanami/router_tracing.rb

Overview

Hanami Instrumentation for ‘hanami.routing`

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/datadog/tracing/contrib/hanami/router_tracing.rb', line 12

def call(env)
  return super if Tracing.active_span && Tracing.active_span.name == Ext::SPAN_ROUTING

  Tracing.trace(
    Ext::SPAN_ROUTING,
    service: configuration[:service_name],
    span_type: Tracing::Metadata::Ext::HTTP::TYPE_INBOUND
  ) do |span_op, trace_op|
    begin
      span_op.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
      span_op.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_ROUTING)

      span_op.resource = nil

      super
    ensure
      span_op.resource ||= if trace_op.resource_override?
                             trace_op.resource
                           else
                             env['REQUEST_METHOD']
                           end
    end
  end
end

#configurationObject



37
38
39
# File 'lib/datadog/tracing/contrib/hanami/router_tracing.rb', line 37

def configuration
  Datadog.configuration.tracing[:hanami]
end