Module: OpenTelemetry
- Extended by:
- OpenTelemetry
- Included in:
- OpenTelemetry
- Defined in:
- lib/opentelemetry/error.rb,
lib/opentelemetry/trace.rb,
lib/opentelemetry/baggage.rb,
lib/opentelemetry/context.rb,
lib/opentelemetry/version.rb,
lib/opentelemetry/internal.rb,
lib/opentelemetry/trace/link.rb,
lib/opentelemetry/trace/span.rb,
lib/opentelemetry/context/key.rb,
lib/opentelemetry/trace/status.rb,
lib/opentelemetry/trace/tracer.rb,
lib/opentelemetry/baggage/entry.rb,
lib/opentelemetry/baggage/builder.rb,
lib/opentelemetry/trace/span_kind.rb,
lib/opentelemetry/trace/tracestate.rb,
lib/opentelemetry/trace/propagation.rb,
lib/opentelemetry/trace/trace_flags.rb,
lib/opentelemetry/trace/span_context.rb,
lib/opentelemetry/baggage/propagation.rb,
lib/opentelemetry/context/propagation.rb,
lib/opentelemetry/internal/proxy_tracer.rb,
lib/opentelemetry/trace/tracer_provider.rb,
lib/opentelemetry/internal/proxy_tracer_provider.rb,
lib/opentelemetry/trace/propagation/trace_context.rb,
lib/opentelemetry/baggage/propagation/context_keys.rb,
lib/opentelemetry/context/propagation/rack_env_getter.rb,
lib/opentelemetry/context/propagation/text_map_getter.rb,
lib/opentelemetry/context/propagation/text_map_setter.rb,
lib/opentelemetry/baggage/propagation/text_map_propagator.rb,
lib/opentelemetry/context/propagation/text_map_propagator.rb,
lib/opentelemetry/context/propagation/noop_text_map_propagator.rb,
lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb,
lib/opentelemetry/context/propagation/composite_text_map_propagator.rb,
lib/opentelemetry/trace/propagation/trace_context/text_map_propagator.rb,
lib/opentelemetry.rb
Overview
OpenTelemetry is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries.
The OpenTelemetry module provides global accessors for telemetry objects.
Defined Under Namespace
Modules: Baggage, Internal, Trace Classes: Context, Error
Constant Summary collapse
- VERSION =
Current OpenTelemetry version
'1.4.0'
Instance Attribute Summary collapse
-
#error_handler ⇒ Callable
Configured error handler or a default that logs the exception and message at ERROR level.
-
#logger ⇒ Object, Logger
Configured Logger or a default STDOUT Logger.
-
#propagation ⇒ Context::Propagation::Propagator
A propagator instance.
Instance Method Summary collapse
-
#handle_error(exception: nil, message: nil) ⇒ Object
Handles an error by calling the configured error_handler.
-
#tracer_provider ⇒ Object, Trace::TracerProvider
Registered tracer provider or a default no-op implementation of the tracer provider.
-
#tracer_provider=(provider) ⇒ Object
Register the global tracer provider.
Instance Attribute Details
#error_handler ⇒ Callable
Returns configured error handler or a default that logs the exception and message at ERROR level.
36 37 38 |
# File 'lib/opentelemetry.rb', line 36 def error_handler @error_handler ||= ->(exception: nil, message: nil) { logger.error("OpenTelemetry error: #{[, exception&., exception&.backtrace&.first].compact.join(' - ')}") } end |
#logger ⇒ Object, Logger
Returns configured Logger or a default STDOUT Logger.
30 31 32 |
# File 'lib/opentelemetry.rb', line 30 def logger @logger ||= Logger.new($stdout, level: ENV['OTEL_LOG_LEVEL'] || Logger::INFO) end |
#propagation ⇒ Context::Propagation::Propagator
Returns a propagator instance.
69 70 71 |
# File 'lib/opentelemetry.rb', line 69 def propagation @propagation ||= Context::Propagation::NoopTextMapPropagator.new end |
Instance Method Details
#handle_error(exception: nil, message: nil) ⇒ Object
Handles an error by calling the configured error_handler.
44 45 46 |
# File 'lib/opentelemetry.rb', line 44 def handle_error(exception: nil, message: nil) error_handler.call(exception: exception, message: ) end |
#tracer_provider ⇒ Object, Trace::TracerProvider
Returns registered tracer provider or a default no-op implementation of the tracer provider.
64 65 66 |
# File 'lib/opentelemetry.rb', line 64 def tracer_provider @mutex.synchronize { @tracer_provider } end |
#tracer_provider=(provider) ⇒ Object
Register the global tracer provider.
52 53 54 55 56 57 58 59 60 |
# File 'lib/opentelemetry.rb', line 52 def tracer_provider=(provider) @mutex.synchronize do if @tracer_provider.instance_of? Internal::ProxyTracerProvider logger.debug("Upgrading default proxy tracer provider to #{provider.class}") @tracer_provider.delegate = provider end @tracer_provider = provider end end |