Class: ScoutApm::Logging::Loggers::OpenTelemetry::SDK::Logs::Logger

Inherits:
Logs::Logger
  • Object
show all
Defined in:
lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger.rb

Overview

The SDK implementation of OpenTelemetry::Logs::Logger

Instance Method Summary collapse

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 ScoutApm::Logging::Loggers::OpenTelemetry::SDK::Logs::Logger instance. This should not be called directly. New loggers should be created using ScoutApm::Logging::Loggers::OpenTelemetry::SDK::Logs::LoggerProvider#logger.

Parameters:



27
28
29
30
# File 'lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger.rb', line 27

def initialize(name, version, logger_provider)
  @instrumentation_scope = ::OpenTelemetry::SDK::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

Parameters:

  • timestamp (optional Time) (defaults to: nil)

    Time when the event occurred.

  • observed_timestamp (optional Time) (defaults to: Time.now)

    Time when the event was observed by the collection system.

  • span_context (optional OpenTelemetry::Trace::SpanContext)

    The OpenTelemetry::Trace::SpanContext to associate with the ScoutApm::Logging::Loggers::OpenTelemetry::SDK::Logs::LogRecord.

  • severity_number (optional Integer) (defaults to: nil)

    Numerical value of the severity. Smaller numerical values correspond to less severe events (such as debug events), larger numerical values correspond to more severe events (such as errors and critical events).

  • body (optional String, Numeric, Boolean, Array<String, Numeric, Boolean>, Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil)

    A value containing the body of the log record.

  • attributes (optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil)

    Additional information about the event.

  • trace_id (optional String (16-byte binary)) (defaults to: nil)

    Request trace id as defined in W3C Trace Context. Can be set for logs that are part of request processing and have an assigned trace id.

  • span_id (optional String (8-byte binary)) (defaults to: nil)

    Span id. Can be set for logs that are part of a particular processing span. If span_id is present trace_id should also be present.

  • trace_flags (optional Integer (8-bit byte of bit flags)) (defaults to: nil)

    Trace flag as defined in W3C Trace Context specification. At the time of writing the specification defines one flag - the SAMPLED flag.

  • context (optional OpenTelemetry::Context) (defaults to: ::OpenTelemetry::Context.current)

    The OpenTelemetry::Context to associate with the ScoutApm::Logging::Loggers::OpenTelemetry::SDK::Logs::LogRecord.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger.rb', line 65

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)

  @logger_provider.on_emit(timestamp: timestamp,
                          observed_timestamp: observed_timestamp,
                          severity_text: severity_text,
                          severity_number: severity_number,
                          body: body,
                          attributes: attributes,
                          trace_id: nil,
                          span_id: nil,
                          trace_flags: nil,
                          instrumentation_scope: @instrumentation_scope,
                          context: context)
end