定制 open-telemetry/sampler-rule-based 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

open-telemetry/sampler-rule-based

Composer 安装命令:

composer require open-telemetry/sampler-rule-based

包简介

OpenTelemetry SDK rule-based sampler

README 文档

README

Allows sampling based on a list of rule sets.

Installation

composer require open-telemetry/sampler-rule-based

Usage

Provide a list of RuleSet instances and a fallback sampler to the RuleBasedSampler constructor. Each rule set contains a list of rules and a delegate sampler to execute if the rule matches. The rules are evaluated in the order they are defined. The first matching rule set will decide the sampling result.

If no rules match, then the fallback sampler is used.

$sampler = new RuleBasedSampler(
    [
        new RuleSet(
            [
                new SpanKindRule(Kind::Server),
                new AttributeRule('url.path', '~^/health$~'),
            ],
            new AlwaysOffSampler(),
        ),
    ],
    new AlwaysOnSampler(),
);

Configuration

The RuleBased sampler can be configured through Declarative Configuration, using the key php_rule_based under tracer_provider.sampler.sampler:

file_format: "0.4"

tracer_provider:
  sampler:
    php_rule_based:
      rule_sets:
        # ...
      fallback:
        # ...

Examples

Drop spans for the /health endpoint:

php_rule_based:
    rule_sets:
    -   rules:
        -   span_kind: { kind: SERVER }
        -   attribute: { key: url.path, pattern: ~^/health$~ }
        delegate:
            always_off: {}
    fallback: # ...

Sample spans with at least one sampled link:

php_rule_based:
    rule_sets:
    -   rules: [ link: { sampled: true } ]
        delegate:
            always_on: {}
    fallback: # ...

Modeling parent-based sampler as rule-based sampler:

php_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

统计信息

  • 总下载量: 4.9k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-09-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固