Documentation
¶
Overview ¶
Package stats-observer demonstrates how to use stats.ValidationObserver and stats.ReportErrors with codecs directly — without any HTTP or MQTT adapter.
This is the codec-only observability path: implement just stats.ValidationObserver (one method) and call stats.ReportErrors after each codex.Codec.Decode.
Scenario: an application validates its config file on startup. Invalid config fields emit stats.RecordValidationError events that a production observer would route to Prometheus counters, structured logs, or alerting.
The final section demonstrates stats.TraceObserver — an additive optional interface for distributed tracing. Implement StartSpan/EndSpan against your tracing backend (OpenTelemetry, Datadog, etc.) and wire it via stats.NewFanout alongside metrics and logging observers.
Run with: go run ./examples/stats-observer