Skip to content

Conversation

@dd-octo-sts
Copy link
Contributor

@dd-octo-sts dd-octo-sts bot commented Dec 12, 2025

Backport be6ff63 from #15559 to 4.0.

Description

Previously, the http writer was calling from_http_response in the else block of the exception handler that does the request, set's the log level, et cetera. However this could have the problem of from_http_response itself raising an exception (e.g. http.client.IncompleteRead as seen on dogweb staging recently) outside of the Exception handler, which would leave the HTTPWriter object in need of a call to _reset; the finally would call _reset but only if reuse_connection aka DD_TRACE_WRITER_REUSE_CONNECTIONS was enabled, which is not the default.

Testing

New tests have been added.

Risks

Additional Notes

…tion (#15559)

## Description

Previously, the http writer was calling `from_http_response` in the
`else` block of the exception handler that does the request, set's the
log level, et cetera. However this could have the problem of
`from_http_response` itself raising an exception (e.g.
`http.client.IncompleteRead` as seen on dogweb staging recently) outside
of the `Exception` handler, which would leave the `HTTPWriter` object in
need of a call to `_reset`; the `finally` would call `_reset` but only
if `reuse_connection` aka `DD_TRACE_WRITER_REUSE_CONNECTIONS` was
enabled, which is not the default.

## Testing
New tests have been added.

## Risks

<!-- Note any risks associated with this change, or "None" if no risks
-->

## Additional Notes

<!-- Any other information that would be helpful for reviewers -->

---------

Signed-off-by: Juanjo Alvarez <[email protected]>
Co-authored-by: Quinna Halim <[email protected]>
(cherry picked from commit be6ff63)
@dd-octo-sts dd-octo-sts bot requested review from a team as code owners December 12, 2025 20:02
@dd-octo-sts dd-octo-sts bot requested review from juanjux, mabdinur and ncybul December 12, 2025 20:02
@github-actions
Copy link
Contributor

CODEOWNERS have been resolved as:

releasenotes/notes/http-writer-reset-090a35e52645e36e.yaml              @DataDog/apm-python
ddtrace/internal/writer/writer.py                                       @DataDog/apm-core-python
tests/tracer/test_writer.py                                             @DataDog/apm-sdk-capabilities-python

@github-actions
Copy link
Contributor

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 247 ± 5 ms.

The average import time from base is: 246 ± 3 ms.

The import time difference between this PR and base is: 1.8 ± 0.2 ms.

Import time breakdown

The following import paths have grown:

ddtrace.auto 0.084 ms (0.03%)
ddtrace.bootstrap.sitecustomize 0.084 ms (0.03%)
ddtrace.bootstrap.preload 0.084 ms (0.03%)
ddtrace.internal.core.crashtracking 0.084 ms (0.03%)

The following import paths have shrunk:

ddtrace.auto 1.227 ms (0.50%)
ddtrace 0.671 ms (0.27%)
ddtrace.internal._unpatched 0.027 ms (0.01%)
json 0.027 ms (0.01%)
json.decoder 0.027 ms (0.01%)
re 0.027 ms (0.01%)
enum 0.027 ms (0.01%)
types 0.027 ms (0.01%)
ddtrace.bootstrap.sitecustomize 0.556 ms (0.22%)
ddtrace.bootstrap.preload 0.556 ms (0.22%)
ddtrace.internal.remoteconfig.client 0.556 ms (0.22%)

@emmettbutler
Copy link
Collaborator

This doesn't seem critical enough to backport cc @juanjux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants