auxmoney/opentracing-bundle-guzzle
auxmoney/opentracing-bundle via Composer:
composer require auxmoney/opentracing-bundle
composer require auxmoney/opentracing-bundle-guzzle
// config/bundles.php
Auxmoney\OpentracingGuzzleBundle\OpentracingGuzzleBundle::class => ['all' => true],
For Symfony Flex, no manual configuration is needed.Inject tracing into a Guzzle HTTP client automatically. Example:
use GuzzleHttp\Client;
// Your existing client (will be auto-enhanced)
$client = new Client(['base_uri' => 'https://api.example.com']);
// Send a request - tracing headers are injected automatically
$response = $client->get('/endpoint');
GuzzleHttp\Client instances with tracing middleware via a compiler pass.For factory-created clients (e.g., via GuzzleHttp\ClientFactory), explicitly decorate them:
use Auxmoney\OpentracingGuzzleBundle\Middleware\TracingMiddleware;
// Create client with tracing middleware
$client = new Client([
'handler' => HandlerStack::create([
new TracingMiddleware(),
// Other middleware...
]),
]);
onRejected handlers for error tracing.$promise = $client->getAsync('/endpoint')
->then(function ($response) { /* ... */ })
->otherwise(function ($exception) { /* Tracing context preserved */ });
Disable tracing for specific clients by excluding middleware:
$client = new Client([
'handler' => HandlerStack::create([
// Skip TracingMiddleware for this client
]),
]);
Missing Core Bundle:
auxmoney/opentracing-bundle. Install it first or tracing won’t work.Class 'Auxmoney\OpentracingBundle\Tracer' not found.Guzzle Version Mismatch:
Factory-Created Clients:
GuzzleHttp\ClientFactory) won’t auto-decorate unless manually configured (see Implementation Patterns).Span Nesting Issues:
Error Tracing:
onRejected) may not propagate tracing context if not handled explicitly. Use:
$promise->otherwise(function ($exception) use ($tracer) {
$tracer->getActiveSpan()->log(['error' => $exception->getMessage()]);
});
$tracer = $container->get('opentracing.tracer');
$activeSpan = $tracer->getActiveSpan();
uber-trace-id):
$client->get('/endpoint', ['debug' => true]);
if (!$this->isTracingEnabled()) {
$client = new Client(['handler' => new HandlerStack()]);
}
Custom Span Tags: Add metadata to spans via middleware:
$span->setTag('http.url', $request->getUri());
$span->setTag('http.method', $request->getMethod());
Header Overrides: Modify tracing headers before injection:
$middleware = new TracingMiddleware();
$middleware->setHeaderName('custom-trace-id', 'your-value');
Span Naming: Override default span names (e.g., for API endpoints):
$span->setOperationName('api.payment.process');
Integration with Other Bundles:
Combine with Sentry or Monolog to correlate traces with logs/errors:
$span->setTag('logger', 'monolog');
How can I help you explore Laravel packages today?