Class: Datadog::Core::Telemetry::Event::Log

Inherits:
Base
  • Object
show all
Defined in:
lib/datadog/core/telemetry/event.rb

Overview

Telemetry class for the ‘logs’ event

Constant Summary collapse

LEVELS =
{
  error: 'ERROR',
  warn: 'WARN',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(message:, level:, stack_trace: nil) ⇒ Log

Returns a new instance of Log.



351
352
353
354
355
356
# File 'lib/datadog/core/telemetry/event.rb', line 351

def initialize(message:, level:, stack_trace: nil)
  super()
  @message = message
  @stack_trace = stack_trace
  @level = LEVELS.fetch(level) { |k| raise ArgumentError, "Invalid log level :#{k}" }
end

Instance Method Details

#payloadObject



358
359
360
361
362
363
364
365
366
367
368
# File 'lib/datadog/core/telemetry/event.rb', line 358

def payload
  {
    logs: [
      {
        message: @message,
        level: @level,
        stack_trace: @stack_trace,
      }.compact
    ]
  }
end

#typeObject



347
348
349
# File 'lib/datadog/core/telemetry/event.rb', line 347

def type
  'logs'
end