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: span vs transaction guzzle #1099

Merged
merged 2 commits into from Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fix: Use Span on Scope instead of Transaction for GuzzleMiddleware (#1099)

## 3.0.0 (2020-09-28)

**Tracing API**
Expand Down
14 changes: 7 additions & 7 deletions src/Tracing/GuzzleTracingMiddleware.php
Expand Up @@ -18,20 +18,20 @@ public static function trace(?HubInterface $hub = null): \Closure
return function (callable $handler) use ($hub): \Closure {
return function (RequestInterface $request, array $options) use ($hub, $handler) {
$hub = $hub ?? SentrySdk::getCurrentHub();
$transaction = $hub->getTransaction();
$span = null;
$span = $hub->getSpan();
$childSpan = null;

if (null !== $transaction) {
if (null !== $span) {
$spanContext = new SpanContext();
$spanContext->setOp('http.guzzle');
$spanContext->setDescription($request->getMethod() . ' ' . $request->getUri());

$span = $transaction->startChild($spanContext);
$childSpan = $span->startChild($spanContext);
}

$handlerPromiseCallback = static function ($responseOrException) use ($span) {
if (null !== $span) {
$span->finish();
$handlerPromiseCallback = static function ($responseOrException) use ($childSpan) {
if (null !== $childSpan) {
$childSpan->finish();
}

if ($responseOrException instanceof \Throwable) {
Expand Down