Module: Uptrace

Extended by:
Uptrace
Included in:
Uptrace
Defined in:
lib/uptrace.rb,
lib/uptrace/dsn.rb,
lib/uptrace/trace.rb,
lib/uptrace/client.rb,
lib/uptrace/metric.rb,
lib/uptrace/version.rb,
lib/uptrace/trace/exporter.rb

Overview

Uptrace provides Uptrace exporters for OpenTelemetry.

Defined Under Namespace

Modules: Metric, Trace Classes: Client, DSN

Constant Summary collapse

VERSION =
'0.16.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject, Client

Returns registered client or a default no-op implementation of the client.

Returns:

  • (Object, Client)

    registered client or a default no-op implementation of the client.



16
17
18
# File 'lib/uptrace.rb', line 16

def client
  @client ||= Client.new
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/uptrace.rb', line 10

def logger
  @logger
end

Instance Method Details

#configure_opentelemetry(c, dsn: '') ⇒ Object

ConfigureOpentelemetry configures OpenTelemetry to export data to Uptrace. By default it:

  • creates tracer provider;
  • registers Uptrace span exporter;
  • sets tracecontext + baggage composite context propagator.

Parameters:

  • c (OpenTelemetry::SDK::Configurator)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/uptrace.rb', line 33

def configure_opentelemetry(c, dsn: '')
  @client = Client.new(dsn: dsn) unless dsn.empty?

  c.add_span_processor(client.span_processor) unless client.disabled?

  if OpenTelemetry.propagation.nil?
    c.injectors = [
      OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector,
      OpenTelemetry::Baggage::Propagation.text_map_injector
    ]
    c.extractors = [
      OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor,
      OpenTelemetry::Baggage::Propagation.text_map_extractor
    ]
  end
end

#trace_url(span = nil) ⇒ String

Parameters:

  • span (optional OpenTelemetry::Trace::Span) (defaults to: nil)

Returns:

  • (String)


22
23
24
# File 'lib/uptrace.rb', line 22

def trace_url(span = nil)
  client.trace_url(span)
end