Sha256: da99cfc8cac968b9b1e4c2686da860847fd027c3c5c1359bbfb52afb25873bfe

Contents?: true

Size: 1.26 KB

Versions: 22

Compression:

Stored size: 1.26 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.render`
        module RendererPolicyTracing
          def render(env, response)
            action = env['hanami.action']
            # env['hanami.action'] could be empty for endpoints without an action
            #
            # For example in config/routes.rb:
            # get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
            action_klass = (action && action.class) ||
              ::Hanami::Routing::Default::NullAction

            Tracing.trace(
              Ext::SPAN_RENDER,
              service: configuration[:service_name],
              resource: action_klass.to_s,
              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_RENDER)

              super
            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/renderer_policy_tracing.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.17.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.16.2 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.16.1 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.16.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.15.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.14.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.13.1 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.13.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.12.1 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb