From b11966f159b7f7c188af92d54659066e8cdb9680 Mon Sep 17 00:00:00 2001 From: Yury Gribkov Date: Fri, 13 Dec 2024 17:52:39 -0800 Subject: [PATCH] Integration Exception Tracking Add count --- ddtrace/internal/logger.py | 2 +- ddtrace/internal/telemetry/writer.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ddtrace/internal/logger.py b/ddtrace/internal/logger.py index 157ee8f50ab..81b88060738 100644 --- a/ddtrace/internal/logger.py +++ b/ddtrace/internal/logger.py @@ -218,7 +218,7 @@ def _report_telemetry_log(self, record): # TODO redact absolute file paths and unknown packages if record.levelno >= logging.ERROR or stack_trace is not None: # Report only an error or an exception with a stack trace - telemetry.telemetry_writer.add_log(level, record.msg, tags=tags, stack_trace=stack_trace) + telemetry.telemetry_writer.add_log(level, record.msg, tags=tags, stack_trace=stack_trace, count=key_bucket.skipped + 1) class _TelemetryConfig: diff --git a/ddtrace/internal/telemetry/writer.py b/ddtrace/internal/telemetry/writer.py index 899c77c1108..0f82a4b1cda 100644 --- a/ddtrace/internal/telemetry/writer.py +++ b/ddtrace/internal/telemetry/writer.py @@ -488,8 +488,8 @@ def add_configurations(self, configuration_list): "value": value, } - def add_log(self, level, message, stack_trace="", tags=None): - # type: (TELEMETRY_LOG_LEVEL, str, str, Optional[Dict]) -> None + def add_log(self, level, message, stack_trace="", tags=None, count=1): + # type: (TELEMETRY_LOG_LEVEL, str, str, Optional[Dict], int) -> None """ Queues log. This event is meant to send library logs to Datadog’s backend through the Telemetry intake. This will make support cycles easier and ensure we know about potentially silent issues in libraries. @@ -509,6 +509,8 @@ def add_log(self, level, message, stack_trace="", tags=None): data["tags"] = ",".join(["%s:%s" % (k, str(v).lower()) for k, v in tags.items()]) if stack_trace: data["stack_trace"] = stack_trace + if count > 1: + data["count"] = count self._logs.add(data) def add_gauge_metric(self, namespace, name, value, tags=None):