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.
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/datadog/core/telemetry/event.rb', line 400 def initialize(message:, level:, stack_trace: nil, count: 1) super() @message = @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.
390 391 392 |
# File 'lib/datadog/core/telemetry/event.rb', line 390 def count @count end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
390 391 392 |
# File 'lib/datadog/core/telemetry/event.rb', line 390 def level @level end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
390 391 392 |
# File 'lib/datadog/core/telemetry/event.rb', line 390 def @message end |
#stack_trace ⇒ Object (readonly)
Returns the value of attribute stack_trace.
390 391 392 |
# File 'lib/datadog/core/telemetry/event.rb', line 390 def stack_trace @stack_trace end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
override equality to allow for deduplication
432 433 434 435 436 |
# File 'lib/datadog/core/telemetry/event.rb', line 432 def ==(other) other.is_a?(Log) && other. == @message && other.level == @level && other.stack_trace == @stack_trace && other.count == @count end |
#hash ⇒ Object
440 441 442 |
# File 'lib/datadog/core/telemetry/event.rb', line 440 def hash [self.class, @message, @level, @stack_trace, @count].hash end |
#payload ⇒ Object
418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/datadog/core/telemetry/event.rb', line 418 def payload { logs: [ { message: @message, level: @level, stack_trace: @stack_trace, count: @count, }.compact ] } end |
#type ⇒ Object
392 393 394 |
# File 'lib/datadog/core/telemetry/event.rb', line 392 def type 'logs' end |