Package com.tnsai.observability.errors
Interface ErrorReportPublisher
- All Known Implementing Classes:
CapturingErrorReportPublisher,CompositeErrorReportPublisher,DedupingErrorReportPublisher,Slf4jErrorReportPublisher
public interface ErrorReportPublisher
Service-side fan-out point for
ErrorReport emissions.
Mirrors the AgentEventPublisher
pattern but for the dedicated error pipeline. Errors get a separate
publisher because:
- They have error-specific dedup semantics (fingerprint-based suppression — out of scope for this PR, see follow-up dedup decorator).
- External error trackers (Sentry, Rollbar, Datadog Error Tracking) want a tight, error-only payload not buried inside a generic event stream.
- Operators commonly want different sinks per channel — chat events to Loki, errors to Sentry — without composing string filters on event types.
Discovered via ServiceLoader; ErrorReports
auto-composes all discovered publishers via
CompositeErrorReportPublisher, so adding a new sink is just
dropping a JAR with a META-INF/services/ entry. Consumers that
want a custom pipeline can call ErrorReports.setPublisher(ErrorReportPublisher)
to override.
Implementations shipped
Slf4jErrorReportPublisher— default, JSON-serializes the report and emits via SLF4J at the level matching report severity. Logstash encoder picks it up for structured sinks.CompositeErrorReportPublisher— fan-out wrapper used internally to combine multiple publishers; consumers can wrap too.CapturingErrorReportPublisher— test utility that holds reports in memory for assertion. Not registered via SPI.
Implementation contract
Implementations must:- Be safe to call from any thread (no per-thread state assumed).
- Never propagate exceptions — log and drop. The caller is in an error path; making it harder is the wrong move.
- Be idempotent for repeated reports of the same fingerprint (the dedup decorator can wrap, but the base publisher must not blow up on a fingerprint it has seen before).
- Since:
- 0.5.0 (issue #86)
-
Method Summary
Modifier and TypeMethodDescriptionvoidpublish(ErrorReport report) Publish a single error report.
-
Method Details
-
publish
Publish a single error report. Errors during publication must not propagate to the caller — the caller is already in an error path; an exception here would mask the original failure.
-