Fixture configuration
How fixtures are referenced, validated and matched to a signal and receiver.
A test references its fixture with input:, relative to the test file:
tests:
- name: passwords are removed from logs
input: fixtures/login-log.json
expect:
- attribute: password
absent: trueFormat
A fixture is one OTLP/JSON export request. It must be a JSON object with exactly one of these top-level keys:
| Top-level key | Signal | Protobuf message |
|---|---|---|
resourceSpans | traces | ExportTraceServiceRequest |
resourceLogs | logs | ExportLogsServiceRequest |
resourceMetrics | metrics | ExportMetricsServiceRequest |
The signal is inferred from that key. If a test sets signal:, it must agree:
test declares `signal: logs` but the fixture contains tracesValidation
Before any Collector starts, each fixture is:
- parsed as JSON;
- checked for exactly one signal key. A fixture with several signals is rejected, because it isn't a single export request;
- decoded as the matching OTLP request, which catches wrong field types and malformed IDs;
- checked to contain at least one item (span, log record or data point).
A snake_case key gets a hint:
expected one of `resourceSpans`, `resourceMetrics` or `resourceLogs` at the top level, found ["resource_spans"] (OTLP/JSON uses lowerCamelCase field names, e.g. `resourceSpans`)Fixture problems are reported during planning, together with receiver and exporter problems, and exit with code 2.
Injection
The file's bytes are posted unchanged to the test's receiver as application/json. The Collector must answer
with HTTP 2xx and no partialSuccess rejection. Otherwise the test is an execution error (exit code 5).
Fixtures are posted without custom headers, so routing on request metadata can't be tested.
Organizing fixtures
- Reuse one fixture across several tests: the PII redaction example runs three
tests on
checkout-span.json. - Keep IDs and timestamps fixed, so runs are deterministic.
- Put a whole trace in one fixture when a processor works on traces.
tail_samplingdecides per trace.
See Span fixtures, Log fixtures and Metric fixtures for complete examples.