Module: SolarWindsAPM::API::Tracing

Defined in:
lib/solarwinds_apm/api/tracing.rb

Instance Method Summary collapse

Instance Method Details

#solarwinds_ready?(wait_milliseconds = 3000, integer_response: nil) ⇒ Boolean

Wait for SolarWinds to be ready to send traces.

This may be useful in short lived background processes when it is important to capture information during the whole time the process is running. Usually SolarWinds doesn’t block an application while it is starting up.

Argument:

  • wait_milliseconds - (int, default 3000) the maximum time to wait in milliseconds

Example:

unless SolarWindsAPM::API.solarwinds_ready?(10_000)
  Logger.info "SolarWindsAPM not ready after 10 seconds, no metrics will be sent"
end

Returns:

  • Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/solarwinds_apm/api/tracing.rb', line 31

def solarwinds_ready?(wait_milliseconds = 3000, integer_response: nil)
  unless integer_response.nil?
    SolarWindsAPM.logger.warn do
      'Deprecation: solarwinds_ready? no longer accepts integer_response, this parameter will be removed in the next release.'
    end
  end

  root_sampler = ::OpenTelemetry.tracer_provider.sampler.instance_variable_get(:@root)
  is_ready = root_sampler.wait_until_ready(wait_milliseconds / 1000)
  !!is_ready
end