Class: Brut::Instrumentation::OpenTelemetry::NormalizedAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/brut/instrumentation/open_telemetry.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix, attributes) ⇒ NormalizedAttributes

Returns a new instance of NormalizedAttributes.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/brut/instrumentation/open_telemetry.rb', line 94

def initialize(prefix,attributes)
  if prefix == :detect
    prefix = attributes.delete(:prefix)
    if prefix.nil?
      prefix = Brut.container.otel_attribute_prefix
    end
  end
  prefix_string = if prefix
                    "#{prefix}."
                  else
                    ""
                  end
  @attributes = (attributes || {}).map { |key,value|
    [ "#{prefix_string}#{key}", normalize_value(value) ]
  }.to_h
end

Instance Method Details

#to_hObject



111
112
113
# File 'lib/brut/instrumentation/open_telemetry.rb', line 111

def to_h
  @attributes
end