Sha256: 3dc645cc9b463f6ea0a9106cfd33b888f6e1ef58e9a4355010b1f70f3aa6fd98

Contents?: true

Size: 591 Bytes

Versions: 10

Compression:

Stored size: 591 Bytes

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module RubyKafka
      # Utilities to help with instrumenting kafka
      module Utils
        module_function

        def extract_message_key(key)
          # skip encode if already valid utf8
          return key if key.nil? || (key.encoding == Encoding::UTF_8 && key.valid_encoding?)

          key.encode(Encoding::UTF_8)
        rescue Encoding::UndefinedConversionError
          nil
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-ruby_kafka-0.21.3 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.21.2 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.21.1 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.21.0 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.20.2 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.20.1 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.20.0 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.19.1 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.19.0 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb
opentelemetry-instrumentation-ruby_kafka-0.18.6 lib/opentelemetry/instrumentation/ruby_kafka/utils.rb