Class: Datadog::Core::Telemetry::Event::Log Private
- Defined in:
- lib/datadog/core/telemetry/event/log.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Telemetry class for the ‘logs’ event. Logs with the same content are deduplicated at flush time.
Constant Summary collapse
- LEVELS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ error: 'ERROR', warn: 'WARN', }.freeze
- LEVELS_STRING =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
LEVELS.values.freeze
Instance Attribute Summary collapse
- #count ⇒ Object readonly private
- #level ⇒ Object readonly private
- #message ⇒ Object readonly private
- #stack_trace ⇒ Object readonly private
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
private
override equality to allow for deduplication.
- #hash ⇒ Object private
-
#initialize(message:, level:, stack_trace: nil, count: 1) ⇒ Log
constructor
private
A new instance of Log.
- #payload ⇒ Object private
- #type ⇒ Object private
Constructor Details
#initialize(message:, level:, stack_trace: nil, count: 1) ⇒ Log
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Log.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 29 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)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 19 def count @count end |
#level ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 19 def level @level end |
#message ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 19 def @message end |
#stack_trace ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 19 def stack_trace @stack_trace end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
override equality to allow for deduplication
61 62 63 64 65 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 61 def ==(other) other.is_a?(Log) && other. == @message && other.level == @level && other.stack_trace == @stack_trace && other.count == @count end |
#hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 69 def hash [self.class, @message, @level, @stack_trace, @count].hash end |
#payload ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 47 def payload { logs: [ { message: @message, level: @level, stack_trace: @stack_trace, count: @count, }.compact ] } end |
#type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/datadog/core/telemetry/event/log.rb', line 21 def type 'logs' end |