You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allows sampling based on a list of rule sets. The first matching rule set will decide the sampling result.
13
+
Provide a list of `RuleSet` instances and a fallback sampler to the `RuleBasedSampler` constructor. Each rule set
14
+
contains a list of rules and a delegate sampler to execute if the rule matches. The rules are evaluated in the order
15
+
they are defined. The first matching rule set will decide the sampling result.
16
+
17
+
If no rules match, then the fallback sampler is used.
14
18
15
19
```php
16
20
$sampler = new RuleBasedSampler(
@@ -27,12 +31,29 @@ $sampler = new RuleBasedSampler(
27
31
);
28
32
```
29
33
30
-
###Configuration
34
+
## Configuration
31
35
32
-
###### Example: drop spans for the /health endpoint
36
+
The RuleBased sampler can be configured through [Declarative Configuration](https://opentelemetry.io/docs/specs/otel/configuration/#declarative-configuration), using the
37
+
key `php_rule_based` under `tracer_provider.sampler.sampler`:
33
38
34
39
```yaml
35
-
contrib_rule_based:
40
+
file_format: "0.4"
41
+
42
+
tracer_provider:
43
+
sampler:
44
+
php_rule_based:
45
+
rule_sets:
46
+
# ...
47
+
fallback:
48
+
# ...
49
+
```
50
+
51
+
### Examples
52
+
53
+
Drop spans for the /health endpoint:
54
+
55
+
```yaml
56
+
php_rule_based:
36
57
rule_sets:
37
58
- rules:
38
59
- span_kind: { kind: SERVER }
@@ -42,21 +63,21 @@ contrib_rule_based:
42
63
fallback: # ...
43
64
```
44
65
45
-
###### Example: sample spans with at least one sampled link
66
+
Sample spans with at least one sampled link:
46
67
47
68
```yaml
48
-
contrib_rule_based:
69
+
php_rule_based:
49
70
rule_sets:
50
71
- rules: [ link: { sampled: true } ]
51
72
delegate:
52
73
always_on: {}
53
74
fallback: # ...
54
75
```
55
76
56
-
###### Example: modeling parentbased sampler as rulebased sampler
77
+
Modeling parent-based sampler as rule-based sampler:
0 commit comments