Sha256: 51b0664e2a80aae6f33518df5cc41c5da119dba78727a4bdfa03669f18678aa8

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 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} send", 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.2.1 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.2.0 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.1.2 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.1.1 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb
opentelemetry-instrumentation-racecar-0.1.0 lib/opentelemetry/instrumentation/racecar/patches/consumer.rb