Documentation
¶
Overview ¶
Package observability provides logging and metrics wrappers and consistency for workflows there are several functions in this package that are geared towards reducing boilerplate overhead with the main callers by pre-setting common fields such as operation origin and trigger event so that inline within the workflow package we don't have crazy verbose log and metric statements making the code harder to read
Index ¶
- Constants
- func EmitEngine[T any](ctx context.Context, observer *Observer, emitter soiree.Emitter, ...) error
- func EmitFromTopic[T any](scope *Scope, emitter soiree.Emitter, topic soiree.TypedTopic[T], payload T, ...) error
- func WarnEngine(ctx context.Context, op OperationName, triggerEvent string, fields Fields, ...)
- func WarnListener(ctx context.Context, op OperationName, triggerEvent string, fields Fields, ...)
- func WarnResolver(ctx context.Context, op OperationName, triggerEvent string, fields Fields, ...)
- type Fields
- type Observer
- type Operation
- type OperationName
- type Origin
- type Scope
- func (s *Scope) Context() context.Context
- func (s *Scope) End(err error, fields Fields)
- func (s *Scope) Fail(err error, fields Fields) error
- func (s *Scope) Info(fields Fields)
- func (s *Scope) RecordError(err error, fields Fields)
- func (s *Scope) Skip(reason string, fields Fields)
- func (s *Scope) Warn(err error, fields Fields)
- func (s *Scope) WithFields(fields Fields)
Constants ¶
const ( // FieldOperation is the log field key for the workflow operation FieldOperation = "workflow_op" // FieldOrigin is the log field key for the workflow origin FieldOrigin = "origin" // FieldTriggerEvent is the log field key for the trigger event FieldTriggerEvent = "trigger_event" // FieldTopic is the log field key for event topics FieldTopic = "topic" // FieldPayload is the log field key for event payloads FieldPayload = "payload" // FieldActionKey is the log field key for workflow action keys FieldActionKey = "action_key" // FieldObjectType is the log field key for object types FieldObjectType = "object_type" // FieldExpression is the log field key for CEL expressions FieldExpression = "expression" // FieldSkipReason is the log field key for skip reasons FieldSkipReason = "skip_reason" )
Variables ¶
This section is empty.
Functions ¶
func EmitEngine ¶
func EmitEngine[T any](ctx context.Context, observer *Observer, emitter soiree.Emitter, topic soiree.TypedTopic[T], payload T, client any, op OperationName, triggerEvent string, fields Fields) error
EmitEngine wraps and emits a typed event for engine operations
func EmitFromTopic ¶
func EmitFromTopic[T any](scope *Scope, emitter soiree.Emitter, topic soiree.TypedTopic[T], payload T, client any, extra Fields) error
EmitFromTopic wraps and emits a typed event using topic-provided fields without initializing a scope
func WarnEngine ¶
func WarnEngine(ctx context.Context, op OperationName, triggerEvent string, fields Fields, err error)
WarnEngine logs a workflow warning for engine operations (with the trigger event pre-set reducing overhead for callers)
func WarnListener ¶
func WarnListener(ctx context.Context, op OperationName, triggerEvent string, fields Fields, err error)
WarnListener logs a workflow warning for listener operations (with the trigger event pre-set reducing overhead for callers)
func WarnResolver ¶
func WarnResolver(ctx context.Context, op OperationName, triggerEvent string, fields Fields, err error)
WarnResolver logs a workflow warning for resolver operations (with the trigger event pre-set reducing overhead for callers)
Types ¶
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
Observer standardizes workflow logging and metrics
type Operation ¶
type Operation struct {
// Name is the workflow operation name.
Name OperationName
// Origin is the component emitting the observation.
Origin Origin
// TriggerEvent is the event type that caused the operation.
TriggerEvent string
}
Operation describes a workflow operation being observed.
func (Operation) MarshalZerologObject ¶
MarshalZerologObject implements zerolog.LogObjectMarshaler for Operation.
type OperationName ¶
type OperationName string
OperationName identifies a workflow operation name.
const ( // OpTriggerWorkflow identifies trigger workflow operations. OpTriggerWorkflow OperationName = "trigger_workflow" // OpTriggerExistingInstance identifies trigger existing instance operations. OpTriggerExistingInstance OperationName = "trigger_existing_instance" // OpCompleteAssignment identifies assignment completion processing. OpCompleteAssignment OperationName = "complete_assignment" // OpFindMatchingDefinitions identifies definition matching. OpFindMatchingDefinitions OperationName = "find_matching_definitions" // OpResolveTargets identifies target resolution. OpResolveTargets OperationName = "resolve_targets" // OpHandleAssignmentCompleted identifies assignment completion handling. OpHandleAssignmentCompleted OperationName = "handle_assignment_completed" // OpExecuteAction identifies action execution. OpExecuteAction OperationName = "execute_action" )
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope tracks a single observed workflow operation
func BeginEngine ¶
func BeginEngine(ctx context.Context, observer *Observer, op OperationName, triggerEvent string, fields Fields) *Scope
BeginEngine starts an observation for workflow engine operations
func BeginListenerTopic ¶
func BeginListenerTopic[T any](ctx *soiree.EventContext, observer *Observer, topic soiree.TypedTopic[T], payload T, extra Fields) *Scope
BeginListenerTopic starts an observation for a workflow listener using topic metadata
func (*Scope) RecordError ¶
RecordError captures an error to be logged when the scope ends
func (*Scope) WithFields ¶
WithFields appends fields to the scope logger and context