Class: OpenTelemetry::SDK::Logs::Logger
- Inherits:
-
Logs::Logger
- Object
- Logs::Logger
- OpenTelemetry::SDK::Logs::Logger
- Defined in:
- lib/opentelemetry/sdk/logs/logger.rb
Overview
The SDK implementation of OpenTelemetry::Logs::Logger
Instance Method Summary collapse
-
#initialize(name, version, logger_provider) ⇒ OpenTelemetry::SDK::Logs::Logger
constructor
private
Returns a new Logger instance.
-
#on_emit(timestamp: nil, observed_timestamp: Time.now, severity_text: nil, severity_number: nil, body: nil, attributes: nil, trace_id: nil, span_id: nil, trace_flags: nil, context: OpenTelemetry::Context.current) ⇒ Object
Emit a LogRecord to the processing pipeline.
Constructor Details
#initialize(name, version, logger_provider) ⇒ OpenTelemetry::SDK::Logs::Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new OpenTelemetry::SDK::Logs::Logger instance. This should not be called directly. New loggers should be created using OpenTelemetry::SDK::Logs::LoggerProvider#logger.
24 25 26 27 |
# File 'lib/opentelemetry/sdk/logs/logger.rb', line 24 def initialize(name, version, logger_provider) @instrumentation_scope = InstrumentationScope.new(name, version) @logger_provider = logger_provider end |
Instance Method Details
#on_emit(timestamp: nil, observed_timestamp: Time.now, severity_text: nil, severity_number: nil, body: nil, attributes: nil, trace_id: nil, span_id: nil, trace_flags: nil, context: OpenTelemetry::Context.current) ⇒ Object
Emit a OpenTelemetry::SDK::Logs::LogRecord to the processing pipeline.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/opentelemetry/sdk/logs/logger.rb', line 64 def on_emit(timestamp: nil, observed_timestamp: Time.now, severity_text: nil, severity_number: nil, body: nil, attributes: nil, trace_id: nil, span_id: nil, trace_flags: nil, context: OpenTelemetry::Context.current) current_span = OpenTelemetry::Trace.current_span(context) span_context = current_span.context unless current_span == OpenTelemetry::Trace::Span::INVALID @logger_provider.on_emit(timestamp: , observed_timestamp: , severity_text: severity_text, severity_number: severity_number, body: body, attributes: attributes, trace_id: trace_id || span_context&.trace_id, span_id: span_id || span_context&.span_id, trace_flags: trace_flags || span_context&.trace_flags, instrumentation_scope: @instrumentation_scope, context: context) end |