Skip to content

Generate producer spans #2377

Description

@thompson-tomo

Currently active support only generates consumer spans, we should update this so that a producer span is created when the message is sent. To do this we can

module OpenTelemetry
  module Instrumentation
    module ActiveSupport
      module Producer
        def instrument(name, payload = {})
          tracer = OpenTelemetry.tracer_provider.tracer(
            "opentelemetry-instrumentation-activesupport",
            VERSION
          )

          tracer.in_span("send #{name}", kind: :producer) do
            super
          end
        end
      end
    end
  end
end

And it needs to be installed

ActiveSupport::Notifications.singleton_class.prepend(
  OpenTelemetry::Instrumentation::ActiveSupport::Producer
)

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions