Sha256: aa0cd19636d8db87e4a673476647127284205fdae384f4b2ec431141d9089a60

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module ActionPack
      module Patches
        module ActionController
          # Module to prepend to ActionController::Metal for instrumentation
          module Metal
            def dispatch(name, request, response)
              rack_span = OpenTelemetry::Instrumentation::Rack.current_span
              if rack_span.recording?
                rack_span.name = "#{self.class.name}##{name}" unless request.env['action_dispatch.exception']

                attributes_to_append = {
                  OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => self.class.name,
                  OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(name)
                }
                attributes_to_append[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath
                rack_span.add_attributes(attributes_to_append)
              end

              super(name, request, response)
            end

            private

            def instrumentation_config
              ActionPack::Instrumentation.instance.config
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-action_pack-0.8.0 lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb
opentelemetry-instrumentation-action_pack-0.7.1 lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb
opentelemetry-instrumentation-action_pack-0.7.0 lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb
opentelemetry-instrumentation-action_pack-0.6.0 lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb
opentelemetry-instrumentation-action_pack-0.5.0 lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb
opentelemetry-instrumentation-action_pack-0.4.1 lib/opentelemetry/instrumentation/action_pack/patches/action_controller/metal.rb