public fromIncomingResponse ( GuzzleHttp\Message\RequestInterface $originalRequest, GuzzleHttp\Message\ResponseInterface $response = null ) : |
||
$originalRequest | GuzzleHttp\Message\RequestInterface | |
$response | GuzzleHttp\Message\ResponseInterface | |
Результат |
public function fromIncomingResponse(RequestInterface $originalRequest, ResponseInterface $response = null)
{
$span = $originalRequest->getHeader('X-B3-SpanId');
$trace = $originalRequest->getHeader('X-B3-TraceId');
if (empty($span) || empty($trace)) {
throw new \InvalidArgumentException('Unable to find the original request properties');
}
return new Span(Identifier::fromString($span), $this->getName($originalRequest), Identifier::fromString($trace), [new Annotation(Annotation::CLIENT_RECEIVE, $this->clock->microseconds(), $this->endpointResolver->resolve())], [new BinaryAnnotation('http.status', $response !== null ? $response->getStatusCode() : 0, BinaryAnnotation::TYPE_INTEGER_16)]);
}
/** * @param RequestInterface $request * @param ResponseInterface|null $response */ public function onEnd(RequestInterface $request, ResponseInterface $response = null) { try { $span = $this->guzzleMessageSpanFactory->fromIncomingResponse($request, $response); } catch (\InvalidArgumentException $e) { return; } $this->tracer->trace([$span]); }