Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/stream tracing #49

Merged
merged 3 commits into from
Jan 24, 2024
Merged

Fix/stream tracing #49

merged 3 commits into from
Jan 24, 2024

Conversation

cyve
Copy link
Collaborator

@cyve cyve commented Dec 29, 2023

Currently in TracedResponse:: toStream(), we end the tracing just after the creation of the stream. But when the server do HTTP streaming, the stream is empty at the beginning, and will be filled progressively. Later in the endTracing() method, we use stream_get_content() to add the response body to the trace attribute, which means PHP waits for the full body to be downloaded before continue to execute some code.

In this PR, we end the tracing when we receive the last chunk of the HTTP response. This allows PHP to continue to execute code asynchronously after the call to toStream(), while the response body is downloaded.

@cyve cyve requested a review from cdaguerre December 29, 2023 10:14
@cyve cyve force-pushed the fix/stream-tracing branch from 57e6ba0 to 4d4feea Compare December 29, 2023 12:00
src/Http/TracingHttpClient.php Outdated Show resolved Hide resolved
src/Http/TracedResponse.php Outdated Show resolved Hide resolved
src/Http/TracingHttpClient.php Outdated Show resolved Hide resolved
@cyve cyve force-pushed the fix/stream-tracing branch from 4d4feea to e0727dd Compare January 11, 2024 17:17
@cyve cyve force-pushed the fix/stream-tracing branch from e0727dd to 7cf2cba Compare January 11, 2024 17:22
@cyve cyve force-pushed the fix/stream-tracing branch from b299090 to 047ec83 Compare January 24, 2024 13:12
@cyve cyve merged commit 50c380a into master Jan 24, 2024
6 checks passed
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.

2 participants