class Lumberjack::DataDogDevice

This Lumberjack device logs output to another device as JSON formatted text that maps fields to the standard JSON payload for DataDog log collection.

See docs.datadoghq.com/logs/log_collection

Attributes

backtrace_cleaner[RW]

You can specify a backtrace cleaner that will be called with exception backtraces before they are added to the payload. You can use this to remove superfluous lines, compress line length, etc. One use for it is to keep stack traces clean and prevent them from overflowing the limit on the payload size for an individual log entry.

max_message_length[RW]

You can specify a limit on the message size. Messages over this size will be split into multiple log entries to prevent overflowing the limit on message size which makes the log entries unparseable.

Public Class Methods

new(stream_or_device, backtrace_cleaner: nil, max_message_length: nil) click to toggle source
Calls superclass method
# File lib/lumberjack_data_dog_device.rb, line 141
def initialize(stream_or_device, backtrace_cleaner: nil, max_message_length: nil)
  super(stream_or_device, mapping: data_dog_mapping)
  self.backtrace_cleaner = backtrace_cleaner
  self.max_message_length = max_message_length
end

Private Instance Methods

data_dog_mapping() click to toggle source
# File lib/lumberjack_data_dog_device.rb, line 149
def data_dog_mapping
  {
    time: "timestamp",
    severity: "status",
    progname: ["logger", "name"],
    pid: "pid",
    message: MessageExceptionFormatter.new(self),
    duration: DurationFormatter.new(1_000_000_000),
    duration_ms: DurationFormatter.new(1_000_000),
    duration_micros: DurationFormatter.new(1_000),
    duration_ns: "duration",
    tags: DataDogTagsFormatter.new(self)
  }
end