Documentation
¶
Index ¶
- Variables
- func IsConnectionAbortPanic(recovered any) bool
- func LogRecoveredPanic(event *Event, operation string, recovered any, stack []byte)
- func RecoveredPanicError(event *Event, operation string, recovered any, stack []byte) error
- func WithContext(ctx context.Context, event *Event) context.Context
- func WithErrorDetails(err error, details ErrorDetails) error
- type Emitter
- type ErrorDetailer
- type ErrorDetails
- type ErrorDetailsEntry
- type ErrorDetailsProvider
- type Event
- func (e *Event) EmitStart() bool
- func (e *Event) EmitTerminal(result Result) bool
- func (e *Event) EnrichError(err error)
- func (e *Event) Message() string
- func (e *Event) SetAgentID(value string)
- func (e *Event) SetAttachmentID(value string)
- func (e *Event) SetClientID(value string)
- func (e *Event) SetConnectionID(value string)
- func (e *Event) SetConversationID(value string)
- func (e *Event) SetCursor(value string)
- func (e *Event) SetEntryID(value string)
- func (e *Event) SetErrorCode(value string)
- func (e *Event) SetErrorType(value string)
- func (e *Event) SetFailureCount(value int64)
- func (e *Event) SetGRPCStatus(status string)
- func (e *Event) SetHTTPStatus(status int)
- func (e *Event) SetMemoryID(value string)
- func (e *Event) SetProvider(details ErrorDetailsProvider)
- func (e *Event) SetReason(value string)
- func (e *Event) SetRequestID(value string)
- func (e *Event) SetRetryAttempt(value int)
- func (e *Event) SetTaskID(value string)
- func (e *Event) SetUserID(value string)
- func (e *Event) SetWorkCount(value int64)
- func (e *Event) Snapshot() Snapshot
- type Level
- type Option
- type Result
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
var ErrRecoveredPanic = errors.New("recovered panic")
ErrRecoveredPanic identifies an internal panic converted into an error at a child-goroutine boundary.
Functions ¶
func IsConnectionAbortPanic ¶
IsConnectionAbortPanic reports whether recovered is an expected transport disconnect that should remain stack-suppressed.
func LogRecoveredPanic ¶
LogRecoveredPanic emits a stack-bearing diagnostic point log correlated with an operation. Stacks and panic values intentionally remain outside the canonical event snapshot.
func RecoveredPanicError ¶
RecoveredPanicError logs a recovered panic at its recovery site and returns a privacy-safe error that can be propagated to the operation boundary. Expected connection aborts remain stack-suppressed and become cancellation.
func WithContext ¶
WithContext attaches an event to a context.
func WithErrorDetails ¶
func WithErrorDetails(err error, details ErrorDetails) error
WithErrorDetails wraps err with privacy-safe typed operational diagnostics.
Types ¶
type Emitter ¶
Emitter receives an immutable event record. It is primarily useful for focused tests.
type ErrorDetailer ¶
type ErrorDetailer interface {
OperationErrorDetails() ErrorDetails
}
ErrorDetailer exposes bounded, privacy-safe operational diagnostics.
type ErrorDetails ¶
type ErrorDetails struct {
ErrorType string `json:"errorType,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
Reason string `json:"reason,omitempty"`
Provider *ErrorDetailsProvider `json:"provider,omitempty"`
}
ErrorDetails describes a privacy-safe typed error. Diagnostic values must not contain raw errors.
type ErrorDetailsEntry ¶
type ErrorDetailsEntry struct {
ErrorType string `json:"errorType,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
Reason string `json:"reason,omitempty"`
Provider *ErrorDetailsProvider `json:"provider,omitempty"`
Branch string `json:"branch,omitempty"`
Depth int `json:"depth"`
}
ErrorDetailsEntry records one typed cause and its position in an unwrap tree.
type ErrorDetailsProvider ¶
type ErrorDetailsProvider struct {
Name string `json:"name,omitempty"`
StatusCode int `json:"statusCode,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
TransactionID string `json:"transactionID,omitempty"`
}
ErrorDetailsProvider contains privacy-safe provider metadata.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is a concurrency-safe canonical operation event.
func FromContext ¶
FromContext returns the event attached to ctx, if any.
func (*Event) EmitStart ¶
EmitStart emits at most one start record. Use it only for substantial or streaming work.
func (*Event) EmitTerminal ¶
EmitTerminal emits at most one completion record.
func (*Event) EnrichError ¶
EnrichError collects typed details from a terminal error only.
func (*Event) SetAgentID ¶
func (*Event) SetAttachmentID ¶
func (*Event) SetClientID ¶
func (*Event) SetConnectionID ¶
func (*Event) SetConversationID ¶
func (*Event) SetEntryID ¶
func (*Event) SetErrorCode ¶
func (*Event) SetErrorType ¶
func (*Event) SetFailureCount ¶
func (*Event) SetGRPCStatus ¶
func (*Event) SetHTTPStatus ¶
func (*Event) SetMemoryID ¶
func (*Event) SetProvider ¶
func (e *Event) SetProvider(details ErrorDetailsProvider)
func (*Event) SetRequestID ¶
func (*Event) SetRetryAttempt ¶
func (*Event) SetWorkCount ¶
type Level ¶
type Level string
Level is the severity used for a canonical event.
func LevelForResult ¶
LevelForResult returns the canonical severity for result.
type Option ¶
type Option func(*Event)
func WithEmitter ¶
WithEmitter overrides the default structured logger sink.
type Result ¶
type Result string
Result is the transport-independent outcome of an operation.
const ( ResultSuccess Result = "success" ResultInvalid Result = "invalid" ResultUnauthenticated Result = "unauthenticated" ResultForbidden Result = "forbidden" ResultNotFound Result = "not_found" ResultConflict Result = "conflict" ResultRateLimited Result = "rate_limited" ResultTimedOut Result = "timed_out" ResultCanceled Result = "canceled" ResultRejected Result = "rejected" ResultFailed Result = "failed" ResultRetrying Result = "retrying" )
func ResultFromGRPC ¶
ResultFromGRPC maps a final gRPC code and context state to a semantic result.
func ResultFromHTTP ¶
ResultFromHTTP maps a final HTTP status and context state to a semantic result.
type Snapshot ¶
type Snapshot struct {
Phase string `json:"phase,omitempty"`
RequestID string `json:"requestID,omitempty"`
Status any `json:"status,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
Result Result `json:"result,omitempty"`
Reason string `json:"reason,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorType string `json:"errorType,omitempty"`
UserID string `json:"userID,omitempty"`
ClientID string `json:"clientID,omitempty"`
AgentID string `json:"agentID,omitempty"`
ConversationID string `json:"conversationID,omitempty"`
EntryID string `json:"entryID,omitempty"`
AttachmentID string `json:"attachmentID,omitempty"`
MemoryID string `json:"memoryID,omitempty"`
TaskID string `json:"taskID,omitempty"`
ConnectionID string `json:"connectionID,omitempty"`
Cursor string `json:"cursor,omitempty"`
ProviderName string `json:"providerName,omitempty"`
ProviderStatusCode int `json:"providerStatusCode,omitempty"`
ProviderErrorCode string `json:"providerErrorCode,omitempty"`
ProviderTransactionID string `json:"providerTransactionID,omitempty"`
RetryAttempt int `json:"retryAttempt,omitempty"`
WorkCount int64 `json:"workCount,omitempty"`
FailureCount int64 `json:"failureCount,omitempty"`
ErrorDetails []ErrorDetailsEntry `json:"errorDetails,omitempty"`
ErrorDetailsTruncated bool `json:"errorDetailsTruncated,omitempty"`
}
Snapshot is an immutable copy of an event's sparse canonical fields.