open-telemetry / sampler-rule-based
OpenTelemetry SDK 基于规则的采样器
0.0.1
2024-09-12 23:58 UTC
Requires
- php: ^8.1
- open-telemetry/api: dev-main as 1.1.0
- open-telemetry/sdk: dev-main as 1.1.0
- open-telemetry/sdk-configuration: dev-main as 0.99
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phan/phan: ^5.0
- phpstan/phpstan: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^10 || ^11
- psalm/plugin-phpunit: ^0.18.4
- symfony/config: ^5.4 || ^6.4 || ^7.0
- symfony/yaml: ^6 || ^7
- vimeo/psalm: ^4|^5
This package is auto-updated.
Last update: 2024-09-13 01:08:27 UTC
README
提供不属于官方规范的附加采样器。
安装
composer require open-telemetry/sampler-rule-based
RuleBasedSampler
允许基于规则集列表进行采样。第一个匹配的规则集将决定采样结果。
$sampler = new RuleBasedSampler( [ new RuleSet( [ new SpanKindRule(Kind::Server), new AttributeRule('url.path', '~^/health$~'), ], new AlwaysOffSampler(), ), ], new AlwaysOnSampler(), );
配置
示例:丢弃 /health 端点的跨度
contrib_rule_based: rule_sets: - rules: - span_kind: { kind: SERVER } - attribute: { key: url.path, pattern: ~^/health$~ } delegate: always_off: {} fallback: # ...
示例:采样至少有一个采样链接的跨度
contrib_rule_based: rule_sets: - rules: [ link: { sampled: true } ] delegate: always_on: {} fallback: # ...
示例:将基于父级的采样器建模为基于规则的采样器
rule_based: rule_sets: - rules: [ parent: { sampled: true, remote: true } ] delegate: # remote_parent_sampled - rules: [ parent: { sampled: false, remote: true } ] delegate: # remote_parent_not_sampled - rules: [ parent: { sampled: true, remote: false } ] delegate: # local_parent_sampled - rules: [ parent: { sampled: false, remote: false } ] delegate: # local_parent_not_sampled fallback: # root
AlwaysRecordingSampler
记录所有跨度,以便使用生成来自跨度的指标的跨度处理器。
$sampler = new AlwaysRecordingSampler( new ParentBasedSampler(new AlwaysOnSampler()), );
配置
always_recording: sampler: # ...