From deb7c015c20e488660205fa17e9a09b62ff43631 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 29 Sep 2020 11:35:40 +0200 Subject: [PATCH 1/2] fix: Use Span instead of transaction for guzzle --- src/Tracing/GuzzleTracingMiddleware.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Tracing/GuzzleTracingMiddleware.php b/src/Tracing/GuzzleTracingMiddleware.php index 95720574d..8c54ac32f 100644 --- a/src/Tracing/GuzzleTracingMiddleware.php +++ b/src/Tracing/GuzzleTracingMiddleware.php @@ -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) { From 92bd095a30d1a4965b46177b3dfc5343b2420878 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 29 Sep 2020 12:53:16 +0200 Subject: [PATCH 2/2] meta: Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 607d5ef47..d0f9afdc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- fix: Use Span on Scope instead of Transaction for GuzzleMiddleware (#1099) + ## 3.0.0 (2020-09-28) **Tracing API**