Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Dec 13, 2024
1 parent bc36cfb commit 341b234
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/datadog/core/telemetry/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,20 @@ def type
'logs'
end

# @param message [String] the log message
# @param level [Symbol, String] the log level. Either :error, :warn, 'ERROR', or 'WARN'.
# @param stack_trace [String, nil] the stack trace
# @param count [Integer] the number of times the log was emitted. Used for deduplication.
def initialize(message:, level:, stack_trace: nil, count: 1)
super()
@message = 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}"
Expand Down
6 changes: 3 additions & 3 deletions lib/datadog/core/telemetry/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def disable_on_not_found!(response)
disable!
end

# Deduplicate all_logs by counting the number of occurrences of each log
# entry and replacing them with a single entry with the count.
# Other events are passed through unchanged.
# Deduplicate logs by counting the number of repeated occurrences of the same log
# entry and replacing them with a single entry with the calculated `count` value.
# Non-log events are unchanged.
def deduplicate_logs(events)
return events if events.empty?

Expand Down

0 comments on commit 341b234

Please sign in to comment.