Class: Datadog::Core::Telemetry::Event::Log
- Defined in:
- lib/datadog/core/telemetry/event.rb
Overview
Telemetry class for the ‘logs’ event. Logs with the same content are deduplicated at flush time.
Constant Summary collapse
- LEVELS =
{ error: 'ERROR', warn: 'WARN', }.freeze
- LEVELS_STRING =
LEVELS.values.freeze
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#stack_trace ⇒ Object
readonly
Returns the value of attribute stack_trace.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
override equality to allow for deduplication.
- #hash ⇒ Object
-
#initialize(message:, level:, stack_trace: nil, count: 1) ⇒ Log
constructor
A new instance of Log.
- #payload ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(message:, level:, stack_trace: nil, count: 1) ⇒ Log
Returns a new instance of Log.
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/datadog/core/telemetry/event.rb', line 405 def initialize(message:, level:, stack_trace: nil, count: 1) super() = @stack_trace = stack_trace if level.is_a?(String) && LEVELS_STRING.include?(level) # String level is used during object copy for deduplication @level = level elsif level.is_a?(Symbol) # Symbol level is used by the regular log emitter user @level = LEVELS.fetch(level) { |k| raise ArgumentError, "Invalid log level :#{k}" } else raise ArgumentError, "Invalid log level #{level}" end @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
395 396 397 |
# File 'lib/datadog/core/telemetry/event.rb', line 395 def count @count end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
395 396 397 |
# File 'lib/datadog/core/telemetry/event.rb', line 395 def level @level end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
395 396 397 |
# File 'lib/datadog/core/telemetry/event.rb', line 395 def end |
#stack_trace ⇒ Object (readonly)
Returns the value of attribute stack_trace.
395 396 397 |
# File 'lib/datadog/core/telemetry/event.rb', line 395 def stack_trace @stack_trace end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
override equality to allow for deduplication
437 438 439 440 441 |
# File 'lib/datadog/core/telemetry/event.rb', line 437 def ==(other) other.is_a?(Log) && other. == && other.level == @level && other.stack_trace == @stack_trace && other.count == @count end |
#hash ⇒ Object
445 446 447 |
# File 'lib/datadog/core/telemetry/event.rb', line 445 def hash [self.class, , @level, @stack_trace, @count].hash end |
#payload ⇒ Object
423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/datadog/core/telemetry/event.rb', line 423 def payload { logs: [ { message: , level: @level, stack_trace: @stack_trace, count: @count, }.compact ] } end |
#type ⇒ Object
397 398 399 |
# File 'lib/datadog/core/telemetry/event.rb', line 397 def type 'logs' end |