Record Class ErrorReport

java.lang.Object
java.lang.Record
com.tnsai.observability.errors.ErrorReport

public record ErrorReport(String reportId, Instant timestamp, String fingerprint, String errorClass, String errorCode, String message, List<CauseInfo> causeChain, ErrorCategory category, boolean retryable, Optional<Duration> suggestedRetryDelay, String stackTraceDigest, Optional<String> fullStackTrace, Optional<EventContext> context, Optional<String> recoveryAction, int recoveryAttempts, Map<String,Object> attributes, List<String> relatedEventIds) extends Record
Structured observability record for an error event.

One ErrorReport per error occurrence, dedup-able by fingerprint(). Carries everything an operator or aggregator needs to triage:

  • Identity: reportId (unique per occurrence) + fingerprint (stable per bug)
  • Type: errorClass, errorCode, message (redaction applied upstream)
  • Cause chain: flat list of CauseInfo for full context without getCause().getCause()... digging
  • Classification: ErrorCategory + retryable + suggestedRetryDelay
  • Diagnostic: stack trace digest + optional full trace
  • Correlation: EventContext from #78 (tenant, agent, role, trace, span, ...)
  • Recovery: action taken (RETRIED, DLQ, ESCALATED, NONE) + attempt count
  • Attributes: error-specific fields (LLM provider/model, tool name, ...)

Construction is via ErrorReport.Builder; required fields validated on ErrorReport.Builder.build(). The record is structurally immutable so it is safe to share across threads (e.g. for buffering before flush).

Since:
0.5.0 (issue #86)
  • Constructor Details

    • ErrorReport

      public ErrorReport(String reportId, Instant timestamp, String fingerprint, String errorClass, String errorCode, String message, List<CauseInfo> causeChain, ErrorCategory category, boolean retryable, Optional<Duration> suggestedRetryDelay, String stackTraceDigest, Optional<String> fullStackTrace, Optional<EventContext> context, Optional<String> recoveryAction, int recoveryAttempts, Map<String,Object> attributes, List<String> relatedEventIds)
      Creates an instance of a ErrorReport record class.
      Parameters:
      reportId - the value for the reportId record component
      timestamp - the value for the timestamp record component
      fingerprint - the value for the fingerprint record component
      errorClass - the value for the errorClass record component
      errorCode - the value for the errorCode record component
      message - the value for the message record component
      causeChain - the value for the causeChain record component
      category - the value for the category record component
      retryable - the value for the retryable record component
      suggestedRetryDelay - the value for the suggestedRetryDelay record component
      stackTraceDigest - the value for the stackTraceDigest record component
      fullStackTrace - the value for the fullStackTrace record component
      context - the value for the context record component
      recoveryAction - the value for the recoveryAction record component
      recoveryAttempts - the value for the recoveryAttempts record component
      attributes - the value for the attributes record component
      relatedEventIds - the value for the relatedEventIds record component
  • Method Details

    • builder

      public static ErrorReport.Builder builder()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • reportId

      public String reportId()
      Returns the value of the reportId record component.
      Returns:
      the value of the reportId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • fingerprint

      public String fingerprint()
      Returns the value of the fingerprint record component.
      Returns:
      the value of the fingerprint record component
    • errorClass

      public String errorClass()
      Returns the value of the errorClass record component.
      Returns:
      the value of the errorClass record component
    • errorCode

      public String errorCode()
      Returns the value of the errorCode record component.
      Returns:
      the value of the errorCode record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • causeChain

      public List<CauseInfo> causeChain()
      Returns the value of the causeChain record component.
      Returns:
      the value of the causeChain record component
    • category

      public ErrorCategory category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • retryable

      public boolean retryable()
      Returns the value of the retryable record component.
      Returns:
      the value of the retryable record component
    • suggestedRetryDelay

      public Optional<Duration> suggestedRetryDelay()
      Returns the value of the suggestedRetryDelay record component.
      Returns:
      the value of the suggestedRetryDelay record component
    • stackTraceDigest

      public String stackTraceDigest()
      Returns the value of the stackTraceDigest record component.
      Returns:
      the value of the stackTraceDigest record component
    • fullStackTrace

      public Optional<String> fullStackTrace()
      Returns the value of the fullStackTrace record component.
      Returns:
      the value of the fullStackTrace record component
    • context

      public Optional<EventContext> context()
      Returns the value of the context record component.
      Returns:
      the value of the context record component
    • recoveryAction

      public Optional<String> recoveryAction()
      Returns the value of the recoveryAction record component.
      Returns:
      the value of the recoveryAction record component
    • recoveryAttempts

      public int recoveryAttempts()
      Returns the value of the recoveryAttempts record component.
      Returns:
      the value of the recoveryAttempts record component
    • attributes

      public Map<String,Object> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component
    • relatedEventIds

      public List<String> relatedEventIds()
      Returns the value of the relatedEventIds record component.
      Returns:
      the value of the relatedEventIds record component