telemetry

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 13 Imported by: 2

README

Telemetry

Test duration chart
  • Open Telemetry
  • am-dbg

Open Telemetry

Otel integration exposes machine's states and transitions as Otel traces, compatible with Jaeger. Tracers are inherited from parent machines and form a tree.

Machine tree structure:

- mach:ID
  - states
    - Foo
      - Foo (trace)
      - Foo (trace)
      - ...
    - ...
  - transitions
    - [add] Foo
      - FooEnter (trace)
      - FooState (trace)
      - ...
    - ...
  - submachines
    - mach:ID2
      - ...
    - ...

See pkg/telemetry for more info or import an existing asset

am-dbg

am-dbg telemetry delivers DbgMsg and DbgMsgStruct via simple net/rpc to tools/cmd/am-dbg. It can be consumed by a custom client as well.

Documentation

Overview

Package telemetry provides telemetry exporters for asyncmachine: am-dbg, Prometheus, and OpenTelemetry.

Index

Constants

View Source
const DbgHost = "localhost:6831"

Variables

This section is empty.

Functions

func TransitionsToDBG added in v0.5.0

func TransitionsToDBG(mach *am.Machine, url string) error

TransitionsToDBG sends transitions to the am-dbg server. TODO test TransitionsToDBG TODO support changes to mach.StateNames TODO rewrite to Tracer API?

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
	States am.Struct
}

DbgMsgStruct contains the state and relations data.

func (*DbgMsgStruct) Clock added in v0.5.0

func (d *DbgMsgStruct) Clock(_ am.S, _ string) uint64

func (*DbgMsgStruct) Is added in v0.5.0

func (d *DbgMsgStruct) Is(_ am.S, _ am.S) bool

type DbgMsgTx added in v0.5.0

type DbgMsgTx struct {
	MachineID string
	// Transition ID
	ID string
	// map of positions from the index to state clocks
	Clocks am.T
	// result of the transition
	Accepted bool
	// mutation type
	Type am.MutationType
	// called states
	CalledStates []string
	// 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
	// transition was triggered by an auto state
	IsAuto bool
	// queue length at the start of the transition
	Queue int
	// don't send this over the wire
	Time *time.Time
}

DbgMsgTx contains transition data.

func (*DbgMsgTx) Clock added in v0.5.0

func (d *DbgMsgTx) Clock(statesIndex am.S, state string) uint64

func (*DbgMsgTx) Is added in v0.5.0

func (d *DbgMsgTx) Is(statesIndex am.S, states am.S) bool

func (*DbgMsgTx) Is1 added in v0.5.0

func (d *DbgMsgTx) Is1(statesIndex am.S, state string) bool

func (*DbgMsgTx) TimeSum added in v0.5.0

func (d *DbgMsgTx) TimeSum() uint64

type OtelMachTracer added in v0.5.0

type OtelMachTracer struct {
	Tracer        trace.Tracer
	Machines      map[string]*OtelMachineData
	MachinesMx    sync.Mutex
	MachinesOrder []string
	Logf          func(format string, args ...any)
	// contains filtered or unexported fields
}

OtelMachTracer implements machine.Tracer for OpenTelemetry. Support tracing multiple machines

func NewOtelMachTracer added in v0.5.0

func NewOtelMachTracer(tracer 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 (ot *OtelMachTracer) End()

func (*OtelMachTracer) HandlerEnd added in v0.5.0

func (ot *OtelMachTracer) HandlerEnd(tx *am.Transition, _ string, _ string)

func (*OtelMachTracer) HandlerStart added in v0.5.0

func (ot *OtelMachTracer) HandlerStart(
	tx *am.Transition, emitter string, handler string,
)

func (*OtelMachTracer) Inheritable added in v0.5.0

func (ot *OtelMachTracer) Inheritable() bool

func (*OtelMachTracer) MachineDispose added in v0.5.0

func (ot *OtelMachTracer) MachineDispose(id string)

func (*OtelMachTracer) MachineInit added in v0.5.0

func (ot *OtelMachTracer) MachineInit(mach *am.Machine)

func (*OtelMachTracer) NewSubmachine added in v0.5.0

func (ot *OtelMachTracer) NewSubmachine(parent, mach *am.Machine)

NewSubmachine links 2 machines with a parent-child relationship.

func (*OtelMachTracer) QueueEnd added in v0.6.0

func (ot *OtelMachTracer) QueueEnd(*am.Machine)

func (*OtelMachTracer) TransitionEnd added in v0.5.0

func (ot *OtelMachTracer) TransitionEnd(tx *am.Transition)

func (*OtelMachTracer) TransitionInit added in v0.5.0

func (ot *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
	Logf            func(format string, args ...any)
}

type OtelMachineData added in v0.5.0

type OtelMachineData struct {
	ID string
	// handler ctx & span to be used for more detailed tracing inside handlers
	HandlerTrace context.Context
	HandlerSpan  trace.Span
	Lock         sync.Mutex
	Ended        bool
	// contains filtered or unexported fields
}

Directories

Path Synopsis
Package prometheus provides Prometheus metrics for asyncmachine.
Package prometheus provides Prometheus metrics for asyncmachine.

Jump to

Keyboard shortcuts

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