name, description
| name |
description |
| sp-events-metrics |
OTel metrics companion for @suaveplan/events — dispatch counters, latency histograms, queue-depth gauges via interceptor API. |
Architecture
| Component |
Responsibility |
attachEventMetrics |
Attaches OTel metrics instrumentation to an EventBus via public interceptor API |
EventMetricsHandle |
Returned handle providing snapshot() and detach() for lifecycle management |
MetricsSnapshot |
Typed snapshot of dispatch totals, listener error counts, and latency histograms per event name |
METRIC_NAMES |
Canonical OTel instrument names (events.dispatch_total, events.listener_errors_total, etc.) |
ATTRIBUTE_KEYS |
Standard attribute keys for metric dimensions |
EVENTS_METRICS_CODES + EventsMetricsError |
Structured error registry for metrics attachment failures |
File Structure
Sibling packages
@suaveplan/events — EventBus that this package instruments
@suaveplan/opentelemetry — OTel SDK setup helpers
@suaveplan/error — structured error registry via defineCodes
@suaveplan/types — shared TypeScript primitives
@suaveplan/testing — unit test infrastructure
Patterns
Quick Start
Inspect metrics snapshot
Constraints
- Attaches via
@suaveplan/events public interceptor API (no private state access)
- Metrics are no-ops when no
MeterProvider is registered
detach() removes all instrumentation without affecting the bus
- OTel counters tagged by event name; histograms record dispatch latency in ms
Checklist