EventSubscriber
class EventSubscriber implements SubscriberInterface
This class handles integration with GuzzleHttp 5. Attaching this EventSubscriber to your Guzzle client, will enable distrubted tracing by passing along the trace context header and will also create trace spans for all outgoing requests.
Example:
use GuzzleHttp\Client;
use OpenCensus\Trace\Integrations\Guzzle\EventSubscriber;
$client = new Client();
$subscriber = new EventSubscriber();
$client->getEmitter()->attach($subscriber);
Methods
Create a new Guzzle event listener that creates trace spans and propagates the current trace context to the downstream request.
Returns an array of event names this subscriber wants to listen to.
Handler for the BeforeEvent request lifecycle event. Adds the current trace context as the trace context header. Also starts a span representing this outgoing http request.
Handler for the EndEvent request lifecycle event. Ends the current span which should be the span started in the BeforeEvent handler.
Details
at line 62
__construct(PropagatorInterface $propagator = null)
Create a new Guzzle event listener that creates trace spans and propagates the current trace context to the downstream request.
at line 72
array
getEvents()
Returns an array of event names this subscriber wants to listen to.
at line 86
onBefore(BeforeEvent $event)
Handler for the BeforeEvent request lifecycle event. Adds the current trace context as the trace context header. Also starts a span representing this outgoing http request.
at line 110
onEnd(EndEvent $event)
Handler for the EndEvent request lifecycle event. Ends the current span which should be the span started in the BeforeEvent handler.