Module: Datadog::Core::Telemetry::Logging

Included in:
Component
Defined in:
lib/datadog/core/telemetry/logging.rb

Overview

INTERNAL USAGE ONLY ===

Logging interface for sending telemetry logs… so we can fix them.

For developer using this module:

  • MUST NOT provide any sensitive information (PII)

  • SHOULD reduce the data cardinality for batching/aggregation

Before using it, ask yourself:

  • Do we need to know about this (ie. internal error or client error)?

  • How severe/critical is this error? (ie. error, warning, fatal)

  • What information needed to make it actionable?

Defined Under Namespace

Modules: DatadogStackTrace

Instance Method Summary collapse

Instance Method Details

#error(description) ⇒ Object



72
73
74
75
76
# File 'lib/datadog/core/telemetry/logging.rb', line 72

def error(description)
  event = Event::Log.new(message: description, level: :error)

  log!(event)
end

#report(exception, level: :error, description: nil) ⇒ Object

Parameters:

  • exception (Exception)

    The exception to report

  • level (Symbol) (defaults to: :error)

    The log level (:error, :warn, :info, :debug)

  • description (String, nil) (defaults to: nil)

    A low cardinality description, without dynamic data



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/datadog/core/telemetry/logging.rb', line 51

def report(exception, level: :error, description: nil)
  # Anonymous exceptions to be logged as <Class:0x00007f8b1c0b3b40>
  message = +(exception.class.name || exception.class.inspect)

  telemetry_message = message_for_telemetry(exception)

  if description || telemetry_message
    message << ':'
    message << " #{description}" if description
    message << " (#{telemetry_message})" if telemetry_message
  end

  event = Event::Log.new(
    message: message,
    level: level,
    stack_trace: DatadogStackTrace.from(exception)
  )

  log!(event)
end