Documentation ¶
Index ¶
- Constants
- func AddOtelKeyValueInt64(kvs ...*common.KeyValue) *common.KeyValue
- func GetOtelAttrFromSpan(attr string, span *trace.Span) (int, *common.KeyValue)
- func NewOtelKeyValueInt64(key string, value int64) *common.KeyValue
- func NewOtelKeyValueString(key string, value string) *common.KeyValue
- func NewOtelSpan(traceId string, parentId []byte, name string, start, end time.Time) *trace.Span
- type Adapter
- type AdapterBase
- func (b *AdapterBase) HandleTraceEvent(te TraceEvent)
- func (b *AdapterBase) MakeOtelCallSpans(event CallEvent, parentId []byte, traceId string) []*trace.Span
- func (a *AdapterBase) NewTraceCtx(ctx context.Context, r wazero.Runtime, wasm []byte, opts *Options) (*TraceCtx, error)
- func (b *AdapterBase) SetFlusher(f Flusher)
- func (b *AdapterBase) Start(ctx context.Context, a Adapter)
- func (b *AdapterBase) Stop(wait bool)
- type CallEvent
- type CustomEvent
- type Event
- type EventBucket
- type EventKind
- type Flusher
- type LogEvent
- type LogLevel
- type MemoryGrowEvent
- type MetricEvent
- type MetricFormat
- type Options
- type OtelTrace
- type RawEvent
- type RawEventKind
- type SpanFilter
- type SpanTagsEvent
- type TelemetryId
- type TraceCtx
- func (t *TraceCtx) Abort(context.Context, api.Module, api.FunctionDefinition, error)
- func (t *TraceCtx) After(context.Context, api.Module, api.FunctionDefinition, []uint64)
- func (t *TraceCtx) Before(ctx context.Context, _ api.Module, def api.FunctionDefinition, inputs []uint64, ...)
- func (t *TraceCtx) Finish()
- func (t *TraceCtx) Metadata(metadata interface{})
- func (t *TraceCtx) NewFunctionListener(_ api.FunctionDefinition) experimental.FunctionListener
- func (t *TraceCtx) NewListener(def api.FunctionDefinition) experimental.FunctionListener
- func (t *TraceCtx) SetTraceId(id string) error
- type TraceEvent
Constants ¶
const ( Error LogLevel = 1 Warn = 2 Info = 3 Debug = 4 )
Variables ¶
This section is empty.
Functions ¶
func GetOtelAttrFromSpan ¶
Types ¶
type Adapter ¶
type Adapter interface { Start(context.Context) Stop(wait bool) HandleTraceEvent(e TraceEvent) }
The primary interface that every Adapter needs to follow Start() and Stop() can just call the implementations on AdapterBase or provide some custom logic. HandleTraceEvent is called after an invocation of a wasm module is done and all events are collected.
type AdapterBase ¶
type AdapterBase struct { TraceEvents chan TraceEvent // contains filtered or unexported fields }
Shared implementation for all Adapters
func NewAdapterBase ¶
func NewAdapterBase(batchSize int, flushPeriod time.Duration) AdapterBase
func (*AdapterBase) HandleTraceEvent ¶
func (b *AdapterBase) HandleTraceEvent(te TraceEvent)
func (*AdapterBase) MakeOtelCallSpans ¶
func (b *AdapterBase) MakeOtelCallSpans(event CallEvent, parentId []byte, traceId string) []*trace.Span
MakeOtelCallSpans recursively constructs call spans in open telemetry format
func (*AdapterBase) NewTraceCtx ¶
func (*AdapterBase) SetFlusher ¶
func (b *AdapterBase) SetFlusher(f Flusher)
func (*AdapterBase) Stop ¶
func (b *AdapterBase) Stop(wait bool)
Stops the adapter and waits for all flushes to complete. Set wait parameter to false if you don't want to wait
type CallEvent ¶
type CallEvent struct { Raw []RawEvent Time time.Time Duration time.Duration // contains filtered or unexported fields }
func (CallEvent) FunctionIndex ¶
func (CallEvent) FunctionName ¶
type CustomEvent ¶
func NewCustomEvent ¶
func NewCustomEvent(name string) CustomEvent
func (CustomEvent) RawEvents ¶
func (e CustomEvent) RawEvents() []RawEvent
type EventBucket ¶
type EventBucket struct {
// contains filtered or unexported fields
}
EventBucket is a bucket for outgoing TraceEvents. It only schedules flushes when the bucket goes from empty to 1 item. At most the latency to flush the bucket will be flushPeriod. It will also flush the TraceEvents in batches according to batch size
func NewEventBucket ¶
func NewEventBucket(batchSize int, flushPeriod time.Duration) *EventBucket
NewEventBucket creates an EventBucket
func (*EventBucket) Wait ¶
func (b *EventBucket) Wait()
Wait will block until all pending flushes are done
type Flusher ¶
type Flusher interface {
Flush(events []TraceEvent) error
}
type MemoryGrowEvent ¶
func (MemoryGrowEvent) FunctionIndex ¶
func (e MemoryGrowEvent) FunctionIndex() uint32
func (MemoryGrowEvent) FunctionName ¶
func (e MemoryGrowEvent) FunctionName() string
func (MemoryGrowEvent) MemoryGrowAmount ¶
func (e MemoryGrowEvent) MemoryGrowAmount() uint32
func (MemoryGrowEvent) RawEvents ¶
func (e MemoryGrowEvent) RawEvents() []RawEvent
type MetricEvent ¶
type MetricEvent struct { Time time.Time Format MetricFormat Message string }
func (MetricEvent) RawEvents ¶
func (e MetricEvent) RawEvents() []RawEvent
type Options ¶
type Options struct { SpanFilter *SpanFilter ChannelBufferSize int }
Specify options to change what or how the adapter receives ObserveEvents
type OtelTrace ¶
type OtelTrace struct { TraceId string TracesData *trace.TracesData }
func NewOtelTrace ¶
func (*OtelTrace) SetMetadata ¶
func (t *OtelTrace) SetMetadata(te *TraceEvent, meta map[string]string)
type RawEvent ¶
type RawEvent struct { Kind RawEventKind Stack []experimental.InternalFunction FunctionIndex uint32 FunctionName string MemoryGrowAmount uint32 Time time.Time Duration time.Duration }
Represents the raw event in our Observe form. Events are transformed into vendor specific formats in the Adapters.
type RawEventKind ¶
type RawEventKind int
const ( RawEnter RawEventKind = iota RawExit RawMemoryGrow RawMetric RawSpanTags RawLog RawUnknownEvent )
type SpanFilter ¶
Definition of how to filter our Spans to reduce noise
type SpanTagsEvent ¶
func (SpanTagsEvent) RawEvents ¶
func (e SpanTagsEvent) RawEvents() []RawEvent
type TelemetryId ¶
type TelemetryId struct {
// contains filtered or unexported fields
}
This is a shared type for a span or trace id. It's represented by 2 uint64s and can be transformed to different string or int representations where needed.
func (*TelemetryId) FromBytes ¶
func (t *TelemetryId) FromBytes(id []byte) error
func (*TelemetryId) FromString ¶
func (t *TelemetryId) FromString(id string) error
func (TelemetryId) Lsb ¶
func (id TelemetryId) Lsb() uint64
func (TelemetryId) Msb ¶
func (id TelemetryId) Msb() uint64
func (TelemetryId) ToHex16 ¶
func (t TelemetryId) ToHex16() string
Encode this id into a 16 byte hex (32 chars) Uses both 16 byte uint64 values
func (TelemetryId) ToHex8 ¶
func (t TelemetryId) ToHex8() string
Encode this id into an 8 byte hex (16 chars) Just uses the least significant of the 16 bytes
func (TelemetryId) ToUint64 ¶
func (t TelemetryId) ToUint64() uint64
Some adapters may need a raw representation
type TraceCtx ¶
type TraceCtx struct { Options *Options // contains filtered or unexported fields }
TraceCtx holds the context for a trace, or wasm module invocation. It collects holds a channel to the Adapter and from the wazero Listener It will collect events throughout the invocation of the function. Calling Finish() will then submit those events to the Adapter to be processed and sent
func (*TraceCtx) Abort ¶
Null implementation of the Abort() method to satisfy the FunctionListener interface.
func (*TraceCtx) After ¶
Null implementation of the After() method to satisfy the FunctionListener interface.
func (*TraceCtx) Before ¶
func (t *TraceCtx) Before(ctx context.Context, _ api.Module, def api.FunctionDefinition, inputs []uint64, stack experimental.StackIterator)
Implements the Before() method to satisfy the FunctionListener interface. This takes events from the wazero runtime and sends them to the `raw` channel on the TraceCtx.
func (*TraceCtx) Finish ¶
func (t *TraceCtx) Finish()
Finish() will stop the trace and send the TraceEvent payload to the adapter
func (*TraceCtx) NewFunctionListener ¶
func (t *TraceCtx) NewFunctionListener(_ api.FunctionDefinition) experimental.FunctionListener
Implements the NewFunctionListener() method to satisfy the FunctionListener interface
func (*TraceCtx) NewListener ¶
func (t *TraceCtx) NewListener(def api.FunctionDefinition) experimental.FunctionListener
Implements the NewListener() method to satisfy the FunctionListener interface
func (*TraceCtx) SetTraceId ¶
type TraceEvent ¶
type TraceEvent struct { Events []Event TelemetryId TelemetryId AdapterMeta interface{} }
The payload that contains all the Events from a single wasm module invocation