Module: Dash0::OpenTelemetry::Boot

Defined in:
lib/dash0/opentelemetry/boot.rb

Overview

Orchestrates startup: gating (disable switch, mandatory collector URL, double-instrumentation guard), SDK configuration, and instrumentation install.

The Ruby-version stand-down lives in the requirable entry point (lib/dash0-opentelemetry.rb) so it can run before any modern-syntax file is required.

Constant Summary collapse

COLLECTOR_BASE_URL_ENV =
'DASH0_OTEL_COLLECTOR_BASE_URL'
DISABLE_ENV =
'DASH0_DISABLE'

Class Method Summary collapse

Class Method Details

.booted?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/dash0/opentelemetry/boot.rb', line 45

def booted?
  @booted == true
end

.reset_for_testing!Object

Resets the one-time boot guard. Intended for tests only.



41
42
43
# File 'lib/dash0/opentelemetry/boot.rb', line 41

def reset_for_testing!
  @booted = false
end

.runObject

Boots the distribution. Safe to call more than once; only the first call that passes the gates takes effect.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dash0/opentelemetry/boot.rb', line 22

def run
  return if @booted
  return if disabled?

  base_url = collector_base_url
  return unless base_url

  if already_instrumented?
    Dash0::OpenTelemetry.log_error(
      'The application already has OpenTelemetry loaded; standing down to avoid double instrumentation.'
    )
    return
  end

  @booted = true
  configure(base_url)
end