{"id":21424799,"url":"https://github.com/opentelemetry-php/contrib-sampler-rulebased","last_synced_at":"2026-02-26T20:07:00.787Z","repository":{"id":256865160,"uuid":"856660939","full_name":"opentelemetry-php/contrib-sampler-rulebased","owner":"opentelemetry-php","description":"[READONLY] OpenTelemetry rule-based sampler","archived":false,"fork":false,"pushed_at":"2025-06-11T23:59:44.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-13T04:36:04.163Z","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,"zenodo":null}},"created_at":"2024-09-13T01:04:53.000Z","updated_at":"2025-06-23T23:37:54.000Z","dependencies_parsed_at":"2024-09-13T13:56:32.229Z","dependency_job_id":"70f0ec24-7691-4ad3-a1a0-8547d683fd84","html_url":"https://github.com/opentelemetry-php/contrib-sampler-rulebased","commit_stats":null,"previous_names":["opentelemetry-php/contrib-sampler-rulebased"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/opentelemetry-php/contrib-sampler-rulebased","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-sampler-rulebased","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-sampler-rulebased/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-sampler-rulebased/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-sampler-rulebased/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentelemetry-php","download_url":"https://codeload.github.com/opentelemetry-php/contrib-sampler-rulebased/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentelemetry-php%2Fcontrib-sampler-rulebased/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29870610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T18:42:30.764Z","status":"ssl_error","status_checked_at":"2026-02-26T18:41:47.936Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-22T21:24:36.075Z","updated_at":"2026-02-26T20:07:00.770Z","avatar_url":"https://github.com/opentelemetry-php.png","language":"PHP","readme":"# RuleBasedSampler\n\nAllows sampling based on a list of rule sets.\n\n## Installation\n\n```shell\ncomposer require open-telemetry/sampler-rule-based\n```\n\n## Usage\n\nProvide a list of `RuleSet` instances and a fallback sampler to the `RuleBasedSampler` constructor. Each rule set\ncontains a list of rules and a delegate sampler to execute if the rule matches. The rules are evaluated in the order\nthey are defined. The first matching rule set will decide the sampling result.\n\nIf no rules match, then the fallback sampler is used.\n\n```php\n$sampler = new RuleBasedSampler(\n    [\n        new RuleSet(\n            [\n                new SpanKindRule(Kind::Server),\n                new AttributeRule('url.path', '~^/health$~'),\n            ],\n            new AlwaysOffSampler(),\n        ),\n    ],\n    new AlwaysOnSampler(),\n);\n```\n\n## Configuration\n\nThe RuleBased sampler can be configured through [Declarative Configuration](https://opentelemetry.io/docs/specs/otel/configuration/#declarative-configuration), using the\nkey `php_rule_based` under `tracer_provider.sampler.sampler`:\n\n```yaml\nfile_format: \"0.4\"\n\ntracer_provider:\n  sampler:\n    php_rule_based:\n      rule_sets:\n        # ...\n      fallback:\n        # ...\n```\n\n### Examples\n\nDrop spans for the /health endpoint:\n\n```yaml\nphp_rule_based:\n    rule_sets:\n    -   rules:\n        -   span_kind: { kind: SERVER }\n        -   attribute: { key: url.path, pattern: ~^/health$~ }\n        delegate:\n            always_off: {}\n    fallback: # ...\n```\n\nSample spans with at least one sampled link:\n\n```yaml\nphp_rule_based:\n    rule_sets:\n    -   rules: [ link: { sampled: true } ]\n        delegate:\n            always_on: {}\n    fallback: # ...\n```\n\nModeling parent-based sampler as rule-based sampler:\n\n```yaml\nphp_rule_based:\n    rule_sets:\n    -   rules: [ parent: { sampled: true, remote: true } ]\n        delegate: # remote_parent_sampled\n    -   rules: [ parent: { sampled: false, remote: true } ]\n        delegate: # remote_parent_not_sampled\n    -   rules: [ parent: { sampled: true, remote: false } ]\n        delegate: # local_parent_sampled\n    -   rules: [ parent: { sampled: false, remote: false } ]\n        delegate: # local_parent_not_sampled\n    fallback: # root\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentelemetry-php%2Fcontrib-sampler-rulebased","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentelemetry-php%2Fcontrib-sampler-rulebased","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentelemetry-php%2Fcontrib-sampler-rulebased/lists"}