{"id":23260823,"url":"https://github.com/123inkt/symfony-trace-bundle","last_synced_at":"2026-01-11T11:50:19.277Z","repository":{"id":210005828,"uuid":"724330588","full_name":"123inkt/symfony-trace-bundle","owner":"123inkt","description":"Add request ID's to your Symfony application. ","archived":false,"fork":false,"pushed_at":"2024-03-15T07:19:11.000Z","size":98,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-15T17:14:24.240Z","etag":null,"topics":["console","logging","messenger","monolog","request-id","trace-id","traceability","twig"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/123inkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-27T21:30:44.000Z","updated_at":"2023-12-22T22:41:33.000Z","dependencies_parsed_at":"2023-12-21T00:09:50.150Z","dependency_job_id":"39e6f38a-88ab-41fc-b699-8c4ed5eadfdc","html_url":"https://github.com/123inkt/symfony-trace-bundle","commit_stats":null,"previous_names":["123inkt/symfony-request-id","123inkt/symfony-trace-bundle"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fsymfony-trace-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fsymfony-trace-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fsymfony-trace-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fsymfony-trace-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/123inkt","download_url":"https://codeload.github.com/123inkt/symfony-trace-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438183,"owners_count":18225873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","logging","messenger","monolog","request-id","trace-id","traceability","twig"],"created_at":"2024-12-19T13:18:59.350Z","updated_at":"2026-01-11T11:50:19.269Z","avatar_url":"https://github.com/123inkt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF)](https://php.net/)\n[![Minimum Symfony Version](https://img.shields.io/badge/symfony-%3E%3D%206.4-brightgreen)](https://symfony.com/doc/current/validation.html)\n![Run tests](https://github.com/123inkt/symfony-trace-bundle/actions/workflows/test.yml/badge.svg)\n\n# Symfony Trace Bundle\n\n*Based on [chrisguitarguy/RequestIdBundle](https://github.com/chrisguitarguy/RequestIdBundle)*\n\nThis adds trace ID's to your Symfony application. Why? It's a great way to add\nsome additional information to logs and to present to users. The trace id will \nbe available in:\n- Monolog log messages\n- Request -\u003e Response\n- Console command\n- Twig as extension\n- HttpClient requests (by default only enabled for tagged clients)\n- Messenger messages (by default enabled)\n- Sentry reports (by default disabled)\n\n## Installation\n\nUse [Composer](https://getcomposer.org/).\n```\ncomposer require digitalrevolution/symfony-trace-bundle\n```\n\nThen enable the bundle in your `/config/bundles.php`:\n\n```php\n# /config/bundles.php\n\u003c?php\n\nreturn [\n    ...\n    DR\\SymfonyTraceBundle\\SymfonyTraceBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Configuration\n\nBy default, the bundle will use the [W3C TraceContext](https://www.w3.org/TR/trace-context/) standard to receive and pass on the traceId.\u003cbr\u003e \nFor configuration details see: [TraceContext configuration](docs/configuration/tracecontext.md)\n\nIt's also possible to configure the bundle to setup custom request/response headers and custom ID generators.  \nRead more about the available configuration options on [TraceId configuration](docs/configuration/traceid.md) in the /docs pages.\n\n## How it Works\n\nWhen a request arrives, it is inspected for request header containing a traceId. If present,\nthe value in that header will be used throughout the rest of the bundle. This\nlets you use trace ID's from somewhere higher up in the stack (like in the web\nserver itself).\n\nIf no trace ID is found, one is generated by the `TraceIdGeneratorInterface`.\nIn tracecontext mode, the IDs are generated according to the TraceContext standard.\nThe default generator in traceId mode creates version 4 UUIDs.\n\nOn the way out, a response header can be set on the response as well using\nthe value(s) described above.\n\nThe headers are configurable. See the [configuration](#configuration) above.\nInternally a transaction ID is generator as well. This ID is used to identify a single request.\n\n## Monolog Integration\n\nThere's a monolog *Processor* that adds the trace ID and transaction ID to `extra` array on the record.\nThis can be turned off by setting `monolog.enabled` to `false` in the configuration.\n\nTo use the trace ID in your logs, include `%extra.trace_id%` in your formatter.\nTo use the transaction ID in your logs, include `%extra.transaction_id%` in your formatter.\nHere's a configuration example from this bundle's tests.\n\n```php\n# /config/services.php\n$services-\u003eset('trace_id_formatter', LineFormatter::class)\n    -\u003earg('$format', \"[%%datetime%%][%%extra.trace_id%%][%%extra.transaction_id%%] %%channel%%.%%level_name%%: %%message%% %%extra%%\\n\")\n    -\u003earg('$dateFormat', \"Y-m-d\\TH:i:s\");\n```\n```php\n# /config/packages/monolog.php\n$monolog-\u003ehandler('main')\n        -\u003etype('stream')\n        -\u003epath('%kernel.logs_dir%/error.%kernel.environment%.log')\n        -\u003elevel('debug')\n        -\u003eformatter('trace_id_formatter')        \n        -\u003echannels()-\u003eelements([\"!event\"]);\n```\n\n## Messenger Integration\n\nBy default, the full trace data of the dispatcher process, will be added to the `Envelope` of the message. On the consumer\nside the trace data will be applied to the running consumer process. Once the `Envelope` has been handled, the values \nwill be reset to the original values of the consumer process (if any).\n\n## Twig Integration\n\nBy default, this bundle will add a global `trace_id` and `transaction_id` function to your twig\nenvironment. To disable this set `twig.enabled` to `false` in the bundle\nconfiguration.\n\nHere's an example of a template.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eHello, World\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003e{{ trace_id() }}\u003c/h1\u003e\n        \u003ch2\u003e{{ transaction_id() }}\u003c/h2\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## HttpClient integration\n\nBy default this bundle will check for services tagged with the `http_client.trace_id` tag and decorate them with the TraceAwareHttpClient.\nWhen `tagDefaultClient` is enabled the default symfony http client will also be tagged and thus decorated.\nThis will add the trace header(s) to all outgoing requests for the tagged clients.\nIn traceId mode the header name can be changed with the `header` configuration option.\n\n## Sentry integration\n\nBy default sentry has its own trace id and transaction id which will be propagated through the Sentry SDK. However this traceId will be different\nthan the one generated by this bundle. To fully integrate with Sentry you have to set `$config-\u003esentry()-\u003eenabled(true)` for this bundle and\ndisable Sentry's own tracing by setting `$sentry-\u003etracing()-\u003eenabled(false);` in your Sentry configuration.\n\n**Example:**\n```php\n// config/packages/sentry.php\nreturn static function (SentryConfig $sentry): void {\n    $sentry-\u003etracing()-\u003eenabled(false);\n};\n\n// config/packages/symfony_trace_bundle.php\nreturn static function (SymfonyTraceConfig $config): void {\n    $config-\u003esentry()-\u003eenabled(true);\n};\n```\nThis will ensure that the traceId and transactionId generated by this bundle will be used in Sentry reports.\n\n## About us\n\nAt 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP \nand our several shops. Do you want to join us? [We are looking for developers](https://www.werkenbij123inkt.nl/zoek-op-afdeling/it).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F123inkt%2Fsymfony-trace-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F123inkt%2Fsymfony-trace-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F123inkt%2Fsymfony-trace-bundle/lists"}