Documentation
¶
Index ¶
- Constants
- func Apply[T any](ops []SetOption[T], o *Options[T])
- func ElapsedTime(startTime time.Time) float64
- func Version() string
- type CmdMetricAttributesFn
- type Hooks
- func (h *Hooks[T]) BeforeSend(ctx context.Context, cmd core.Cmd[T]) (context.Context, error)
- func (h *Hooks[T]) OnError(ctx context.Context, sentCmd hooks.SentCmd[T], err error)
- func (h *Hooks[T]) OnResult(ctx context.Context, sentCmd hooks.SentCmd[T], recvResult hooks.ReceivedResult, ...)
- func (h *Hooks[T]) OnTimeout(ctx context.Context, sentCmd hooks.SentCmd[T], err error)
- type HooksFactory
- type Invoker
- type Options
- func (o Options[T]) CmdMetricAttributes(sentCmd hooks.SentCmd[T], status semconv.CmdStreamCommandStatus, ...) (attrs []attribute.KeyValue)
- func (o Options[T]) ResultMetricAttributes(sentCmd hooks.SentCmd[T], recvResult hooks.ReceivedResult, elapsedTime float64) (attrs []attribute.KeyValue)
- func (o Options[T]) SpanAttributes(peerAddr net.Addr, sentCmd hooks.SentCmd[T]) (attrs []attribute.KeyValue)
- func (o Options[T]) SpanResultEventAttributes(sentCmd hooks.SentCmd[T], recvResult hooks.ReceivedResult) (attrs []attribute.KeyValue)
- type Proxy
- type ProxyCallbackFn
- type ResultMetricAttributesFn
- type SetOption
- func WithCmdMetricAttributesFn[T any](fn CmdMetricAttributesFn[T]) SetOption[T]
- func WithMeterProvider[T any](mp metric.MeterProvider) SetOption[T]
- func WithPropagator[T any](p propagation.TextMapPropagator) SetOption[T]
- func WithResultMetricAttributesFn[T any](fn ResultMetricAttributesFn[T]) SetOption[T]
- func WithServerAddr[T any](addr net.Addr) SetOption[T]
- func WithSpanAttributesFn[T any](fn SpanAttributesFn[T]) SetOption[T]
- func WithSpanNameFormatter[T any](f SpanNameFormatterFn[T]) SetOption[T]
- func WithSpanResultEventAttributesFn[T any](fn SpanResultEventAttributesFn[T]) SetOption[T]
- func WithSpanStartOption[T any](s trace.SpanStartOption) SetOption[T]
- func WithTracerProvider[T any](tp trace.TracerProvider) SetOption[T]
- type SpanAttributesFn
- type SpanNameFormatterFn
- type SpanResultEventAttributesFn
- type TraceCmd
- func (c TraceCmd[T, V]) Carrier() (carrier map[string]string)
- func (c TraceCmd[T, V]) Exec(ctx context.Context, seq core.Seq, at time.Time, receiver T, proxy core.Proxy) error
- func (c TraceCmd[T, V]) InnerCmd() core.Cmd[T]
- func (c TraceCmd[T, V]) SetCarrier(carrier map[string]string)
- func (c TraceCmd[T, V]) TypeStr() string
Constants ¶
const ScopeName = "github.com/cmd-stream/otelcmd-stream-go"
ScopeName is the instrumentation scope name.
Variables ¶
This section is empty.
Functions ¶
func ElapsedTime ¶
Types ¶
type CmdMetricAttributesFn ¶
type Hooks ¶
type Hooks[T any] struct { // contains filtered or unexported fields }
Hooks is an implementation of the hooks.Hooks interface from the sender module. It provides OpenTelemetry-based instrumentation for the cmd-stream sender.
func (*Hooks[T]) BeforeSend ¶
type HooksFactory ¶
type HooksFactory[T any] struct { // contains filtered or unexported fields }
HooksFactory is an implementation of the hooks.HooksFactory interface from the sender module. It is responsible for creating Hooks instances configured with OpenTelemetry tracing and metrics options.
func NewHooksFactory ¶
func NewHooksFactory[T any](ops ...SetOption[T]) HooksFactory[T]
NewHooksFactory creates a new HooksFactory.
func (HooksFactory[T]) New ¶
func (f HooksFactory[T]) New() hooks.Hooks[T]
type Invoker ¶
type Invoker[T any] struct { // contains filtered or unexported fields }
Invoker is an implementation of the handler.Invoker interface from the handler module. It adds OpenTelemetry-based instrumentation for command handling on the server side.
func NewInvoker ¶
NewInvoker creates a new invoker that wraps the specified one, adding OpenTelemetry-based instrumentation.
type Options ¶
type Options[T any] struct { ServerAddr net.Addr Tracer trace.Tracer Meter metric.Meter SpanStartOptions []trace.SpanStartOption SpanNameFormatter SpanNameFormatterFn[T] Propagator propagation.TextMapPropagator TracerProvider trace.TracerProvider MeterProvider metric.MeterProvider SpanAttributesFn SpanAttributesFn[T] SpanResultEventAttributesFn SpanResultEventAttributesFn[T] CmdMetricAttributesFn CmdMetricAttributesFn[T] ResultMetricAttributesFn ResultMetricAttributesFn[T] }
func (Options[T]) CmdMetricAttributes ¶
func (o Options[T]) CmdMetricAttributes(sentCmd hooks.SentCmd[T], status semconv.CmdStreamCommandStatus, elapsedTime float64, ) (attrs []attribute.KeyValue)
CmdMetricAttributes returns metric attributes for the sent Command, given its status and elapsed time. It calls the user-provided CmdMetricAttributesFn if set; otherwise, returns nil.
func (Options[T]) ResultMetricAttributes ¶
func (o Options[T]) ResultMetricAttributes(sentCmd hooks.SentCmd[T], recvResult hooks.ReceivedResult, elapsedTime float64, ) (attrs []attribute.KeyValue)
ResultMetricAttributes returns metric attributes for the received Result, given the corresponding sent Command and elapsed time. It calls the user-provided ResultMetricAttributesFn if set; otherwise, returns nil.
func (Options[T]) SpanAttributes ¶
func (o Options[T]) SpanAttributes(peerAddr net.Addr, sentCmd hooks.SentCmd[T]) (attrs []attribute.KeyValue)
SpanAttributes returns span attributes for the given peer address and sent Command. It calls the user-provided SpanAttributesFn if set; otherwise, it returns nil.
func (Options[T]) SpanResultEventAttributes ¶
func (o Options[T]) SpanResultEventAttributes(sentCmd hooks.SentCmd[T], recvResult hooks.ReceivedResult) (attrs []attribute.KeyValue)
SpanResultEventAttributes returns span event attributes for the given sent Command and received result. It calls the user-provided SpanResultEventAttributesFn if set; otherwise, it returns nil.
type Proxy ¶
type Proxy[T any] struct { // contains filtered or unexported fields }
func NewProxy ¶
func NewProxy[T any](proxy core.Proxy, callback ProxyCallbackFn) *Proxy[T]
func (*Proxy[T]) RemoteAddr ¶
type ProxyCallbackFn ¶
type ProxyCallbackFn func(recvResult hooks.ReceivedResult)
type SetOption ¶
func WithCmdMetricAttributesFn ¶
func WithCmdMetricAttributesFn[T any](fn CmdMetricAttributesFn[T]) SetOption[T]
WithCmdMetricAttributesFn sets the function that returns Command metric attributes.
func WithMeterProvider ¶
func WithMeterProvider[T any](mp metric.MeterProvider) SetOption[T]
WithMeterProvider sets the OpenTelemetry MeterProvider.
func WithPropagator ¶
func WithPropagator[T any](p propagation.TextMapPropagator) SetOption[T]
WithPropagator sets the OpenTelemetry TextMapPropagator.
func WithResultMetricAttributesFn ¶
func WithResultMetricAttributesFn[T any](fn ResultMetricAttributesFn[T]) SetOption[T]
WithResultMetricAttributesFn sets the function that returns Result metric attributes.
func WithServerAddr ¶
WithServerAddr sets the server address.
func WithSpanAttributesFn ¶
func WithSpanAttributesFn[T any](fn SpanAttributesFn[T]) SetOption[T]
WithSpanAttributesFn sets the function that returns additional span attributes.
func WithSpanNameFormatter ¶
func WithSpanNameFormatter[T any](f SpanNameFormatterFn[T]) SetOption[T]
WithSpanNameFormatter sets the function used to format span names.
func WithSpanResultEventAttributesFn ¶
func WithSpanResultEventAttributesFn[T any]( fn SpanResultEventAttributesFn[T]) SetOption[T]
WithSpanResultEventAttributesFn sets the function that returns additional span event attributes.
func WithSpanStartOption ¶
func WithSpanStartOption[T any](s trace.SpanStartOption) SetOption[T]
WithSpanStartOption appends a SpanStartOption to be applied when starting spans.
func WithTracerProvider ¶
func WithTracerProvider[T any](tp trace.TracerProvider) SetOption[T]
WithTracerProvider sets the OpenTelemetry TracerProvider.
type SpanAttributesFn ¶
type SpanNameFormatterFn ¶
type TraceCmd ¶
TraceCmd wraps a core.Cmd and carries tracing context for propagation.
func NewTraceCmd ¶
NewTraceCmd creates a new TraceCmd.