Skip to main content

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.

All configuration is optional — the bundle works out of the box with zero YAML. When you need to customise behaviour, create config/packages/open_telemetry.yaml and add only the keys you want to change; every option shown below is already applied as a default.

Annotated full configuration

The block below lists every accepted key with its default value and an inline comment explaining what it does.
open_telemetry:
    traces:
        enabled: true
        tracer_name: 'opentelemetry-symfony'

        # URL path prefixes excluded from HTTP request tracing
        excluded_paths: []
        record_client_ip: true             # disable for GDPR compliance
        error_status_threshold: 500        # range 400–599; responses >= this are marked ERROR

        console:
            enabled: true
            excluded_commands: [messenger:consume, messenger:consume-messages]

        http_client:
            enabled: true
            excluded_hosts: []             # OTLP endpoint host is auto-excluded

        messenger:
            enabled: true
            root_spans: false              # true = standalone root span per consumed message

        scheduler:
            enabled: true                  # suppresses duplicate Messenger spans for scheduled tasks

        mailer:
            enabled: true
            record_subject: false          # subjects can contain personal data (PII)

        doctrine:
            enabled: true
            record_statements: true        # false = hide SQL text from spans

        cache:
            enabled: true
            excluded_pools: []             # service IDs to skip, e.g. cache.system

        propagator: w3c                    # w3c | xray | w3c+xray
        id_generator: default              # default | xray

        twig:
            enabled: true
            excluded_templates: []

    metrics:
        enabled: false                     # master switch; must be true for any subsystem metric
        meter_name: 'opentelemetry-symfony'

        messenger:
            enabled: false
            excluded_queues: []            # receiver names to skip

        doctrine:
            enabled: false

        http_server:
            enabled: false
            excluded_paths: []             # same prefix-match rules as traces.excluded_paths

        http_client:
            enabled: false
            excluded_hosts: []             # OTLP endpoint is auto-excluded

        mailer:
            enabled: false

    logs:
        correlation:
            enabled: true                  # inject trace_id / span_id into Monolog records

        export:
            enabled: false                 # requires symfony/monolog-bundle
            level: debug                   # minimum Monolog level to export
            capture_code_attributes: false # resolve file/line via debug_backtrace (small cost)
            unprefixed_attributes: true    # flat context/extra attributes (matches Java/.NET/JS/Python)

    sdk:
        enabled: false                     # implicitly true when any other sdk.* key is set
        autoload_enabled: false            # set OTEL_PHP_AUTOLOAD_ENABLED before Dotenv runs
        use_putenv: false                  # also write via putenv() — not thread-safe
        resource_attributes: {}            # merged into OTEL_RESOURCE_ATTRIBUTES; bundle wins
        exporter_otlp_headers: {}          # merged into OTEL_EXPORTER_OTLP_HEADERS; bundle wins

traces section

The traces section controls HTTP request tracing and every built-in instrumentation plugin.
KeyTypeDefaultDescription
enabledbooltrueEnable HTTP request tracing via OpenTelemetrySubscriber. Each subsystem has its own toggle.
tracer_namestringopentelemetry-symfonyInstrumentation library name reported to the OTel backend.
excluded_pathsstring[][]URL path prefixes to exclude from tracing. Paths without a leading / are normalised automatically.
record_client_ipbooltrueRecord the client IP address as a span attribute. Disable for GDPR compliance.
error_status_thresholdint500HTTP responses with a status code ≥ this value are marked as errors when no exception was thrown. Accepted range: 400–599.
propagatorstringw3cContext propagation format. See propagator below.
id_generatorstringdefaultTrace ID generation format. See id_generator below.

traces.console

KeyTypeDefaultDescription
enabledbooltrueCreate spans for Symfony Console commands.
excluded_commandsstring[][messenger:consume, messenger:consume-messages]Command names to skip. Long-lived consume commands are excluded by default because per-message tracing is handled by the Messenger middleware.

traces.http_client

KeyTypeDefaultDescription
enabledbooltrueInstrument outgoing HTTP requests with CLIENT spans and inject propagation headers.
excluded_hostsstring[][]Hostnames to skip. The host of OTEL_EXPORTER_OTLP_ENDPOINT is always excluded automatically to prevent infinite trace loops.

traces.messenger

KeyTypeDefaultDescription
enabledbooltrueInstrument Symfony Messenger dispatch and consume paths.
root_spansboolfalseWhen false (default), consumed-message spans are linked to the dispatching trace. When true, each consumed message starts a new root span — useful for task-oriented backends such as Traceway or Sentry that model work units as independent traces.

traces.scheduler

KeyTypeDefaultDescription
enabledbooltrueEmit a CONSUMER span per scheduled-task run with trigger metadata. Requires symfony/scheduler. When enabled, the Messenger middleware automatically skips envelopes carrying Symfony’s ScheduledStamp so the richer scheduler span owns the work unit without producing duplicate producer/consumer spans.

traces.mailer

KeyTypeDefaultDescription
enabledbooltrueAdd a PRODUCER span around MailerInterface::send and a CLIENT span around the transport send.
record_subjectboolfalseRecord the email subject as the email.subject attribute on the PRODUCER span. Disabled by default because subjects can contain personal data.

traces.doctrine

KeyTypeDefaultDescription
enabledbooltrueInstrument Doctrine DBAL with CLIENT spans for every database query. Supports doctrine/dbal ^3.6 and ^4.0.
record_statementsbooltrueAttach the SQL statement to spans. Prepared statements use ? placeholders; query()/exec() calls record raw SQL which may contain literal values. Disable if raw SQL might contain sensitive data.

traces.cache

