Sha256: d47a57d3c7c895af95a4c68671b7d224bab2f19b554828ac1676469b57e1f512

Contents?: true

Size: 1.3 KB

Versions: 22

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require_relative 'ext'
require_relative '../../metadata/ext'

module Datadog
  module Tracing
    module Contrib
      module Hanami
        # Hanami Instrumentation for `hanami.routing`
        module RouterTracing
          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

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ddtrace-1.23.3 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.17.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.16.2 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.16.1 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.16.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.15.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.14.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.13.1 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.13.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.12.1 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/hanami/router_tracing.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/hanami/router_tracing.rb