Fix the decoration of the HTTP client when tracing is enabled #786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The distributed tracing functionality for the HTTP client has been broken for a long time: first, the decoration of the raw HTTP client does not happen correctly, leading to a double presence of our instrumentation in the decoration chain. Second, but not least, because our instrumentation runs before we have the complete URL of the request, the reported span includes incomplete and/or misleading information.
This PR is an attempt to fix #700 based on @simonberger's contribution in #704. Starting from Symfony
6.3
, the framework decoration strategy was revisited and this made the fix quite simple. However, on older versions of the framework, each built-in decorator of the HTTP client (e.g. theRetryableHttpClient
), references in the constructor the.inner
service of the client being decorated, making impossible to inject our own client at a given position because no real decoration chain exists. For this reason, I had to hardcode and decorate the specific services created by the framework inFrameworkExtension
, rather than the raw HTTP client.