Skip to content

Commit

Permalink
Update http client breadcrumb/span data fields
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Nov 13, 2023
1 parent e773335 commit 256ee11
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/Sentry/Laravel/Features/HttpClientIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ public function handleRequestSendingHandlerForTracing(RequestSending $event): vo
$context->setDescription($event->request->method() . ' ' . $partialUri);
$context->setData([
'url' => $partialUri,

Check warning on line 61 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L58-L61

Added lines #L58 - L61 were not covered by tests
'http.request.method' => $event->request->method(),
// See: https://develop.sentry.dev/sdk/performance/span-data-conventions/#http
'http.query' => $fullUri->getQuery(),
'http.fragment' => $fullUri->getFragment(),
'http.request.method' => $event->request->method(),
'http.response_transfer_size' => $event->request->toPsrRequest()->getBody()->getSize(),

Check warning on line 66 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L63-L66

Added lines #L63 - L66 were not covered by tests
]);

$this->pushSpan($parentSpan->startChild($context));
Expand All @@ -73,6 +75,11 @@ public function handleResponseReceivedHandlerForTracing(ResponseReceived $event)

if ($span !== null) {
$span->finish();
$span->setData(array_merge($span->getData(), [

Check warning on line 78 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L76-L78

Added lines #L76 - L78 were not covered by tests
// See: https://develop.sentry.dev/sdk/performance/span-data-conventions/#http
'http.response.status_code' => $event->response->status(),
'http.response_content_length' => $event->response->toPsrResponse()->getBody()->getSize(),

Check warning on line 81 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L80-L81

Added lines #L80 - L81 were not covered by tests
]));
$span->setHttpStatus($event->response->status());

Check warning on line 83 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L83

Added line #L83 was not covered by tests
}
}

Check warning on line 85 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L85

Added line #L85 was not covered by tests
Expand Down Expand Up @@ -104,12 +111,13 @@ public function handleResponseReceivedHandlerForBreadcrumb(ResponseReceived $eve
null,

Check warning on line 111 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L109-L111

Added lines #L109 - L111 were not covered by tests
[
'url' => $this->getPartialUri($fullUri),

Check warning on line 113 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L113

Added line #L113 was not covered by tests
'http.request.method' => $event->request->method(),
'http.response.status_code' => $event->response->status(),
// See: https://develop.sentry.dev/sdk/performance/span-data-conventions/#http
'http.query' => $fullUri->getQuery(),
'http.fragment' => $fullUri->getFragment(),
'http.request.body.size' => $event->request->toPsrRequest()->getBody()->getSize(),
'http.response.body.size' => $event->response->toPsrResponse()->getBody()->getSize(),
'http.request.method' => $event->request->method(),
'http.response.status_code' => $event->response->status(),
'http.response_transfer_size' => $event->request->toPsrRequest()->getBody()->getSize(),
'http.response_content_length' => $event->response->toPsrResponse()->getBody()->getSize(),

Check warning on line 120 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L115-L120

Added lines #L115 - L120 were not covered by tests
]
));
}

Check warning on line 123 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L123

Added line #L123 was not covered by tests
Expand All @@ -125,10 +133,11 @@ public function handleConnectionFailedHandlerForBreadcrumb(ConnectionFailed $eve
null,

Check warning on line 133 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L129-L133

Added lines #L129 - L133 were not covered by tests
[
'url' => $this->getPartialUri($fullUri),

Check warning on line 135 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L135

Added line #L135 was not covered by tests
'http.request.method' => $event->request->method(),
// See: https://develop.sentry.dev/sdk/performance/span-data-conventions/#http
'http.query' => $fullUri->getQuery(),
'http.fragment' => $fullUri->getFragment(),
'http.request.body.size' => $event->request->toPsrRequest()->getBody()->getSize(),
'http.request.method' => $event->request->method(),
'http.response_transfer_size' => $event->request->toPsrRequest()->getBody()->getSize(),

Check warning on line 140 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L137-L140

Added lines #L137 - L140 were not covered by tests
]
));
}

Check warning on line 143 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L143

Added line #L143 was not covered by tests
Expand All @@ -154,7 +163,7 @@ private function getFullUri(string $url): UriInterface
*/
private function getPartialUri(UriInterface $uri): string

Check warning on line 164 in src/Sentry/Laravel/Features/HttpClientIntegration.php

View check run for this annotation

Codecov / codecov/patch

src/Sentry/Laravel/Features/HttpClientIntegration.php#L164

Added line #L164 was not covered by tests
{
return (string) Uri::fromParts([
return (string)Uri::fromParts([
'scheme' => $uri->getScheme(),
'host' => $uri->getHost(),
'port' => $uri->getPort(),
Expand Down

0 comments on commit 256ee11

Please sign in to comment.