/**
* @param RequestInterface $originalRequest
* @param ResponseInterface|null $response
*
* @return Span
*/
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)]);
}