observability

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

View Source
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 Fields

type Fields map[string]any

Fields captures standard workflow log fields.

type Observer

type Observer struct {
	// contains filtered or unexported fields
}

Observer standardizes workflow logging and metrics

func New

func New() *Observer

New returns a workflow observer with defaults

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

func (op Operation) MarshalZerologObject(e *zerolog.Event)

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 Origin

type Origin string

Origin identifies the component emitting the observation.

const (
	// OriginEngine identifies workflow engine operations.
	OriginEngine Origin = "engine"
	// OriginListeners identifies workflow listener operations.
	OriginListeners Origin = "listeners"
	// OriginResolver identifies workflow resolver operations.
	OriginResolver Origin = "resolver"
)

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) Context

func (s *Scope) Context() context.Context

Context returns the scoped context with logger fields applied

func (*Scope) End

func (s *Scope) End(err error, fields Fields)

End finalizes the observation, logging and recording metrics.

func (*Scope) Fail

func (s *Scope) Fail(err error, fields Fields) error

Fail records an error with fields and returns it for the caller

func (*Scope) Info

func (s *Scope) Info(fields Fields)

Info logs a standardized workflow info event

func (*Scope) RecordError

func (s *Scope) RecordError(err error, fields Fields)

RecordError captures an error to be logged when the scope ends

func (*Scope) Skip

func (s *Scope) Skip(reason string, fields Fields)

Skip marks the operation as skipped with an optional reason

func (*Scope) Warn

func (s *Scope) Warn(err error, fields Fields)

Warn logs a standardized workflow warning

func (*Scope) WithFields

func (s *Scope) WithFields(fields Fields)

WithFields appends fields to the scope logger and context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL