instrumentation-bundle
instrumentation-bundle copied to clipboard
Instrumentation for Symfony
Instrumentation for Symfony
Using the official OpenTelemetry SDK
Features
Traces
- Minimal auto-instrumentation for requests, console commands, consumers and doctrine
- Trace context propagation from incoming requests to consumers, outgoing http calls and databases (using
sqlcommenter
) - Configurable blacklisting of requests by path to avoid useless traces
Metrics
- Minimal auto-instrumentation for common request, consumer and message metrics (see list of provided default metrics).
Logs
- Adds trace context to logs for correlation, with customizable keys.
Installation and configuration
composer require worldia/instrumentation-bundle <your-exporter>
You will aso need to install an exporter implementation.
Add to ```bundles.php```:
```php
return [
// Other bundles
Instrumentation\InstrumentationBundle::class => ['all' => true],
];
Minimal configuration
See the complete configuration reference here or run bin/console config:dump-reference instrumentation
.
// docker-compose.yaml
services:
php:
image: php:8.1
environment:
- OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4318
jaeger:
image: jaegertracing/jaeger
// instrumentation.yaml
instrumentation: ~
Usage
-
Tracing
- Simple tracing example
- Simple tracing example using the static API
- Add Urls to your traces in error messages
- Use upstream request id as trace id
- Customize operation (span) name for a message
- Link strategy for a message
- Propagating trace/baggage context in HTTP requests
- Add request / response bodies as span attributes for HTTP requests
-
Logging
- Customizing trace context log keys