Documentation
¶
Overview ¶
Package telemetry provides telemetry exporters for asyncmachine: am-dbg, Prometheus, and OpenTelemetry.
Index ¶
- Constants
- func BindLokiEnv(mach am.Api) error
- func BindLokiLogger(mach am.Api, client promtail.Client)
- func BindOtelLogger(mach am.Api, provider *ologsdk.LoggerProvider, service string)
- func MachBindOtelEnv(mach am.Api) error
- func NewOtelLoggerProvider(exporter ologsdk.Exporter) *ologsdk.LoggerProvider
- func NewOtelProvider(source string, ctx context.Context) (trace.Tracer, *sdktrace.TracerProvider, error)
- func NormalizeId(id string) string
- func TransitionsToDbg(mach am.Api, addr string) error
- type DbgMsg
- type DbgMsgStruct
- type DbgMsgTx
- func (m *DbgMsgTx) ActiveStates(statesIndex am.S) am.S
- func (m *DbgMsgTx) CalledStateNames(statesIndex am.S) am.S
- func (m *DbgMsgTx) Clock(statesIndex am.S, state string) uint64
- func (m *DbgMsgTx) Index(statesIndex am.S, state string) int
- func (m *DbgMsgTx) Is(statesIndex am.S, states am.S) bool
- func (m *DbgMsgTx) Is1(statesIndex am.S, state string) bool
- func (m *DbgMsgTx) MutString(statesIndex am.S) string
- func (m *DbgMsgTx) TimeSum() uint64
- func (m *DbgMsgTx) TxString(statesIndex am.S) string
- type DbgTracer
- type OtelMachTracer
- func (mt *OtelMachTracer) End()
- func (mt *OtelMachTracer) HandlerEnd(tx *am.Transition, emitter string, handler string)
- func (mt *OtelMachTracer) MachineDispose(id string)
- func (mt *OtelMachTracer) MachineInit(mach am.Api) context.Context
- func (mt *OtelMachTracer) NewSubmachine(parent, mach am.Api)
- func (mt *OtelMachTracer) QueueEnd(mach am.Api)
- func (mt *OtelMachTracer) TransitionEnd(tx *am.Transition)
- func (mt *OtelMachTracer) TransitionInit(tx *am.Transition)
- type OtelMachTracerOpts
- type OtelMachineData
- type OtelTxHist
Constants ¶
const ( // DbgAddr is the default address of the am-dbg server. DbgAddr = "localhost:6831" // EnvAmDbgAddr is the address of a running am-dbg instance. // "1" expands to "localhost:6831" EnvAmDbgAddr = "AM_DBG_ADDR" )
const ( EnvService = "AM_SERVICE" EnvLokiAddr = "AM_LOKI_ADDR" EnvOtelTrace = "AM_OTEL_TRACE" EnvOtelTraceTxs = "AM_OTEL_TRACE_TXS" EnvOtelTraceArgs = "AM_OTEL_TRACE_ARGS" EnvOtelTraceNoauto = "AM_OTEL_TRACE_NOAUTO" )
Variables ¶
This section is empty.
Functions ¶
func BindLokiEnv ¶ added in v0.11.0
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 BindOtelLogger ¶ added in v0.8.0
func BindOtelLogger( mach am.Api, provider *ologsdk.LoggerProvider, service string, )
BindOtelLogger binds an OpenTelemetry logger to a machine.
func MachBindOtelEnv ¶ added in v0.10.3
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 NewOtelLoggerProvider ¶ added in v0.8.0
func NewOtelLoggerProvider(exporter ologsdk.Exporter) *ologsdk.LoggerProvider
NewOtelLoggerProvider creates a new OpenTelemetry logger provider bound to the given exporter.
func NewOtelProvider ¶ added in v0.10.3
func NormalizeId ¶ added in v0.8.0
Types ¶
type DbgMsg ¶ added in v0.5.0
type DbgMsg interface {
// Clock returns the state's clock, using the passed index
Clock(statesIndex am.S, state string) uint64
// Is returns true if the state is active, using the passed index
Is(statesIndex am.S, states am.S) bool
}
DbgMsg is the interface for the messages to be sent to the am-dbg server.
type DbgMsgStruct ¶ added in v0.5.0
type DbgMsgStruct struct {
// Machine ID
ID string
// state names defining the indexes for diffs
StatesIndex am.S
// all the states with relations
// TODO refac: Schema
States am.Schema
// list of group names and state indexes
Groups map[string][]int
// order of groups
GroupsOrder []string
// parent machine ID
Parent string
// machine tags
Tags []string
}
DbgMsgStruct contains the state and relations data.
type DbgMsgTx ¶ added in v0.5.0
type DbgMsgTx struct {
MachineID string
// Transition ID
// TODO refac: Id
ID string
// Clocks is represents the machine time [am.Time] from after the current
// transition.
// TODO refac to TimeAfter, re-gen all the assets
Clocks am.Time
// QueueTick is the current queue tick in the machine.
// transition.
QueueTick uint64
// TODO QueueDebug with all string entries for comparison
// MutQueueToken is the token of a prepended mutation, can be scheduled or
// executed, depending on IsQueued.
MutQueueToken uint64
// MutQueueTick is the assigned queue tick when the tx will be executed.
// Only for IsQueued.
MutQueueTick uint64
// mutation type
Type am.MutationType
// called states
// TODO remove. Deprecated use CalledStateNames(index)
CalledStates []string
// TODO rename to CalledStates, re-gen all assets
CalledStatesIdxs []int
// all the transition steps
Steps []*am.Step
// log entries created during the transition
LogEntries []*am.LogEntry
// log entries before the transition, which happened after the prev one
PreLogEntries []*am.LogEntry
// queue length at the start of the transition
// TODO rename to QueueLen
// TODO change to int32
Queue int
// Time is human time. Don't send this over the wire.
// TODO remove or skip in msgpack
// TODO rename to HTime
Time *time.Time
// transition was triggered by an auto state
IsAuto bool
// result of the transition
// TODO rename to IsAccepted
Accepted bool
// is this a check (Can*) tx or mutation?
IsCheck bool
// is this a queued mutation?
IsQueued bool
Args map[string]string
QueueDump []string
}
DbgMsgTx contains transition data.
func (*DbgMsgTx) ActiveStates ¶ added in v0.8.0
func (*DbgMsgTx) CalledStateNames ¶ added in v0.8.0
type DbgTracer ¶ added in v0.7.0
type DbgTracer struct {
*am.NoOpTracer
Addr string
Mach am.Api
// contains filtered or unexported fields
}
func (*DbgTracer) MachineDispose ¶ added in v0.8.0
func (*DbgTracer) MachineInit ¶ added in v0.8.0
func (*DbgTracer) MutationQueued ¶ added in v0.15.0
func (*DbgTracer) SchemaChange ¶ added in v0.11.0
func (*DbgTracer) TransitionEnd ¶ added in v0.7.0
func (t *DbgTracer) TransitionEnd(tx *am.Transition)
type OtelMachTracer ¶ added in v0.5.0
type OtelMachTracer struct {
*am.NoOpTracer
Tracer trace.Tracer
Machines map[string]*OtelMachineData
MachinesMx sync.Mutex
MachinesOrder []string
RootSpan trace.Span
// TODO bind to env var
Logf func(format string, args ...any)
NextIndex int
// contains filtered or unexported fields
}
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.
func NewOtelMachTracer ¶ added in v0.5.0
func NewOtelMachTracer( rootMach am.Api, rootSpan trace.Span, otelTracer trace.Tracer, opts *OtelMachTracerOpts, ) *OtelMachTracer
NewOtelMachTracer creates a new machine tracer from an OpenTelemetry tracer. Requires OtelMachTracer.Dispose to be called at the end.
func (*OtelMachTracer) End ¶ added in v0.5.0
func (mt *OtelMachTracer) End()
func (*OtelMachTracer) HandlerEnd ¶ added in v0.5.0
func (mt *OtelMachTracer) HandlerEnd( tx *am.Transition, emitter string, handler string, )
func (*OtelMachTracer) MachineDispose ¶ added in v0.5.0
func (mt *OtelMachTracer) MachineDispose(id string)
func (*OtelMachTracer) MachineInit ¶ added in v0.5.0
func (mt *OtelMachTracer) MachineInit(mach am.Api) context.Context
func (*OtelMachTracer) NewSubmachine ¶ added in v0.5.0
func (mt *OtelMachTracer) NewSubmachine(parent, mach am.Api)
NewSubmachine links 2 machines with a parent-child relationship.
func (*OtelMachTracer) QueueEnd ¶ added in v0.6.0
func (mt *OtelMachTracer) QueueEnd(mach am.Api)
func (*OtelMachTracer) TransitionEnd ¶ added in v0.5.0
func (mt *OtelMachTracer) TransitionEnd(tx *am.Transition)
func (*OtelMachTracer) TransitionInit ¶ added in v0.5.0
func (mt *OtelMachTracer) TransitionInit(tx *am.Transition)
type OtelMachTracerOpts ¶ added in v0.5.0
type OtelMachTracerOpts struct {
// if true, only state changes will be traced
SkipTransitions bool
// if true, only Healthcheck and Heartbeat will be skipped
IncludeHealth bool
// if true, transition traces won't include [am.Machine.GetLogArgs]
SkipLogArgs bool
// if true, auto transitions won't be traced
SkipAuto bool
// TODO
WhitelistStates am.S
// TODO
BlacklistStates am.S
Logf func(format string, args ...any)
}
type OtelMachineData ¶ added in v0.5.0
type OtelTxHist ¶ added in v0.11.0
Directories
¶
| Path | Synopsis |
|---|---|
|
Package prometheus provides Prometheus metrics for asyncmachine.
|
Package prometheus provides Prometheus metrics for asyncmachine. |