Skip to content
Novus Examples
yaml1.9 KB

OpenTelemetry Collector — Tail-Sampling Policies (yaml)

Six tail-sampling policies including an inverted regex match that drops health checks and a composite policy with its own rate limit and ordered sub-policies. Policies are OR-ed and one match keeps the entire trace, which is the semantic most people get backwards.

Preview — first 50 linesyaml
# Tail-sampling policies for the shop namespace. Tail sampling must run in a
# single collector instance that sees every span of a trace, which is why this
# pipeline has no other processors between the receiver and the sampler.
processors:
  tail_sampling:
    decision_wait: 30s
    num_traces: 100000
    expected_new_traces_per_sec: 2000
    policies:
      - name: keep-all-errors
        type: status_code
        status_code:
          status_codes: [ERROR]

      - name: keep-slow-checkouts
        type: latency
        latency:
          threshold_ms: 1000

      - name: keep-flagged-customers
        type: string_attribute
        string_attribute:
          key: enduser.id
          values: [cust-000418, cust-000502]
          enabled_regex_matching: false

      - name: drop-health-checks
        type: string_attribute
        string_attribute:
          key: url.path
          values: ['^/healthz$', '^/readyz$']
          enabled_regex_matching: true
          invert_match: true

      - name: probabilistic-remainder
        type: probabilistic
        probabilistic:
          sampling_percentage: 5

      - name: composite-rate-limited
        type: composite
        composite:
          max_total_spans_per_second: 500
          policy_order: [keep-all-errors, keep-slow-checkouts, probabilistic-remainder]
          composite_sub_policy:
            - name: keep-all-errors
              type: status_code
              status_code:
                status_codes: [ERROR]
            - name: keep-slow-checkouts
65 lines total — download for the full file.

Specifications

Policies
6
Composite Sub Policies
3
Decision Wait
30s
Has Inverted Match
true
Latency Threshold Ms
1000
Probabilistic Percentage
5
Note
policies are OR-ed; one match keeps the whole trace

Testing contract

Expected to pass
Scenario
Evaluate the trace fixtures in this category against these policies.
Expected result
The error-trace fixture is kept by keep-all-errors and the 2-second root also matches keep-slow-checkouts, while a healthz-only trace is dropped by the inverted match before the probabilistic policy is reached.

What is a .yaml file?

YAML (YAML Ain't Markup Language) is a human-readable data-serialization format using indentation, key-value pairs, and lists, and is a superset of JSON. It supports comments, anchors, and multiple documents per file, favoring readability for configuration. Its indentation sensitivity makes it error-prone to hand-edit.

How to use this file

Use an example YAML file to test config parsers, indentation and anchor handling, multi-document streams, and safe-loading to avoid arbitrary object construction.

How to use this file for testing

“OpenTelemetry Collector — Tail-Sampling Policies (yaml)” is a deterministic Novus Examples fixture for Observability, Config parsing, Config testing. Structured and plain-text telemetry with known timestamps, levels, request identifiers, and error states for testing log ingestion, correlation, dashboards, and alert pipelines.

Documented properties for this file: YAML · 1,909 bytes. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Telemetry fixtures use fixed trace IDs, span IDs, and timestamps so ingestion is reproducible run to run. Point your collector, parser, or query layer at the file and assert the documented span tree, metric families, or severity mix; service and host names are invented.

Code examples

import yaml  # pip install pyyaml

with open("otel-collector-tail-sampling.yaml") as f:
    data = yaml.safe_load(f)
print(data)

Generated by generation/observability.py. Free for any use, no attribution required — license.