Class: OpenTelemetry::Propagator::Vitess::SqlQueryPropagator

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/propagator/vitess/sql_query_propagator.rb

Overview

Instance Method Summary collapse

Constructor Details

#initializeSqlQueryPropagator

Returns a new instance of SqlQueryPropagator.



42
43
44
# File 'lib/opentelemetry/propagator/vitess/sql_query_propagator.rb', line 42

def initialize
  @jaeger = OpenTelemetry::Propagator::Jaeger.text_map_propagator
end

Instance Method Details

#extract(carrier, context: Context.current, getter: nil) ⇒ Object

No-op extractor.



47
48
49
# File 'lib/opentelemetry/propagator/vitess/sql_query_propagator.rb', line 47

def extract(carrier, context: Context.current, getter: nil)
  context
end

#fieldsArray<String>

Returns the predefined propagation fields. If your carrier is reused, you should delete the fields returned by this method before calling +inject+.

Returns:

  • (Array<String>)

    a list of fields that will be used by this propagator.



72
73
74
# File 'lib/opentelemetry/propagator/vitess/sql_query_propagator.rb', line 72

def fields
  FIELDS
end

#inject(carrier, context: Context.current, setter: SqlQuerySetter) ⇒ Object

Parameters:

  • carrier (Object)

    to update with context.

  • context (optional Context) (defaults to: Context.current)

    The active Context.

  • setter (optional Setter) (defaults to: SqlQuerySetter)

    If the optional setter is provided, it will be used to write context into the carrier, otherwise the default setter will be used.



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/opentelemetry/propagator/vitess/sql_query_propagator.rb', line 56

def inject(carrier, context: Context.current, setter: SqlQuerySetter)
  span_context = Trace.current_span(context).context
  return unless span_context.valid?

  jaeger = {}
  @jaeger.inject(jaeger, context: context)
  encoded = Base64.strict_encode64(jaeger.to_json)
  setter.set(carrier, VT_SPAN_CONTEXT, encoded)

  nil
end