Skip to content

Commit 8d79908

Browse files
github-actions[bot]mabdinuremmettbutler
authored
chore(telemetry): make logs less noisy and more clear [backport 2.19] (#11876)
Backport 33b2499 from #11853 to 2.19. Partially Resolves: #10842 - Removes exception traceback from telemetry client logs. We should not generate a traceback everytime we fail to send telemetry payloads to the agent. This traceback is noisy and not actionable. - Updates telemetry client log message to clearly state that instrumentation telemetry failed to send and not user telemetry (ex: traces, logs, metrics). ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: Emmett Butler <[email protected]>
1 parent 3d0089c commit 8d79908

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ddtrace/internal/telemetry/writer.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,17 @@ def send_event(self, request: Dict) -> Optional[httplib.HTTPResponse]:
118118
conn.request("POST", self._endpoint, rb_json, headers)
119119
resp = get_connection_response(conn)
120120
if resp.status < 300:
121-
log.debug("sent %d in %.5fs to %s. response: %s", len(rb_json), sw.elapsed(), self.url, resp.status)
121+
log.debug(
122+
"Instrumentation Telemetry sent %d in %.5fs to %s. response: %s",
123+
len(rb_json),
124+
sw.elapsed(),
125+
self.url,
126+
resp.status,
127+
)
122128
else:
123-
log.debug("failed to send telemetry to %s. response: %s", self.url, resp.status)
124-
except Exception:
125-
log.debug("failed to send telemetry to %s.", self.url, exc_info=True)
129+
log.debug("Failed to send Instrumentation Telemetry to %s. response: %s", self.url, resp.status)
130+
except Exception as e:
131+
log.debug("Failed to send Instrumentation Telemetry to %s. Error: %s", self.url, str(e))
126132
finally:
127133
if conn is not None:
128134
conn.close()

tests/telemetry/test_writer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def test_send_failing_request(mock_status, telemetry_writer):
638638
telemetry_writer.periodic(force_flush=True)
639639
# asserts unsuccessful status code was logged
640640
log.debug.assert_called_with(
641-
"failed to send telemetry to %s. response: %s",
641+
"Failed to send Instrumentation Telemetry to %s. response: %s",
642642
telemetry_writer._client.url,
643643
mock_status,
644644
)

0 commit comments

Comments
 (0)