Class: Brut::FrontEnd::Components::Traceparent
- Inherits:
-
Brut::FrontEnd::Component
- Object
- Phlex::HTML
- Brut::FrontEnd::Component
- Brut::FrontEnd::Components::Traceparent
- Defined in:
- lib/brut/front_end/components/traceparent.rb
Overview
Renders the traceparent value for the current trace so that the front-end can add additional spans.
Instance Method Summary collapse
-
#initialize ⇒ Traceparent
constructor
A new instance of Traceparent.
-
#view_template ⇒ Object
Methods inherited from Brut::FrontEnd::Component
component_name, #component_name
Methods included from Brut::FrontEnd::Component::Helpers
#global_component, #inline_svg
Methods included from I18n::ForHTML
Methods included from I18n::BaseMethods
#l, #t, #t_direct, #this_field_value
Methods included from Brut::Framework::Errors
Constructor Details
#initialize ⇒ Traceparent
Returns a new instance of Traceparent.
3 4 5 6 7 8 9 |
# File 'lib/brut/front_end/components/traceparent.rb', line 3 def initialize propagator = OpenTelemetry::Trace::Propagation::TraceContext::TextMapPropagator.new carrier = {} current_context = OpenTelemetry::Context.current propagator.inject(carrier, context: current_context) @traceparent = carrier["traceparent"] end |
Instance Method Details
#view_template ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/brut/front_end/components/traceparent.rb', line 11 def view_template attributes = { name: "traceparent", content: @traceparent, } if !@traceparent attributes["data-no-traceparent"] = "no traceparent was available - this component may have been rendered outside of an existing OpenTelemetry context" end (**attributes) end |