Documentation
¶
Overview ¶
Package tracing is responsible for forwarding and translating span headers for internal requests
Index ¶
- Constants
- func HTTPMiddleware(h http.Handler) http.Handler
- func HeaderMatcher(key string) (string, bool)
- func LogFromContext(ctx context.Context, log logger.Logger) logger.Logger
- func New(log logger.Logger, service string, host string, zipkinEndpoint string) io.Closer
- func NewFromEnv(log logger.Logger, service string, host string, endpointVar, disableVar string) io.Closer
- func NewSpanContext(ctx context.Context, log logger.Logger, name string) (spanner.Spanner, context.Context)
- func NewSpanWithAttributes(ctx context.Context, name string, log logger.Logger, attributes map[string]any) (spanner.Spanner, context.Context)
- func NewTracer(log logger.Logger, portName string) io.Closer
- func SetSpanField(ctx context.Context, key string, value string)
- func SetSpanHTTPHeader(span opentracing.Span, log logger.Logger, r *http.Request)
- func StartSpanFromContext(ctx context.Context, log logger.Logger, name string) (spanner.Spanner, context.Context)
- func TraceIDFromContext(ctx context.Context, log logger.Logger) string
- type Span
- type Spanner
Constants ¶
const (
TraceID = prefixTracerState + "traceid"
)
Variables ¶
This section is empty.
Functions ¶
func HeaderMatcher ¶
HeaderMatcher ensures that open tracing headers x-b3-* are forwarded to output requests
func LogFromContext ¶ added in v0.27.0
LogFromContext takes the trace ID from the current span and adds it to the logger:
returns:
- the new logger with a context metadata value for traceID
This will be called on entry to a method or a function that has a context.Context.
func NewFromEnv ¶
func NewFromEnv(log logger.Logger, service string, host string, endpointVar, disableVar string) io.Closer
NewFromEnv initialises tracing and returns a closer if tracing is configured. If the necessary configuration is not available it is Fatal unless disableVar is set and is truthy (strconf.ParseBool -> true). If tracing is disabled returns nil
func NewSpanContext ¶
func NewSpanWithAttributes ¶ added in v0.28.0
func NewSpanWithAttributes(ctx context.Context, name string, log logger.Logger, attributes map[string]any) (spanner.Spanner, context.Context)
Constructors...
func NewTracer ¶
NewTracer and the following methods are only called once to create the global tracer in startup/run.go
func SetSpanField ¶ added in v0.27.0
func SetSpanHTTPHeader ¶ added in v0.27.0
func StartSpanFromContext ¶
Types ¶
type Span ¶ added in v0.28.0
type Span struct {
// contains filtered or unexported fields
}
Injecting a function StartSpanFomContext that returns an interface does not work as the Go compiler treats interfaces defined in separate packages as different even though the signature is identical. So this struct hides the interface and returns a concrete type instead. Conveniently it also hides calls to the opentracing-go package thsu making it easier to move to opentelemetry later.