package telemetry

Import Path
	github.com/pancsta/asyncmachine-go/pkg/telemetry (on go.dev)

Dependency Relation
	imports 28 packages, and imported by 15 packages

Involved Source Files Package telemetry provides telemetry exporters for asyncmachine: am-dbg, Prometheus, and OpenTelemetry. otel.go telemetry.go
Package-Level Type Names (total 8)
/* sort by: | */
DbgMsg is the interface for the messages to be sent to the am-dbg server. Clock returns the state's clock, using the passed index Is returns true if the state is active, using the passed index *DbgMsgStruct *DbgMsgTx
DbgMsgStruct contains the state and relations data. list of group names and state indexes order of groups Machine ID parent machine ID all the states with relations TODO refac: Schema state names defining the indexes for diffs machine tags (*DbgMsgStruct) Clock(_ am.S, _ string) uint64 (*DbgMsgStruct) Is(_ am.S, _ am.S) bool *DbgMsgStruct : DbgMsg func github.com/pancsta/asyncmachine-go/pkg/graph.(*Graph).AddClient(msg *DbgMsgStruct) error func github.com/pancsta/asyncmachine-go/tools/debugger/server.(*RPCServer).DbgMsgSchema(msgSchema *DbgMsgStruct, _ *string) error
DbgMsgTx contains transition data. result of the transition TODO rename to IsAccepted Args map[string]string called states TODO remove. Deprecated use CalledStateNames(index) TODO rename to CalledStates, re-gen all assets Clocks is represents the machine time [am.Time] from after the current transition. TODO refac to TimeAfter, re-gen all the assets Transition ID TODO refac: Id transition was triggered by an auto state is this a check (Can*) tx or mutation? is this a queued mutation? log entries created during the transition MachineID string MutQueueTick is the assigned queue tick when the tx will be executed. Only for IsQueued. TODO QueueDebug with all string entries for comparison MutQueueToken is the token of a prepended mutation, can be scheduled or executed, depending on IsQueued. log entries before the transition, which happened after the prev one queue length at the start of the transition TODO rename to QueueLen TODO change to int32 QueueDump []string QueueTick is the current queue tick in the machine. transition. all the transition steps Time is human time. Don't send this over the wire. TODO remove or skip in msgpack TODO rename to HTime mutation type (*DbgMsgTx) ActiveStates(statesIndex am.S) am.S (*DbgMsgTx) CalledStateNames(statesIndex am.S) am.S (*DbgMsgTx) Clock(statesIndex am.S, state string) uint64 (*DbgMsgTx) Index(statesIndex am.S, state string) int (*DbgMsgTx) Is(statesIndex am.S, states am.S) bool (*DbgMsgTx) Is1(statesIndex am.S, state string) bool TODO unify with Mut String TODO Sum() and TimeSum(idxs []int) TODO unify with Tx String *DbgMsgTx : DbgMsg func github.com/pancsta/asyncmachine-go/tools/debugger.(*Debugger).CurrentTx() *DbgMsgTx func github.com/pancsta/asyncmachine-go/tools/debugger.(*Debugger).NextTx() *DbgMsgTx func github.com/pancsta/asyncmachine-go/tools/debugger.(*Debugger).PrevTx() *DbgMsgTx func github.com/pancsta/asyncmachine-go/tools/debugger/server.(*Client).Tx(idx int) *DbgMsgTx func github.com/pancsta/asyncmachine-go/pkg/graph.(*Graph).ParseMsg(id string, msgTx *DbgMsgTx) func github.com/pancsta/asyncmachine-go/tools/debugger/server.(*RPCServer).DbgMsgTx(msgTx *DbgMsgTx, _ *string) error
Addr string Mach am.Api NoOpTracer *am.NoOpTracer ( DbgTracer) HandlerEnd(transition *machine.Transition, emitter string, handler string) ( DbgTracer) HandlerStart(transition *machine.Transition, emitter string, handler string) ( DbgTracer) Inheritable() bool (*DbgTracer) MachineDispose(id string) (*DbgTracer) MachineInit(mach am.Api) context.Context (*DbgTracer) MutationQueued(mach am.Api, mut *am.Mutation) ( DbgTracer) NewSubmachine(parent, machine machine.Api) ( DbgTracer) QueueEnd(machine machine.Api) (*DbgTracer) SchemaChange(mach am.Api, _ am.Schema) (*DbgTracer) TransitionEnd(tx *am.Transition) ( DbgTracer) TransitionInit(transition *machine.Transition) ( DbgTracer) TransitionStart(transition *machine.Transition) ( DbgTracer) VerifyStates(machine machine.Api) *DbgTracer : github.com/pancsta/asyncmachine-go/pkg/machine.Tracer func NewDbgTracer(mach am.Api, addr string) *DbgTracer
Ended bool ID string Index is a unique number for this machine withing the Otel tracer.
OtelMachTracer implements machine.Tracer for OpenTelemetry. Supports tracing of multiple state machines, resulting in a single trace. This tracer is automatically bound to new sub-machines. TODO bind to env var Machines map[string]*OtelMachineData MachinesMx sync.Mutex MachinesOrder []string NextIndex int NoOpTracer *am.NoOpTracer RootSpan trace.Span Tracer trace.Tracer (*OtelMachTracer) End() (*OtelMachTracer) HandlerEnd(tx *am.Transition, emitter string, handler string) ( OtelMachTracer) HandlerStart(transition *machine.Transition, emitter string, handler string) ( OtelMachTracer) Inheritable() bool (*OtelMachTracer) MachineDispose(id string) (*OtelMachTracer) MachineInit(mach am.Api) context.Context ( OtelMachTracer) MutationQueued(machine machine.Api, mutation *machine.Mutation) NewSubmachine links 2 machines with a parent-child relationship. (*OtelMachTracer) QueueEnd(mach am.Api) ( OtelMachTracer) SchemaChange(machine machine.Api, old machine.Schema) (*OtelMachTracer) TransitionEnd(tx *am.Transition) (*OtelMachTracer) TransitionInit(tx *am.Transition) ( OtelMachTracer) TransitionStart(transition *machine.Transition) ( OtelMachTracer) VerifyStates(machine machine.Api) *OtelMachTracer : github.com/pancsta/asyncmachine-go/pkg/machine.Tracer func NewOtelMachTracer(rootMach am.Api, rootSpan trace.Span, otelTracer trace.Tracer, opts *OtelMachTracerOpts) *OtelMachTracer
TODO if true, only Healthcheck and Heartbeat will be skipped Logf func(format string, args ...any) if true, auto transitions won't be traced if true, transition traces won't include [am.Machine.GetLogArgs] if true, only state changes will be traced TODO func NewOtelMachTracer(rootMach am.Api, rootSpan trace.Span, otelTracer trace.Tracer, opts *OtelMachTracerOpts) *OtelMachTracer
Ctx context.Context Id string
Package-Level Functions (total 10)
BindLokiEnv bind Loki logger to [mach], based on environment vars: - AM_SERVICE (required) - AM_LOKI_ADDR (required) This tracer is NOT inherited by submachines.
func BindLokiLogger(mach am.Api, client promtail.Client)
BindOtelLogger binds an OpenTelemetry logger to a machine.
MachBindOtelEnv bind an OpenTelemetry tracer to [mach], based on environment variables: - AM_SERVICE (required) - AM_OTEL_TRACE (required) - AM_OTEL_TRACE_TXS - OTEL_EXPORTER_OTLP_ENDPOINT - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT This tracer is inherited by submachines, and this function applies only to top-level machines.
func NewDbgTracer(mach am.Api, addr string) *DbgTracer
NewOtelLoggerProvider creates a new OpenTelemetry logger provider bound to the given exporter.
NewOtelMachTracer creates a new machine tracer from an OpenTelemetry tracer. Requires OtelMachTracer.Dispose to be called at the end.
TransitionsToDbg sends transitions to the am-dbg server.
Package-Level Constants (total 8)
DbgAddr is the default address of the am-dbg server.
EnvAmDbgAddr is the address of a running am-dbg instance. "1" expands to "localhost:6831"
const EnvLokiAddr = "AM_LOKI_ADDR"
const EnvOtelTrace = "AM_OTEL_TRACE"
const EnvOtelTraceArgs = "AM_OTEL_TRACE_ARGS"
const EnvOtelTraceNoauto = "AM_OTEL_TRACE_NOAUTO"
const EnvOtelTraceTxs = "AM_OTEL_TRACE_TXS"
const EnvService = "AM_SERVICE"