This guide takes you from a freshly installed bundle to your first live trace in under five minutes. You will set a handful of environment variables, run the built-in doctor command to confirm everything is wired correctly, and then make a request to see spans appear in your tracing backend. No custom code is required to get automatic instrumentation running.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tracewayapp/opentelemetry-symfony-bundle/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before starting, make sure you have the following in place:
- PHP >= 8.1 installed and available on the command line
- Symfony 6.4 LTS, 7.x, or 8.x project with Composer dependencies installed
- A running OTLP-compatible backend — Jaeger, Grafana Tempo, Honeycomb, Traceway, or a local OpenTelemetry Collector
Getting Started
Install the bundle
If you haven’t already, add the bundle to your project:Then install the OTLP exporter and an HTTP client to ship traces:Symfony Flex registers the bundle automatically. Without Flex, add it to
config/bundles.php:Set environment variables
Add the following variables to your
.env file (or .env.local to keep them out of version control):| Variable | Purpose |
|---|---|
OTEL_PHP_AUTOLOAD_ENABLED | Activates the OpenTelemetry SDK when Composer’s autoloader is loaded. Must be true. |
OTEL_SERVICE_NAME | Identifies your application in the tracing backend. Use a short, stable name. |
OTEL_TRACES_EXPORTER | The exporter to use. Set to otlp for any OpenTelemetry-compatible backend. |
OTEL_EXPORTER_OTLP_ENDPOINT | Base URL of your OTLP receiver. Port 4318 is standard for HTTP. |
OTEL_EXPORTER_OTLP_PROTOCOL | Wire format for OTLP export. Use http/json for the widest compatibility. |
Verify the wiring with traceway:doctor
Run the built-in diagnostic command to confirm that the SDK is configured correctly and your OTLP endpoint is reachable:A healthy output looks like this:You can also output results as JSON for CI pipeline consumption:
An HTTP
404 response from the OTLP endpoint connectivity check is expected and counts as reachable — it means the server responded, which is all the check needs to confirm. A real connection refused or DNS failure produces an error.Make a request and see your traces
Start your Symfony application and make any HTTP request — a page load, an API call, or even a console command:Open your tracing backend and look for a trace named after your service (
my-symfony-app). You should see spans for the HTTP request, any database queries, cache operations, and template renders — all automatically, without writing a single line of instrumentation code.What’s Traced Automatically
Once the bundle is installed and configured, the following components produce spans with no additional setup:- HTTP requests — every incoming request with route template, status code, and client IP
- Console commands — name, arguments, exit code, and any thrown exceptions
- Outgoing HttpClient calls — with W3C trace context propagation to downstream services
- Messenger messages — producer and consumer spans with async context propagation
- Doctrine DBAL queries — parameterised SQL, transactions, and database metadata
- Cache operations —
get(hit/miss),delete, andinvalidateTagsper pool - Twig renders — template name and nested includes
- Mailer sends — two-span split across
MailerInterface::sendand the transport layer - Scheduler jobs —
RecurringMessageexecution with trigger metadata - Monolog logs —
trace_idandspan_idinjected into every log record
Manual Instrumentation
For business-logic spans beyond automatic instrumentation, injectTracingInterface into any service:
$this->createStub(TracingInterface::class) — the stub invokes the callback directly so your business logic runs unmodified.
Next Steps
Configuration Reference
Explore all
open_telemetry configuration options — excluded paths, metrics, log export, SDK settings, and more.Metrics
Enable opt-in OTel metrics and create custom counters and histograms with
MeterRegistryInterface.