Module: Uptrace

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

Overview

Uptrace provides Uptrace exporters for OpenTelemetry.

Defined Under Namespace

Modules: IdGenerator Classes: Client, DSN

Constant Summary collapse

VERSION =
'1.4.0'

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.



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

def client
  @client ||= Client.new
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

Instance Method Details

#configure_opentelemetry(dsn: '') {|c| ... } ⇒ Object

ConfigureOpentelemetry configures OpenTelemetry to export data to Uptrace. Specifically it configures and registers Uptrace span exporter.

Parameters:

  • dsn (optional String) (defaults to: '')

Yield Parameters:

  • c (OpenTelemetry::SDK::Configurator)

    Yields a configurator to the provided block



33
34
35
36
37
38
39
40
41
# File 'lib/uptrace.rb', line 33

def configure_opentelemetry(dsn: '')
  OpenTelemetry::SDK.configure do |c|
    @client = Client.new(dsn: dsn) unless dsn.empty?
    c.add_span_processor(span_processor(@client.dsn)) unless client.disabled?
    c.id_generator = Uptrace::IdGenerator

    yield c if block_given?
  end
end

#trace_url(span = nil) ⇒ String

Parameters:

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

Returns:

  • (String)


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

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