class Middleware

internal  
 

Traits

Properties

protected Transaction|null $transaction

The current active transaction.

protected Span|null $appSpan

The span for the app.handle part of the application.

Methods

Span|null
getParentSpanIfSampled()

Get the current span if it is sampled.

void
withParentSpanIfSampled(callable $callback)

Call the callback with the current span if it is sampled.

SpanStatus|null
cancellationStatus(Throwable $cancellation, Throwable|null $exception = null)

Get the status of an operation that cancellation stopped.

__construct(bool $continueAfterResponse = true, bool $traceMissingRoutes = false)

Create a new tracing middleware instance.

Response
handle(Request $request, Closure $next)

Handle an incoming request.

void
terminate(Request $request, Response $response)

Perform cleanup after the response has been sent.

void
requestCanceled(RequestCanceled $event)

Complete the transaction when cancellation stopped the request before it terminated.

void
finishTransaction()

Finish the current transaction.

static void
signalRouteWasMatched()

Signal that a route was matched for the current request.

Details

in WorksWithSpans at line 18
protected Span|null getParentSpanIfSampled()

Get the current span if it is sampled.

Return Value

Span|null

in WorksWithSpans at line 35
protected void withParentSpanIfSampled(callable $callback)

Call the callback with the current span if it is sampled.

Parameters

callable $callback

Return Value

void

in WorksWithSpans at line 53
protected SpanStatus|null cancellationStatus(Throwable $cancellation, Throwable|null $exception = null)

Get the status of an operation that cancellation stopped.

A direct cancellation with no earlier failure leaves the status unset: it is control flow, and the SDK has no canceled status. A known failure, or a cleanup failure carrying the cancellation, is an error.

Parameters

Throwable $cancellation
Throwable|null $exception

Return Value

SpanStatus|null

at line 52
__construct(bool $continueAfterResponse = true, bool $traceMissingRoutes = false)

Create a new tracing middleware instance.

Parameters

bool $continueAfterResponse
bool $traceMissingRoutes

at line 61
Response handle(Request $request, Closure $next)

Handle an incoming request.

Parameters

Request $request
Closure $next

Return Value

Response

at line 76
void terminate(Request $request, Response $response)

Perform cleanup after the response has been sent.

When after-response tracing is enabled, a Coroutine::defer() registered in startTransaction() finishes the transaction after deferred work.

Parameters

Request $request
Response $response

Return Value

void

at line 106
void requestCanceled(RequestCanceled $event)

Complete the transaction when cancellation stopped the request before it terminated.

Parameters

RequestCanceled $event

Return Value

void

at line 285
void finishTransaction()

Finish the current transaction.

Return Value

void

at line 319
static void signalRouteWasMatched()

Signal that a route was matched for the current request.

Return Value

void