Class: Datadog::Tracing::Contrib::Hanami::ActionTracer

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/tracing/contrib/hanami/action_tracer.rb

Overview

Hanami Instrumentation for ‘hanami.action`

Instance Method Summary collapse

Constructor Details

#initialize(app, action) ⇒ ActionTracer

Returns a new instance of ActionTracer.



13
14
15
16
# File 'lib/datadog/tracing/contrib/hanami/action_tracer.rb', line 13

def initialize(app, action)
  @app = app
  @action = action
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/datadog/tracing/contrib/hanami/action_tracer.rb', line 18

def call(env)
  Tracing.trace(
    Ext::SPAN_ACTION,
    resource: @action.to_s,
    service: configuration[:service_name],
    span_type: Tracing::Metadata::Ext::HTTP::TYPE_INBOUND
  ) do |span_op, trace_op|
    span_op.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
    span_op.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_ACTION)

    if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
      Contrib::Analytics.set_sample_rate(span_op, configuration[:analytics_sample_rate])
    end

    trace_op.resource = span_op.resource

    @app.call(env)
  end
end