Sha256: 2e2bf893d2e5a1c25055c11749c0dd6360ac9ec5e85b498edaefa3a367d62254

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module Racecar
      module Patches
        # This module contains logic to patch Racecar::Consumer
        module Consumer
          def produce(payload, topic:, key: nil, partition: nil, partition_key: nil, headers: nil, create_time: nil)
            attributes = {
              'messaging.system' => 'kafka',
              'messaging.destination' => topic,
              'messaging.destination_kind' => 'topic'
            }

            headers ||= {}

            tracer.in_span("#{topic} publish", attributes: attributes, kind: :producer) do
              OpenTelemetry.propagation.inject(headers)
              super
            end
          end

          def tracer
            Racecar::Instrumentation.instance.tracer
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-racecar-0.3.4 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.3.3 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.3.2 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.3.1 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.3.0 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb