Skip to main content

Crate mcp_usage_export

Crate mcp_usage_export 

Source
Expand description

Buffered usage accounting for MCP calls.

Recording is synchronous, memory-only, and never performs network I/O. A separate BillingPipeline::flush drains aggregates into an exporter. If an export fails, the exact same event identifiers and quantities are retained for retry, which makes ambiguous provider failures safe.

Structs§

AggregatedUsage
One pre-aggregated provider event ready for export.
BillingPipeline
Coordinates a UsageBuffer with an off-path exporter.
CompositeExporter
Fan-out exporter for logs, billing, analytics, and audit sinks.
FnExporter
Adapter for an application-owned async export function.
LogExporter
Stateless exporter that emits structured log events.
MeterEventDeadLetter
A meter event that needs application-owned reconciliation.
MeterEventExporter
Exports pre-aggregated usage through an application-supplied provider.
MeterEventProviderError
Sanitized batch-wide provider failure without per-event outcomes.
NoopRecorder
Shared, no-op recorder for deployments that want attribution metrics only.
UsageBuffer
Thread-safe in-memory aggregator with bounded idempotency memory.
UsageEvent
One delivered unit event emitted by the request path.

Enums§

ExportError
Provider export failure.
MeterEventDeadLetterReason
Why a meter event was quarantined for reconciliation.
MeterEventOutcome
The provider’s final or retryable disposition for one meter event.
RecordError
Recording failures are internal synchronization failures only.
RecordOutcome
Result of attempting to record an event.

Traits§

BatchExporter
Exports a prepared batch away from the request path.
MeterEventProvider
Submits ordered batches of pre-aggregated usage to a billing provider.
UsageRecorder
A synchronous usage sink suitable for the HTTP hot path.

Type Aliases§

ExportFuture
Boxed future returned by object-safe billing exporters.
MeterEventProviderFuture
Boxed future returned by a meter event provider.
SharedExporter
Convenient trait-object alias for composing exporters at runtime.
SharedRecorder
Convenient trait-object alias used by the edge layer.