Class Slf4jErrorReportPublisher

java.lang.Object
com.tnsai.observability.errors.Slf4jErrorReportPublisher
All Implemented Interfaces:
ErrorReportPublisher

public final class Slf4jErrorReportPublisher extends Object implements ErrorReportPublisher
Default ErrorReportPublisher — JSON-serialises the report and writes it via SLF4J at the level matching the report's ErrorCategory. A Logstash JSON encoder configured on the com.tnsai.observability.errors.ErrorReport logger picks the structured payload up; without one, the JSON shows up in plain text logs which are still grep-able by fingerprint / errorCode.

Error level mapping:

Logger is one-per-error-class (e.g. com.tnsai.exceptions.LLMException) so consumers can filter specific exception types separately from the umbrella ErrorReport channel.

This publisher is registered via SPI in META-INF/services/com.tnsai.observability.errors.ErrorReportPublisher so the ErrorReports facade picks it up automatically.

Since:
0.5.0 (issue #86)
  • Constructor Details

    • Slf4jErrorReportPublisher

      public Slf4jErrorReportPublisher()
  • Method Details

    • publish

      public void publish(ErrorReport report)
      Description copied from interface: ErrorReportPublisher
      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.
      Specified by:
      publish in interface ErrorReportPublisher