Class: Uptrace::Client
- Inherits:
-
Object
- Object
- Uptrace::Client
- Defined in:
- lib/uptrace/client.rb
Overview
Uptrace client that configures OpenTelemetry SDK to use Uptrace exporter.
Instance Attribute Summary collapse
-
#dsn ⇒ Object
readonly
Returns the value of attribute dsn.
Instance Method Summary collapse
- #disabled? ⇒ Boolean
-
#initialize(dsn: '') ⇒ Client
constructor
A new instance of Client.
- #trace_url(span = nil) ⇒ String
Constructor Details
#initialize(dsn: '') ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/uptrace/client.rb', line 11 def initialize(dsn: '') dsn = ENV.fetch('UPTRACE_DSN', '') if dsn.empty? begin @dsn = DSN.new(dsn) rescue ArgumentError => e Uptrace.logger.error("Uptrace is disabled: #{e.}") @disabled = true @dsn = DSN.new('https://[email protected]/PROJECT_ID') end end |
Instance Attribute Details
#dsn ⇒ Object (readonly)
Returns the value of attribute dsn.
8 9 10 |
# File 'lib/uptrace/client.rb', line 8 def dsn @dsn end |
Instance Method Details
#disabled? ⇒ Boolean
24 25 26 |
# File 'lib/uptrace/client.rb', line 24 def disabled? @disabled end |
#trace_url(span = nil) ⇒ String
30 31 32 33 34 |
# File 'lib/uptrace/client.rb', line 30 def trace_url(span = nil) span = OpenTelemetry::Trace.current_span if span.nil? trace_id = span.context.hex_trace_id "#{@dsn.app_addr}/traces/#{trace_id}" end |