Documentation ¶
Index ¶
- func CtxSpanToNatsMsgMiddleware() middleware.Send
- func CtxWithSpanToNatsMsg(ctx context.Context, msg jetstream.Msg)
- func CtxWithTraceParentFromNatsMsg(ctx context.Context, msg jetstream.Msg) context.Context
- func CtxWithTraceParentFromNatsMsgMiddleware() middleware.Receive
- func CtxWithTraceParentToWfState(ctx context.Context, state *model.WorkflowState)
- func GetTraceparentTraceAndSpan(traceparent string) (string, string)
- func NatsMsgToCtxWithSpan(ctx context.Context, msg jetstream.Msg) context.Context
- func NatsMsgToCtxWithSpanMiddleware() middleware.Receive
- func NewTraceID() [16]byte
- func NewTraceParent(traceID [16]byte, spanID [8]byte) string
- func NewTraceParentWithEmptySpan(traceID [16]byte) string
- func SetTraceParentSpanID(traceparent string, spanID string) string
- func StartApiSpan(ctx context.Context, tracerName string, apiName string) (context.Context, trace.Span)
- func TraceIDFromTraceparent(traceparent string) (trace.TraceID, error)
- type Config
- type JetStreamCarrier
- type MapCarrier
- type NatsCarrier
- type PropagateOption
- type TraceParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxSpanToNatsMsgMiddleware ¶
func CtxSpanToNatsMsgMiddleware() middleware.Send
CtxSpanToNatsMsgMiddleware returns a middleware function which attaches telemetry to outgoing messages.
func CtxWithSpanToNatsMsg ¶
CtxWithSpanToNatsMsg injects traceID and spanID into a NATS message based on the provided context.
func CtxWithTraceParentFromNatsMsg ¶
CtxWithTraceParentFromNatsMsg injects the traceparent value from a NATS message into the provided context. If the traceparent value is present in the message header, it is set as the value for the ctxkey.Traceparent key in the context. If the traceparent value is not present, a new traceparent value is generated with an empty spanID and set as the value for the ctxkey.Traceparent key in the context.
func CtxWithTraceParentFromNatsMsgMiddleware ¶
func CtxWithTraceParentFromNatsMsgMiddleware() middleware.Receive
CtxWithTraceParentFromNatsMsgMiddleware is a middleware function that wraps the receive function in order to inject traceparent into the context based on the NATS message. The receive function should have the signature func(ctx context.Context, msg *nats.Msg) (context.Context, error).
func CtxWithTraceParentToWfState ¶
func CtxWithTraceParentToWfState(ctx context.Context, state *model.WorkflowState)
CtxWithTraceParentToWfState injects the traceparent from the context into a WorkflowState. If telemetry is enabled in the configuration, the traceID and spanID will be extracted from the context and assigned to the TraceParent field of the WorkflowState object.
func GetTraceparentTraceAndSpan ¶
GetTraceparentTraceAndSpan returns a trace and span from a W3C traceparent
func NatsMsgToCtxWithSpan ¶
NatsMsgToCtxWithSpan injects traceID and spanID into a context based on the provided NATS message.
func NatsMsgToCtxWithSpanMiddleware ¶
func NatsMsgToCtxWithSpanMiddleware() middleware.Receive
NatsMsgToCtxWithSpanMiddleware returns a middleware function which extracts telemetry from incoming messages.
func NewTraceID ¶
func NewTraceID() [16]byte
NewTraceID generates a new W3C trace ID with 16 bytes of random data.
func NewTraceParent ¶
NewTraceParent returns a new W3C traceparent string using the provided traceID and spanID.
func NewTraceParentWithEmptySpan ¶
NewTraceParentWithEmptySpan generates a traceparent string based on the provided trace ID. The spanID is left as a dummy value. The traceparent format follows the W3C Trace Context specification (https://www.w3.org/TR/trace-context/). Format: 00-{traceID}-{spanID}-00
func SetTraceParentSpanID ¶
SetTraceParentSpanID sets the span portion of a W3C traceparent and returns a new W3C traceparent
func StartApiSpan ¶
func StartApiSpan(ctx context.Context, tracerName string, apiName string) (context.Context, trace.Span)
StartApiSpan starts a new API span with the provided tracer name and API name. It takes a context, tracer name, and API name as input parameters. The function extracts the trace and span IDs from the provided traceparent string. If the trace ID is invalid, it starts a new root span with the tracer name and API name using the OpenTelemetry Tracer Provider. If the span ID is empty, it starts a new root span and updates the traceparent string with the new span ID. Otherwise, it creates a new SpanContext with the extracted trace and span IDs and updates the context with the remote span context. Finally, it starts a new span with the updated context, tracer name, and API name using the OpenTelemetry Tracer Provider. The function returns the updated context and the started span.
Types ¶
type JetStreamCarrier ¶ added in v1.1.927
type JetStreamCarrier struct {
// contains filtered or unexported fields
}
JetStreamCarrier defines an open telemetry carrier that serialises to NATS headers
func NewJetStreamCarrier ¶ added in v1.1.927
func NewJetStreamCarrier(msg jetstream.Msg) *JetStreamCarrier
NewJetStreamCarrier creates a new instance of NatsCarrier
func (*JetStreamCarrier) Get ¶ added in v1.1.927
func (c *JetStreamCarrier) Get(key string) string
Get a header value
func (*JetStreamCarrier) Keys ¶ added in v1.1.927
func (c *JetStreamCarrier) Keys() []string
Keys - returns all header keys
func (*JetStreamCarrier) Set ¶ added in v1.1.927
func (c *JetStreamCarrier) Set(key string, value string)
Set a header value
type MapCarrier ¶
MapCarrier defines an open telemetry carrier that serialises to a go map[string]string
func NewMapCarrier ¶
func NewMapCarrier() *MapCarrier
NewMapCarrier creates a new instance of MapCarrier
type NatsCarrier ¶
type NatsCarrier struct {
// contains filtered or unexported fields
}
NatsCarrier defines an open telemetry carrier that serialises to NATS headers
type PropagateOption ¶
type PropagateOption func(*propagateOptions)
PropagateOption is the prototype for the propagate option function
func WithNewDefaultTraceId ¶
func WithNewDefaultTraceId() PropagateOption
WithNewDefaultTraceId returns a PropagateOption function that sets the default trace ID to a newly generated trace ID.
type TraceParams ¶
type TraceParams struct {
TraceParent string
}
TraceParams represents parameters related to tracing