KeyTypeDefaultDescription
enabledbooltrueInstrument Symfony Cache with INTERNAL spans for get/delete operations.
excluded_poolsstring[][]Cache pool service IDs to exclude from tracing, e.g. cache.system, cache.validator, cache.serializer.

traces.twig

KeyTypeDefaultDescription
enabledbooltrueInstrument Twig with INTERNAL spans for every template render.
excluded_templatesstring[][]Template name prefixes to skip, e.g. @WebProfiler/, @Debug/.

propagator

Controls which context propagation format is used for distributed tracing headers.
ValueDescription
w3c(default) Injects and extracts traceparent / tracestate headers (W3C Trace Context).
xrayInjects and extracts X-Amzn-Trace-Id (AWS X-Ray format). Requires open-telemetry/contrib-aws.
w3c+xrayInjects and extracts both header formats simultaneously. Requires open-telemetry/contrib-aws.

id_generator

Controls the format of generated trace IDs.
ValueDescription
defaultRandom hex trace IDs (standard OTel format).
xrayEpoch-prefixed X-Ray trace IDs. Requires open-telemetry/contrib-aws. When selected, the bundle builds and registers a TracerProvider using OTEL_* env vars plus the X-Ray ID generator.
Using propagator: xray, propagator: w3c+xray, or id_generator: xray requires the open-telemetry/contrib-aws package. The bundle throws a LogicException at container compile time if that package is absent.

metrics section

The metrics section is off by default. The top-level metrics.enabled: true flag is the master switch that registers the MeterRegistry service for manual instrumentation; every subsystem listed below also requires it to be true.
Enabling any subsystem metric (e.g. metrics.messenger.enabled: true) while metrics.enabled is false is a configuration error — the bundle will throw an InvalidConfigurationException at container compile time.
KeyTypeDefaultDescription
enabledboolfalseMaster switch. Registers MeterRegistry and enables the metrics pipeline.
meter_namestringopentelemetry-symfonyInstrumentation library name reported with all emitted metrics. Shared across built-in metric subscribers.

metrics.messenger

KeyTypeDefaultDescription
enabledboolfalseEmit messaging.process.duration (histogram) and messaging.client.consumed.messages (counter) on the consume path. Requires symfony/messenger.
excluded_queuesstring[][]Receiver names to skip when emitting messenger metrics.

metrics.doctrine

KeyTypeDefaultDescription
enabledboolfalseEmit db.client.operation.duration (histogram) for every DBAL query, exec, prepared statement execution, and transaction control. Requires doctrine/dbal.

metrics.http_server

KeyTypeDefaultDescription
enabledboolfalseEmit http.server.request.duration (histogram), http.server.active_requests (up/down counter), http.server.request.body.size, and http.server.response.body.size (histograms).
excluded_pathsstring[][]URL path prefixes to skip, using the same prefix-match rules as traces.excluded_paths.

metrics.http_client

KeyTypeDefaultDescription
enabledboolfalseEmit http.client.request.duration, http.client.request.body.size, and http.client.response.body.size (histograms) on outgoing requests. Requires symfony/http-client.
excluded_hostsstring[][]Hostnames to skip. The OTLP endpoint host is auto-excluded.

metrics.mailer

KeyTypeDefaultDescription
enabledboolfalseEmit messaging.client.operation.duration (histogram) and messaging.client.sent.messages (counter) on outbound transport sends. Requires symfony/mailer.

logs section

The logs section controls two independent features: trace-correlation injection into Monolog records, and native OTel log export.

logs.correlation

KeyTypeDefaultDescription
enabledbooltrueInject trace_id and span_id into every Monolog log record via a Monolog processor. Requires monolog/monolog.

logs.export

Log export requires both a configured OTel LoggerProvider (e.g. via OTEL_LOGS_EXPORTER) and symfony/monolog-bundle. The bundle throws a LogicException at container compile time if monolog-bundle is absent while this feature is enabled.
KeyTypeDefaultDescription
enabledboolfalseExport Monolog log records via the OTel Logs API.
levelstringdebugMinimum Monolog level to export. Accepted values: debug, info, notice, warning, error, critical, alert, emergency.
capture_code_attributesboolfalseResolve code.file.path, code.line.number, and code.function.name via debug_backtrace() when Monolog’s IntrospectionProcessor is not installed. Has a small per-log performance cost; prefer installing IntrospectionProcessor instead.
unprefixed_attributesbooltrueEmit Monolog context and extra fields as flat OTel attributes instead of namespacing them under monolog.context.* / monolog.extra.*. The flat shape matches the cross-ecosystem convention used by Java, Python, .NET, and JavaScript OTel libraries.

sdk section

The sdk section lets you set OTel SDK environment variables through Symfony’s configuration system, giving you access to DotEnv, container parameters, and Symfony Secrets. See the SDK Setup guide for a full walkthrough.
KeyTypeDefaultDescription
enabledboolfalseImplicitly true when any other sdk.* key is set. Set explicitly to false to suppress the section even if keys are present.
autoload_enabledboolfalseSet OTEL_PHP_AUTOLOAD_ENABLED=true at bundle boot time and re-run the SDK autoloader. Solves the Symfony DotEnv timing problem.
use_putenvboolfalseAlso write env variables via putenv(). Not thread-safe; off by default.
resource_attributesmap{}Key-value pairs merged into OTEL_RESOURCE_ATTRIBUTES. Bundle-set values win over existing ones. Supports Symfony parameter syntax.
exporter_otlp_headersmap{}Key-value pairs merged into OTEL_EXPORTER_OTLP_HEADERS. Bundle-set values win over existing ones. Supports Symfony Secrets.

Build docs developers (and LLMs) love