Notification Logging and Observability
Summary
Observability comes from the shared kernel: structured JSON logging, OpenTelemetry tracing with a service-specific dispatch span, correlation-id propagation and a durable audit trail. A health endpoint and a statistics endpoint provide operational read surfaces.
Signal map
Logging
AddHrSuitObservability clears default providers and adds a JSON console logger with scopes and UTC timestamps. The dispatcher and channel senders emit structured ILogger events (duplicate skip, stale skip, delivery failure warnings, placeholder sends).
Tracing
NotificationTelemetry defines the HrSuit.NotificationService ActivitySource, registered with the tracer in Program.cs. DispatchAsync starts a consumer-kind span per event tagged with event type, event id and correlation id, and captures the trace id onto audit rows. Shared-kernel tracing adds ASP.NET Core and HTTP client instrumentation, with an optional OTLP exporter and console exporter enabled by configuration.
Correlation
UseHrSuitCorrelationId propagates an X-Correlation-Id header and item. Correlation ids are stored on messages, processed-event rows and audit rows, and the audit endpoint can be queried by correlation id.
Audit trail
NotificationAuditLog is an append-only, DB-backed record of every processing stage with tenant, event, message, correlation and trace identifiers — queryable via GET /notifications/audit. This is the primary durable diagnostic surface.
Health and statistics
/health is mapped via ASP.NET Core health checks; the root endpoint returns service info. /notifications/stats returns aggregate counts for operational visibility.
Recommended improvements (not implemented)
- No metrics/meter provider or metrics exporter is registered (tracing only).
- No health-data push to the platform service.
- No log/trace sink is configured by default (exporters depend on environment configuration).
Requires Confirmation
Production log sink, trace exporter endpoint, metrics strategy and health-monitoring integration require confirmation.
Source References
microservices/src/notification-service/Program.csmicroservices/src/notification-service/Application/NotificationTelemetry.csmicroservices/src/notification-service/Application/NotificationDispatcher.csmicroservices/src/shared-kernel/Extensions/ObservabilityExtensions.cs
Related Articles
See Also
Keywords
Logging, tracing, correlation, audit, health, OpenTelemetry.
Revision Information
- Status: Draft
- Last reviewed: 2026-07-21
- Next review: 2026-10-21