trace

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey = "x-trace-id"
	SpanIDKey  = "x-span-id"
)

Variables

This section is empty.

Functions

func ConstructNewSpanContext

func ConstructNewSpanContext(ctx context.Context) trace.SpanContext

ConstructNewSpanContext helper function to inject in open telemetry refid from context

func GenerateSpanIDRaw

func GenerateSpanIDRaw() []byte

func GenerateSpanIDString

func GenerateSpanIDString() string

func GenerateTraceIDRaw

func GenerateTraceIDRaw() []byte

func GenerateTraceIDString

func GenerateTraceIDString() string

func HTTPMiddleware

func HTTPMiddleware(next http.Handler) http.Handler

HTTPMiddleware Assume that spanID and TraceID already in ctx Example:

h := refid.HTTPMiddleware(tracing.HTTPMiddleware(otelhttp.NewHandler(s.newRouter(), "app-test",
	otelhttp.WithTracerProvider(otel.GetTracerProvider()),
	otelhttp.WithPropagators(propagation.TraceContext{}),
)))

func Module

func Module(serviceName string) fx.Option

func NewGRPCClient

func NewGRPCClient(collectorURI string, options ...otlptracegrpc.Option) otlptrace.Client

NewGRPCClient create new open telemetry tracing grpc client

func NewGlobalTracerProvider

func NewGlobalTracerProvider(
	serviceName string,
	spanExporter sdk.SpanExporter,
	providerOpts ...sdk.TracerProviderOption,
)

func NewHTTPClient

func NewHTTPClient(collectorURI string, options ...otlptracehttp.Option) otlptrace.Client

NewHTTPClient create new open telemetry tracing http client

func NewTraceSpanExporter

func NewTraceSpanExporter(ctx context.Context, client otlptrace.Client) (tracesdk.SpanExporter, error)

Types

type SpanID

type SpanID struct {
}

func (*SpanID) Generate

func (t *SpanID) Generate() any

func (*SpanID) IsValid

func (t *SpanID) IsValid(v any) bool

type TraceID

type TraceID struct {
}

func (*TraceID) Generate

func (t *TraceID) Generate() any

func (*TraceID) IsValid

func (t *TraceID) IsValid(v any) bool

Jump to

Keyboard shortcuts

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