Package com.tnsai.observability.errors
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
CauseInfofor full context withoutgetCause().getCause()...digging - Classification:
ErrorCategory+ retryable + suggestedRetryDelay - Diagnostic: stack trace digest + optional full trace
- Correlation:
EventContextfrom #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)
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionErrorReport(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 aErrorReportrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattributesrecord component.static ErrorReport.Builderbuilder()category()Returns the value of thecategoryrecord component.Returns the value of thecauseChainrecord component.context()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorClassrecord component.Returns the value of theerrorCoderecord component.Returns the value of thefingerprintrecord component.Returns the value of thefullStackTracerecord component.final inthashCode()Returns a hash code value for this object.message()Returns the value of themessagerecord component.Returns the value of therecoveryActionrecord component.intReturns the value of therecoveryAttemptsrecord component.Returns the value of therelatedEventIdsrecord component.reportId()Returns the value of thereportIdrecord component.booleanReturns the value of theretryablerecord component.Returns the value of thestackTraceDigestrecord component.Returns the value of thesuggestedRetryDelayrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
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 aErrorReportrecord class.- Parameters:
reportId- the value for thereportIdrecord componenttimestamp- the value for thetimestamprecord componentfingerprint- the value for thefingerprintrecord componenterrorClass- the value for theerrorClassrecord componenterrorCode- the value for theerrorCoderecord componentmessage- the value for themessagerecord componentcauseChain- the value for thecauseChainrecord componentcategory- the value for thecategoryrecord componentretryable- the value for theretryablerecord componentsuggestedRetryDelay- the value for thesuggestedRetryDelayrecord componentstackTraceDigest- the value for thestackTraceDigestrecord componentfullStackTrace- the value for thefullStackTracerecord componentcontext- the value for thecontextrecord componentrecoveryAction- the value for therecoveryActionrecord componentrecoveryAttempts- the value for therecoveryAttemptsrecord componentattributes- the value for theattributesrecord componentrelatedEventIds- the value for therelatedEventIdsrecord component
-
-
Method Details
-
builder
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
reportId
Returns the value of thereportIdrecord component.- Returns:
- the value of the
reportIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
fingerprint
Returns the value of thefingerprintrecord component.- Returns:
- the value of the
fingerprintrecord component
-
errorClass
Returns the value of theerrorClassrecord component.- Returns:
- the value of the
errorClassrecord component
-
errorCode
Returns the value of theerrorCoderecord component.- Returns:
- the value of the
errorCoderecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
causeChain
Returns the value of thecauseChainrecord component.- Returns:
- the value of the
causeChainrecord component
-
category
Returns the value of thecategoryrecord component.- Returns:
- the value of the
categoryrecord component
-
retryable
public boolean retryable()Returns the value of theretryablerecord component.- Returns:
- the value of the
retryablerecord component
-
suggestedRetryDelay
Returns the value of thesuggestedRetryDelayrecord component.- Returns:
- the value of the
suggestedRetryDelayrecord component
-
stackTraceDigest
Returns the value of thestackTraceDigestrecord component.- Returns:
- the value of the
stackTraceDigestrecord component
-
fullStackTrace
Returns the value of thefullStackTracerecord component.- Returns:
- the value of the
fullStackTracerecord component
-
context
Returns the value of thecontextrecord component.- Returns:
- the value of the
contextrecord component
-
recoveryAction
Returns the value of therecoveryActionrecord component.- Returns:
- the value of the
recoveryActionrecord component
-
recoveryAttempts
public int recoveryAttempts()Returns the value of therecoveryAttemptsrecord component.- Returns:
- the value of the
recoveryAttemptsrecord component
-
attributes
Returns the value of theattributesrecord component.- Returns:
- the value of the
attributesrecord component
-