{"id":15282716,"url":"https://github.com/opentelemetry-php/contrib-propagator-server-timing","last_synced_at":"2025-05-07T03:21:50.210Z","repository":{"id":209359233,"uuid":"723531505","full_name":"opentelemetry-php/contrib-propagator-server-timing","owner":"opentelemetry-php","description":"[READONLY] TraceResponse propagator contrib module","archived":false,"fork":false,"pushed_at":"2025-04-07T22:56:50.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T23:30:13.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opentelemetry-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-26T00:37:00.000Z","updated_at":"2025-04-07T22:56:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"3643d05a-54b7-4348-8a94-986a028695e6","html_url":"https://github.com/opentelemetry-php/contrib-propagator-server-timing","commit_stats":null,"previous_names":["opentelemetry-php/contrib-propagator-server-timing"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-propagator-server-timing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-propagator-server-timing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-propagator-server-timing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-propagator-server-timing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentelemetry-php","download_url":"https://codeload.github.com/opentelemetry-php/contrib-propagator-server-timing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804790,"owners_count":21806878,"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":[],"created_at":"2024-09-30T14:37:02.851Z","updated_at":"2025-05-07T03:21:50.189Z","avatar_url":"https://github.com/opentelemetry-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Releases](https://img.shields.io/badge/releases-purple)](https://github.com/opentelemetry-php/contrib-propagator-server-timing/releases)\n[![Issues](https://img.shields.io/badge/issues-pink)](https://github.com/open-telemetry/opentelemetry-php/issues)\n[![Source](https://img.shields.io/badge/source-contrib-green)](https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/src/Propagation/ServerTiming)\n[![Mirror](https://img.shields.io/badge/mirror-opentelemetry--php--contrib-blue)](https://github.com/opentelemetry-php/contrib-propagator-server-timing)\n[![Latest Version](http://poser.pugx.org/open-telemetry/opentelemetry-propagation-traceresponse/v/unstable)](https://packagist.org/packages/open-telemetry/opentelemetry-propagation-server-timing/)\n[![Stable](http://poser.pugx.org/open-telemetry/opentelemetry-propagation-traceresponse/v/stable)](https://packagist.org/packages/open-telemetry/opentelemetry-propagation-server-timing/)\n\nThis is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.\n\n# OpenTelemetry ServerTiming Propagator\n\nThis package provides a [Server-Timing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Server-Timing)\npropagator to inject the current span context into Response datastructures.\n\nThe main goal is to allow client-side technology (Real User Monitoring, HTTP Clients) to record\nthe server side context in order to allow referencing it.\n\nServer-Timing response headers are especially useful for this approach, as they are accessible on the client side,\neven for the initial page load.\n\n## Requirements\n\n* OpenTelemetry SDK and exporters (required to actually export traces)\n\nOptional:\n* OpenTelemetry extension (Some instrumentations can automatically use the `TraceResponsePropagator`)\n\n## Usage\n\nAssuming there is an active `SpanContext`, you can inject it into your response as follows:\n\n```php\n// your framework probably provides a datastructure to model HTTP responses\n// and allows you to hook into the end of a request / listen to a matching event.\n$response = new Response();\n\n// get the current scope, bail out if none\n$scope = Context::storage()-\u003escope();\nif (null === $scope) {\n    return;\n}\n\n// create a PropagationSetterInterface that knows how to inject response headers\n$propagationSetter = new class implements OpenTelemetry\\Context\\Propagation\\PropagationSetterInterface {\n    public function set(\u0026$carrier, string $key, string $value) : void {\n        $carrier-\u003eheaders-\u003eset($key, $value);\n    }\n};\n$propagator = new ServerTimingPropagator();\n$propagator-\u003einject($response, $propagationSetter, $scope-\u003econtext());\n```\n\n## Installation via composer\n\n```bash\n$ composer require open-telemetry/opentelemetry-propagation-server-timing\n```\n\n## Installing dependencies and executing tests\n\nFrom TraceResponse subdirectory:\n\n```bash\n$ composer install\n$ ./vendor/bin/phpunit tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentelemetry-php%2Fcontrib-propagator-server-timing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentelemetry-php%2Fcontrib-propagator-server-timing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentelemetry-php%2Fcontrib-propagator-server-timing/lists"}