Module: OpenTelemetry::SDK

Extended by:
SDK
Included in:
SDK
Defined in:
lib/opentelemetry/sdk.rb,
lib/opentelemetry/sdk/trace.rb,
lib/opentelemetry/sdk/version.rb,
lib/opentelemetry/sdk/internal.rb,
lib/opentelemetry/sdk/resources.rb,
lib/opentelemetry/sdk/trace/span.rb,
lib/opentelemetry/sdk/trace/event.rb,
lib/opentelemetry/sdk/configurator.rb,
lib/opentelemetry/sdk/trace/export.rb,
lib/opentelemetry/sdk/trace/tracer.rb,
lib/opentelemetry/sdk/trace/samplers.rb,
lib/opentelemetry/sdk/trace/span_data.rb,
lib/opentelemetry/sdk/forwarding_logger.rb,
lib/opentelemetry/sdk/trace/span_limits.rb,
lib/opentelemetry/sdk/resources/resource.rb,
lib/opentelemetry/sdk/trace/span_processor.rb,
lib/opentelemetry/sdk/trace/samplers/result.rb,
lib/opentelemetry/sdk/trace/tracer_provider.rb,
lib/opentelemetry/sdk/instrumentation_library.rb,
lib/opentelemetry/sdk/trace/samplers/decision.rb,
lib/opentelemetry/sdk/trace/export/span_exporter.rb,
lib/opentelemetry/sdk/trace/samplers/parent_based.rb,
lib/opentelemetry/sdk/trace/export/metrics_reporter.rb,
lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb,
lib/opentelemetry/sdk/trace/export/batch_span_processor.rb,
lib/opentelemetry/sdk/trace/export/console_span_exporter.rb,
lib/opentelemetry/sdk/trace/export/simple_span_processor.rb,
lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb,
lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb

Overview

SDK provides the reference implementation of the OpenTelemetry API.

Defined Under Namespace

Modules: Internal, Resources, Trace Classes: Configurator, ForwardingLogger, InstrumentationLibrary

Constant Summary collapse

VERSION =

Current OpenTelemetry version

'1.1.0'
ConfigurationError =

ConfigurationError is an exception type used to wrap configuration errors passed to OpenTelemetry.error_handler. This can be used to distinguish errors reported during SDK configuration.

Class.new(OpenTelemetry::Error)

Instance Method Summary collapse

Instance Method Details

#configure {|configurator| ... } ⇒ Object

Configures SDK and instrumentation

Example usage: Without a block defaults are installed without any instrumentation

OpenTelemetry::SDK.configure

Install instrumentation individually with optional config

OpenTelemetry::SDK.configure do |c|
  c.use 'OpenTelemetry::Instrumentation::Faraday', tracer_middleware: SomeMiddleware
end

Install all instrumentation with optional config

OpenTelemetry::SDK.configure do |c|
  c.use_all 'OpenTelemetry::Instrumentation::Faraday' => { tracer_middleware: SomeMiddleware }
end

Add a span processor

OpenTelemetry::SDK.configure do |c|
  c.add_span_processor SpanProcessor.new(SomeExporter.new)
end

Configure everything

OpenTelemetry::SDK.configure do |c|
  c.logger = Logger.new(File::NULL)
  c.add_span_processor SpanProcessor.new(SomeExporter.new)
  c.use_all
end

Yield Parameters:

  • configurator (Configurator)

    Yields a configurator to the provided block



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/opentelemetry/sdk.rb', line 63

def configure
  configurator = Configurator.new
  yield configurator if block_given?
  configurator.configure
rescue StandardError
  begin
    raise ConfigurationError
  rescue ConfigurationError => e
    OpenTelemetry.handle_error(exception: e, message: "unexpected configuration error due to #{e.cause}")
  end
end