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

add HTTP Client tracing #18

Merged
merged 2 commits into from
Aug 21, 2024
Merged

add HTTP Client tracing #18

merged 2 commits into from
Aug 21, 2024

Conversation

LordSimal
Copy link
Owner

image

@LordSimal LordSimal requested a review from cleptric July 27, 2024 18:34
@LordSimal
Copy link
Owner Author

I am confused - how does sentry know how long the request took and/or when the span should be started? It looks to me like it starts the span at the end of when the response was already received.

if ($parentSpan !== null) {
$context = SpanContext::make()
->setOp('http.client');
$span = $parentSpan->startChild($context);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to start the span on HttpClient.beforeSend and end it on HttpClient.afterSend.

Comment on lines 48 to 52
->setData([
'http.request.method' => $request->getMethod(),
'http.response.body.size' => $response?->getBody()?->getSize(),
'http.response.status_code' => $response?->getStatusCode() ?? 0,
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cleptric
Copy link
Collaborator

@LordSimal
Copy link
Owner Author

thanks, that definitely helped.

@@ -76,6 +77,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$this->addQueryData();
$listener = new EventListener();
EventManager::instance()->on($listener);
EventManager::instance()->on(new HttpEventListener());
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the next major realease of this plugin I would like to unify the listener classes into their own folder/namespace. Didn't expect that I already need multiple implementations of different event listeners already.

@LordSimal LordSimal force-pushed the add-http-client-requests branch from 49a181d to fecccdc Compare July 28, 2024 16:21
@LordSimal LordSimal changed the title add HTTP Client tracing + fix Cake 5.1 error logger bug add HTTP Client tracing Aug 3, 2024
@LordSimal LordSimal force-pushed the add-http-client-requests branch from e1cf247 to f11c5cb Compare August 21, 2024 12:50
@LordSimal LordSimal merged commit aa30628 into 3.next Aug 21, 2024
5 checks passed
@LordSimal LordSimal deleted the add-http-client-requests branch August 21, 2024 12:51
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