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** 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) {