Skip to content

Commit 7365de0

Browse files
committed
Stats exporter in README
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent c179590 commit 7365de0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

libdd-trace-stats/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Compute aggregated statistics from distributed tracing spans with time-bucketed
1414
- **Span Filtering**: Filter spans by top-level, measured, or span.kind
1515
- **Time Bucketing**: Configurable bucket sizes for aggregation
1616
- **Statistics Export**: Generate statistics payloads for Datadog backend
17+
- **Stats Exporter** *(non-wasm)*: Periodic HTTP flusher backed by any `HttpClientTrait` implementation
1718

1819
## Span Concentrator
1920

@@ -41,6 +42,28 @@ Only certain spans are aggregated:
4142

4243
When flushed, the concentrator keeps the most recent buckets and returns older buckets as statistics.
4344

45+
## Stats Exporter
46+
47+
`StatsExporter` wraps a `FlushableConcentrator` and periodically drains it, encoding the resulting `ClientStatsPayload` as msgpack and POSTing it to the agent's `/v0.6/stats` endpoint.
48+
49+
```rust
50+
use libdd_trace_stats::stats_exporter::{StatsExporter, StatsMetadata};
51+
use libdd_capabilities_impl::NativeCapabilities;
52+
use std::sync::{Arc, Mutex};
53+
use std::time::Duration;
54+
55+
let exporter = StatsExporter::<NativeCapabilities>::new(
56+
Duration::from_secs(10),
57+
Arc::new(Mutex::new(concentrator)),
58+
StatsMetadata { service: "my-service".into(), ..Default::default() },
59+
endpoint,
60+
NativeCapabilities::new_client(),
61+
);
62+
63+
// Flush and send (force=true drains all buckets on shutdown)
64+
exporter.send(false).await?;
65+
```
66+
4467
## Example Usage
4568

4669
```rust

0 commit comments

Comments
 (0)