Class: Brut::Instrumentation::OpenTelemetry::Span
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Brut::Instrumentation::OpenTelemetry::Span
- Defined in:
- lib/brut/instrumentation/open_telemetry.rb
Instance Method Summary collapse
-
#add_attributes(attributes) ⇒ Object
Adds attributes to the span, converting the hash or keyword arguments to strings.
-
#add_prefixed_attributes(prefix, attributes) ⇒ Object
Adds attributes to the span, prefixing each key with the given prefix, then converting the hash or keyword arguments to strings.
Instance Method Details
#add_attributes(attributes) ⇒ Object
Adds attributes to the span, converting the hash or keyword arguments to strings. This will use the app’s Otel prefix for all attributes, so you do not have to prefix them. If you need to set standard attributes, you should use #add_prefixed_attributes instead.
Values will be converted via NormalizedAttributes, which preserves strings, numbers, and booleans, and converts the rest to strings via ‘to_s`.
146 147 148 |
# File 'lib/brut/instrumentation/open_telemetry.rb', line 146 def add_attributes(attributes) add_prefixed_attributes(:detect,attributes) end |
#add_prefixed_attributes(prefix, attributes) ⇒ Object
Adds attributes to the span, prefixing each key with the given prefix, then converting the hash or keyword arguments to strings. For example, if the prefix is ‘my_app’ and you add the attributes ‘type’ and ‘reason’, the actual attribute names will be ‘my_app.type’ and ‘my_app.reason’.
153 154 155 156 157 |
# File 'lib/brut/instrumentation/open_telemetry.rb', line 153 def add_prefixed_attributes(prefix,attributes) __getobj__.add_attributes( NormalizedAttributes.new(prefix,attributes).to_h ) end |