Module: Datadog::Tracing::Contrib::Hanami::RendererPolicyTracing
- Defined in:
- lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
Overview
Hanami Instrumentation for ‘hanami.render`
Instance Method Summary collapse
Instance Method Details
#configuration ⇒ Object
34 35 36 |
# File 'lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb', line 34 def configuration Datadog.configuration.tracing[:hanami] end |
#render(env, response) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb', line 12 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, 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 |