Skip to main content

Module dispatch_metrics

Module dispatch_metrics 

Source
Expand description

OTLP dispatch-rate counters for commands/queries/reports/views.

Mirrors the entity_set_stats.rs/report_cache_stats.rs idiom but reports through OTel Counters instead of a periodic log line, so a dashboard can compute per-second rates and slice by tag (command/query/ report/view id, and dispatch origin) instead of grepping logs.

Cheap/no-op without a registered MeterProvider (see myko-server’s telemetry::init_from_env) — opentelemetry::global::meter falls back to a no-op meter when telemetry isn’t configured, so these calls are safe to leave in unconditionally.

Functions§

record_command
One increment per command execution, tagged by command id and source"external" for commands arriving pre-serialized via CommandExecutorAdapter::execute_from_value (the funnel for both native-WS command dispatch and MCP HTTP/WS in-process tool calls), vs "internal" for commands composed in-process by another command handler or a saga via CommandContext::execute_command. This is a dispatch path distinction, not a transport one — it answers “did this arrive from outside the process or get called by server-side code composing commands,” which is what actually matters for load attribution.
record_query
record_query_response
record_report
record_report_response
record_view
record_view_response