Repository navigation
Exporting to OpenTelemetry
The Kronikol.Extensions.Otlp package also works in the outbound direction: it exports Kronikol's captured interactions as OpenTelemetry spans over OTLP/HTTP, so the traffic only Kronikol can see — proxy-tap and TCP-tap hops from services that emit no telemetry, handler-captured calls with exact test attribution — appears in Tempo, Jaeger or any collector next to the application's real traces. It is the outbound twin of the same package's receiver-tee (Integration Otlp Extension).
Three layers, each useful alone:
| Layer | Type / verb | When |
|---|---|---|
| Batch push | OtlpExporter |
At the end of a run, from the in-process store or any list of logs — the primary mode; test suites are batch-shaped |
| Streaming sink | OtlpExportSink : IRequestResponseSink |
Live tap topologies — compose onto a ProxyTap/TcpTap/OtlpTap Sink
|
| CLI | kronikol export |
Post-hoc, from NDJSON capture files, in any language's pipeline |
Looking for CTRF? It is a different verb.
kronikol exportpushes live spans to a collector;kronikol ctrfconverts a finishedTestRunReport.jsoninto a Common Test Report Format document for CI tooling. See Querying Reports.
Under all three sit two pure, public pieces: OtlpSpanMapper (MapAll / Map / ShouldSkip) turns captured pairs into OtlpExportSpans (a whole capture maps to an OtlpExportBatch: the spans plus the skip and orphan counts), and OtlpJsonEncoder.Encode turns spans into the OTLP/JSON document (ScopeName / ScopeVersion are the scope every exported span carries). Both are usable on their own, offline mapping and golden tests included.
One request/response pair becomes one span: the request supplies the start time and request attributes, the response the end time and status.
| Span field / attribute | Source |
|---|---|
resource service.name
|
CallerName (one resourceSpans entry per caller); on a delivery logged as the broker's arrow into the consumer, the consumer, ServiceName
|
| scope |
Kronikol + the assembly version |
span name
|
the Kronikol method label (GET, Find ← Trial); CALL when the record carries no method |
kind |
By OpenTelemetry's tables since 5.28.0: CLIENT, CONSUMER for a delivery and PRODUCER for Kafka's produce. See Span kinds
|
url.full |
Uri |
http.request.method |
Method, when it is an HTTP verb on an http or https address |
http.response.status_code |
the numeric StatusCode; span status ERROR when ≥ 400 (the client-span semconv rule), when the status is the string form of a failure (Error, Failed, Timeout…), or when it is a call that threw, the exception's type behind a bang (!HttpRequestException; for Kafka, 4.16.2+, Confluent's error code, !Local_MsgTimedOut), whose status message is then the call's error (4.3.0+; before, such a span was exported UNSET with no message); from 5.34.3 a failure's message is its error whatever its status, a SQL Error among them, and an answer with an error is exported ERROR though its status is a word the list does not name (#232) |
db.system.name |
the reverse of the receiver's category mapping (the full list is below the table); omitted for non-database calls |
messaging.system |
what the address's scheme names, on a span on a broker's address: OpenTelemetry's value where it has one (aws_sqs, gcp_pubsub, aws.sns), else the scheme (kafka, servicebus, eventhubs, storagequeue, masstransit, eventbridge). Since 5.28.0 |
messaging.operation.name |
the label's first word where it names an operation (Publish, SendMessage, Complete), or two where the operation has two (ConsumeFault, SendOffsets), else the operation's type. Since 5.28.0 |
messaging.operation.type |
send, receive or process, where the record says which. A settlement carries none, as Kronikol does not separate it from management. Since 5.28.0 |
messaging.destination.name |
what the address names: the queue or the topic, or the message type where MassTransit's Summarised writes that. Since 5.28.0 |
peer.service |
ServiceName; on a delivery logged as the broker's arrow into the consumer, the broker, CallerName
|
kronikol.test.id / kronikol.test.name
|
TestId / TestName
|
kronikol.test.result |
the test's verdict (Passed, Failed, Skipped, Bypassed, SkippedAfterFailure), only when TestResult can answer for the test — see below
|
kronikol.phase |
Phase, when not Unknown
|
kronikol.dependency.category |
DependencyCategory, when set |
kronikol.captured.by |
CapturedBy, when set |
kronikol.request.body / kronikol.response.body
|
the bodies, only with IncludeBodies = true (the default is false), capped at BodyAttributeCapBytes (default 8 KiB; despite the name the cap counts characters, and a capped body ends with an …truncated (N chars total) marker) |
| headers | not exported (size + secret risk outweigh the value; an allow-list option can be added on demand) |
The kronikol.* attribute names are the same vocabulary the taps' own Activities already emit, so everything Kronikol puts on a span reads consistently — with one exception: kronikol.test.result has no counterpart on a tap's Activity, because a tap sees a call in flight and no call knows how its test ended.
kronikol.test.result is the only attribute that does not come from the captured record, and it cannot: every field on a captured call is written at capture time, while the result exists only once the framework adapter has assembled the run. Nothing a tracker holds could supply it.
The join is free, though — a record's TestId is its Scenario.Id — so a host that has the finished features wires it in one line:
var byId = features.SelectMany(f => f.Scenarios).ToDictionary(s => s.Id);
options.TestResult = id => byId.TryGetValue(id, out var scenario) ? scenario.Result.ToString() : null;Return null — the default for every id — and the attribute is left off. The values are ExecutionResult's own names, so a span attribute greps against the result field in TestRunReport.json without translation.
The streaming sink cannot carry it. OtlpExportSink POSTs on a flush interval while the test is still running, so there is no verdict to look up and the attribute is absent. That is deliberate: holding spans back until one existed would break the rule the sink is built on, that capture never blocks. A run that needs the verdict exports in batch at the end, or through the CLI with --tests.
Every database DependencyCategories value has a db.system.name, and each round-trips through the receiver's mapper: Redis → redis, MongoDB → mongodb, BigQuery → bigquery, PostgreSQL → postgresql, MySQL → mysql, SqlServer → microsoft.sql_server, SQLite → sqlite, Oracle → oracle.db, Elasticsearch → elasticsearch, CosmosDB → azure.cosmosdb, DynamoDB → aws.dynamodb, Spanner → gcp.spanner, Bigtable → bigtable, ClickHouse → clickhouse. The generic Database and SQL categories export as semconv other_sql. These are the registry's values at semantic conventions v1.44.0, since 5.28.0, where SqlServer, Oracle, CosmosDB, DynamoDB and Spanner exported mssql, oracle, cosmosdb, dynamodb and spanner. The registry names neither BigQuery nor Bigtable, so each keeps a name of its own.
Timestamps are never a reason to drop a record: a request with no timestamp borrows its response's; a pair with none at all is stamped with the export time and marked kronikol.times.synthetic = true.
Since 5.28.0 a span's kind follows OpenTelemetry's tables (semantic conventions v1.44.0, whose messaging page is at status Development). A record's own MetaType is unchanged: Event means the call moves a message, and this is the exporter's reading of it. In order, and the first that answers wins:
| A record that is | Span kind | Why |
|---|---|---|
Not an Event: a database query, an HTTP or gRPC call, settling a message, managing a topic or a queue |
CLIENT |
|
An Event on a database's category (a consumer's own, or a capture from before 5.27.14) |
CLIENT, with no messaging.*
|
A database span "SHOULD be CLIENT" |
An Event with an HTTP verb on an http or https address |
CLIENT |
An HTTP span "MUST be CLIENT" |
A delivery: TrackConsumeEvent, Kafka's and MassTransit's Consume, Pub/Sub's Receive, Event Hubs' Process
|
CONSUMER |
"Not initiated by the application code" |
A pull: Receive, Peek, ReceiveMessage, ReadEvents, Pub/Sub's Pull
|
CLIENT |
OTel's receive
|
| Kafka's produce | PRODUCER |
Its tracker injects traceparent, so the send's context is the message's creation context |
| Any other send | CLIENT |
OTel's send is PRODUCER only "if the context of the Send span is used as creation context", and no other tracker injects one |
Two Kafka routes inject nothing and still read PRODUCER: PropagateTraceContext off, and LogProduce by hand. Kafka's Consume reads as a delivery on every route, though with TraceMessageProcessing off, its default, TrackingKafkaConsumer.Consume is a poll the application makes, which OTel's table calls CLIENT and receive, as a record does not say which route wrote it. A dashboard that filtered on PRODUCER to find messages should filter on messaging.operation.type, which a span that moves a message carries.
What a backend draws (measured on hand-written OTLP payloads; Kronikol's spans are flat, with no parent and no links):
| Span | Collector 0.164.0 | Tempo 2.10.10 | Jaeger 2.22.0 |
|---|---|---|---|
Flat CLIENT, peer |
app to peer | app to peer | none |
Flat PRODUCER, with or without messaging.*
|
none | app to peer | none |
Flat CONSUMER, service the consumer |
none | broker to app | none |
| Parent and child |
messaging_system edge |
messaging_system edge |
producer to consumer |
So a send other than Kafka's draws an edge on the Collector's service graph, where a PRODUCER drew none, and on Tempo a delivery logged from the consumer (Pub/Sub's Receive, Event Hubs' ProcessEvent) now reads broker to app, where it read backwards. A Kafka produce and its consume in one POST draw both edges on Tempo, where they drew one. Tempo's service-graph generator discards a span that ended over 30 seconds before it arrives, so a later kronikol export, and an end-of-run batch for the spans older than that, draw no Tempo graph at any kind.
What a span keeps through NDJSON. A record read back from a file has no mark of how it was logged, so its label is all that says what it is: Consume, Process or Deliver is a delivery, and Receive, Pull, Poll or Peek a pull. A tracker's own record keeps its kind. A hand-logged TrackSendEvent("Process order", ...) reads CONSUMER through NDJSON, where it reads as a send in process.
- A captured W3C trace id always wins (
ActivityTraceId/ActivitySpanId): those spans land in the same distributed trace the system under test emitted, which is the whole point (invariant D4, below). Kafka entries record these from 4.17.0, so exported Kafka spans moved from the per-test trace into the app's trace. - When no Activity id was captured, the default
TraceIdStrategy.PerTestderives the trace id deterministically fromTestId(theInteractionRecord.ToGuidrecipe — a 32-hex browser-minted test id maps to itself), so one test renders as one trace in Tempo/Jaeger. Without this, capture paths that mint a fresh Guid per pair would flood the backend with thousands of single-span traces.TraceIdStrategy.PerPairkeeps the raw per-pair id for users who want it (--per-pair-traceson the CLI); a record whose per-pairTraceIdis empty still falls back to thePerTestderivation. - The span id is the captured
ActivitySpanId, else the first 16 hex ofRequestResponseId— deterministic, so re-exporting produces identical spans. It is the request record's: for a call a host makes over a socket, the span current when the handler saw the call, the host's request span, which the host's other calls under that request carry as well. The transport's own span for the call is on the response record (4.26.5). -
Exported traces are flat: no
parentSpanIdis emitted, so a trace is a fan of sibling spans. That is by design, not a bug — inferring parent/child from caller-name chains and interval nesting is a possible future enhancement.
-
Echo suppression (default). Records with
capturedBy: spanorwire + spancame from the backend's own telemetry via the OTLP tap — re-exporting them would duplicate spans the backend already stores. Opt in withIncludeSpanSourced/--include-span-sourcedif you know the tap was a leaf and the collector never saw them. -
Always skipped: diagram marker records (rendering control, not telemetry) and
TrackingIgnorerecords. - A record whose other half never shows up is still exported, as a zero-duration orphan span marked
kronikol.orphan = true. The batch path orphans every unmatched record at the end of the mapping; the streaming sink orphans a response with no buffered request straight away, and a buffered request oncePendingRequestTtl(default 30 s) lapses. A lone request that carries its own measureddurationMs(the one-record NDJSON contract) is a complete span, not an orphan.
using Kronikol.Extensions.Otlp;
using Kronikol.Tracking;
using var exporter = new OtlpExporter(new OtlpExportOptions
{
Endpoint = new Uri("http://localhost:4318/v1/traces"),
Headers = { ["authorization"] = $"Bearer {token}" }, // the tap's ExpectedHeaders, in reverse
Gzip = true,
});
var result = await exporter.ExportAsync(RequestResponseLogger.RequestAndResponseLogs);
// result.SpansExported / SpansFailed / TraceCount / SkippedRecords / OrphanSpans / BatchesSent / BatchesFailedBatches are paged by BatchMaxSpans (default 512). A failed batch gets one immediate re-attempt, then is counted and logged — never thrown, and no retry loop that would hold a test process open; result.Success == false tells you the collector was down.
OtlpExportOptions.Log (an Action<string>) is where the batch path says why a batch failed (the status code or exception, with the attempt number); the CLI wires it to stderr. Whatever it throws is ignored (4.22.2): before, a throw from a refused batch stopped the streaming sink's worker, so nothing after it was exported and every flush waited for ever. Each POST rides a standalone HttpClient with a 30 s timeout. Constructing an OtlpExporter (or an OtlpExportSink) calls OtlpExportOptions.Validate() and throws when the options cannot run an exporter: the endpoint must be an absolute http/https URI and every numeric knob positive. Spans you have already mapped yourself (via OtlpSpanMapper) go through OtlpExporter.ExportSpansAsync, the same paging and retry without the mapping step.
Redaction note: this path is already redacted — RequestResponseLogger.Redaction ran when each entry was logged (see Capture-Time Redaction).
For live tap topologies, OtlpExportSink streams captures out as they happen. Compose it with the tap's normal sink:
var otlp = new OtlpExportSink(new OtlpExportOptions
{
Endpoint = new Uri("http://localhost:4318/v1/traces"),
Name = "otlp-export", // the default; names the sink in diagnostics
});
proxyTapOptions.Sink = new CompositeRequestResponseSink(
new NdjsonInteractionWriter(".logs/taps/web.ndjson"), // for kronikol ingest
otlp); // and live to the collector
// ... run the tests ...
await otlp.DisposeAsync(); // drains and flushes, orphaning requests that never got a responseThe same works on TcpTapOptions.Sink and OtlpTapOptions.Sink (mind the echo: spans an OtlpTap captured are suppressed by default, see above). The taps redact via their own hooks (SecretDenylist, Key/Value/DocumentRedaction) before the sink, so what streams out is what they would have stored.
The sink obeys D3. Log() is a TryWrite into a bounded channel (QueueCapacity, default 4096) — it never blocks and never throws. A background worker pairs, batches (BatchMaxSpans / FlushInterval, default 2 s) and POSTs. Drops and delivery failures are counted on public counters (EntriesDropped, RecordsSkipped, SpansExported, SpansFailed, BatchesFailed, OrphanSpans) and surfaced as DiagnosticKind.CaptureDegraded entries from Diagnostics() — hand them to IngestRequest.HostDiagnostics (or --diagnostic) so a degraded export is a line in the report, not only in a log. FlushAsync(timeout) gives a deterministic flush point (the timeout is optional; on timeout or after disposal it returns quietly, best-effort like everything else on this path); DisposeAsync() waits at most ShutdownTimeout (default 5 s) before cancelling an in-flight POST, so a hung collector cannot hold the process open.
kronikol export <captures.ndjson>... --otlp <endpoint> [--header k=v]...
[--tests tests.ndjson]
[--include-bodies] [--body-cap N] [--include-span-sourced]
[--per-pair-traces] [--no-redact] [--redact-header h]...
[--gzip] [--dry-run [--out file.json]]
Reads the same NDJSON capture files kronikol ingest does and POSTs them as spans. Inputs may be files, directories (searched recursively for *.ndjson / *.jsonl) or glob patterns; malformed lines are skipped and reported on stderr (the count plus the first few file:line references), and batch-failure reasons land on stderr too (the CLI wires OtlpExportOptions.Log there). --dry-run writes the encoded OTLP/JSON instead of POSTing (to --out, else stdout) — testable without a listener, and a handy debug view of exactly what would leave; it needs no --otlp, while --out is only valid with --dry-run (a real export POSTs to the endpoint). -h / --help prints the full usage. Counts are printed (spans / traces / skipped / orphans); exit codes follow kronikol ingest (0 success, 1 runtime failure, 2 usage).
--tests <file> is how the CLI learns each test's verdict: it reads the run's companion tests NDJSON — the same file kronikol ingest --tests takes — and gives every span of a test the kronikol.test.result attribute from that test's end event. Without it no span claims a verdict, because the interaction capture does not contain one. Status words are mapped through the same table the ingest uses, so a span attribute and the report the same files would produce never disagree; a word the table does not know maps to Failed, and the unrecognised words are named on stderr so a producer's typo does not paint spans red in silence. A tests file that sits inside an input directory is not also read as an interaction capture. A missing one exits 1.
Redaction is per-path, and this is the path that needs it: batch export from the in-process store was redacted at capture, tap-fed sinks were redacted by the taps — but NDJSON files have had nothing run over them (RequestResponseLogger.Redaction applies only on ingest-replay). kronikol export therefore applies CaptureRedaction itself, default on, with --no-redact / --redact-header mirroring kronikol ingest exactly.
The exporter is a standalone HttpClient POSTing OTLP/JSON to a URL. It never touches the system under test's TracerProviderBuilder, never registers processors, never re-emits Activity objects and never flips Activity.Recorded. Exporting Kronikol's captures cannot change what the observed system emits, samples or reports — it only adds spans, under Kronikol's own scope name, to whatever collector you point it at.
Protocol note: the export encoding is OTLP/JSON (application/json on /v1/traces), which collectors accept alongside protobuf. A hand-rolled protobuf encoder is a possible follow-on if a JSON-rejecting endpoint ever shows up in practice.
Two invariants this feature (and the taps) cite by name:
-
D3 — capture never blocks or degrades the observed system. Every Kronikol capture path hands work to a bounded queue and returns; when the queue is full the newest item is dropped and counted, never awaited. A slow report pipeline, a hung collector or a blocked sink can never slow the system under test. The counters surface as
CaptureDegradedreport diagnostics. -
D4 — real W3C ids are preserved end-to-end. When a genuine trace/span id was observed (an incoming
traceparent, a captured Activity, an OTLP span), Kronikol carries it through capture, storage, reports (activityTraceId/activitySpanIdinTestRunReport.json) and now export — so Kronikol's view and the backend's view of the same call always cross-link.
- Integration Otlp Extension — the inbound direction: the OTLP receiver-tee.
- Integration ProxyTap Extension / Integration TcpTap Extension — the taps whose captures this exports.
- Ingesting External Captures — the NDJSON format the CLI reads.
- Capture-Time Redaction — what has been redacted where.
Home · 🔍 Search this wiki Full-text search across every page. The “Pages” list above matches page and heading names, not page content.
Getting Started
- Quick Start (xUnit)
- Project Templates
- AI Integration Prompt
- Framework Integration Guides
- Migrating to v5
- Migrating to v4
Common Tasks
Integration Guides
- Integration xUnit3
- Integration xUnit2
- Integration NUnit
- Integration MSTest
- Integration TUnit
- Integration BDDfy xUnit3
- Integration LightBDD xUnit2
- Integration LightBDD xUnit3
- Integration LightBDD TUnit
- Integration ReqNRoll xUnit2
- Integration ReqNRoll xUnit3
- Integration ReqNRoll TUnit
- Integration Playwright
Uninstrumentable / polyglot backends
- Integration ProxyTap Extension
- Integration TcpTap Extension
- Integration Otlp Extension
- Exporting to OpenTelemetry
- Ingesting External Captures
- Ingesting from Jest
- Integration Cucumber Messages
- Capture-Time Redaction
Extensions
- Integration AtlasDataApi Extension
- Integration BigQuery Extension
- Integration Bigtable Extension
- Integration BlobStorage Extension
- Integration ClickHouse Extension
- Integration CloudStorage Extension
- Integration CosmosDB Extension
- Integration Dapper Extension
- Integration DynamoDB Extension
- Integration EF Core Relational Extension
- Integration Elasticsearch Extension
- Integration EventBridge Extension
- Integration EventHubs Extension
- Integration Grpc Extension
- Integration Kafka Extension
- Integration MassTransit Extension
- Integration MongoDB Extension
- Integration MySqlConnector Extension
- Integration Npgsql Extension
- Integration Oracle Extension
- Integration PubSub Extension
- Integration Redis Extension
- Integration S3 Extension
- Integration ServiceBus Extension
- Integration SNS Extension
- Integration Spanner Extension
- Integration SqlClient Extension
- Integration Sqlite Extension
- Integration SQS Extension
- Integration StorageQueues Extension
- Integration OpenTelemetry Extension
- Integration DispatchProxy Extension
- Integration MediatR Extension
- Integration PlantUML IKVM
Configuration
- Tracking Dependencies
- Tracking Custom Dependencies
- HTTP Tracking Setup
- Report Configuration
- Diagram Customisation
- Phase-Aware Tracking
- Content Formatting
- PlantUML Server Configuration
Features
- Generated Reports
- Report Themes
- Search and Filter Syntax
- Component Diagrams
- PlantUML Browser Rendering
- Inline SVG Rendering
- Internal Flow Tracking
- Tags and Attributes
- Excluding Requests
- Excluded Headers
- Multi-Host Test Architectures
- Event-Driven Architecture Testing
- Service Bus Tracking Patterns
- Background Thread Correlation
- Parallel-Safe Background Correlation
- Event & Message Tracking
- Assertion Tracking
- Step Tracking
- Tabular Attributes
- Large Response and Diagram Handling
- Querying Reports
- Service Card
- Cross-Run History
- Diagnostics and Debugging
- CI Summary Integration
- CI Artifact Upload
- Merging Parallel Reports
Reference