trace

package
v0.179.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WgOperationName = attribute.Key("wg.operation.name")
	WgOperationType = attribute.Key("wg.operation.type")
	WgComponentName = attribute.Key("wg.component.name")
)
View Source
const TraceName = "wundergraph"

TraceName represents the tracing name.

Variables

View Source
var (
	PublicServerAttribute     = WgComponentName.String("public-server")
	InternalServerAttribute   = WgComponentName.String("internal-server")
	ApiTransportAttribute     = WgComponentName.String("api-transport")
	HooksClientAttribute      = WgComponentName.String("hooks-client")
	WebhookTransportAttribute = WgComponentName.String("webhook-transport")
)
View Source
var TraceIdKey = http.CanonicalHeaderKey("x-trace-id")

TraceIdKey is the trace id header. https://www.w3.org/TR/trace-context/#trace-id May change it to trace-id afterwards.

Functions

func Extract

Extract extracts the metadata from ctx.

func Inject

func Inject(ctx context.Context, p propagation.TextMapPropagator, metadata *metadata.MD)

Inject injects cross-cutting concerns from the ctx into the metadata.

func NewTransport

func NewTransport(base http.RoundTripper, opts ...otelhttp.Option) http.RoundTripper

NewTransport wraps the provided http.RoundTripper with one that enriches the span with the operation name and type and set the span status Internally it uses otelhttp.NewTransport to instrument the request

func RequestFilter

func RequestFilter(req *http.Request) bool

func SetOperationAttributes

func SetOperationAttributes(ctx context.Context)

func SpanNameFormatter

func SpanNameFormatter(_operation string, r *http.Request) string

SpanNameFormatter formats the span name based on the http request

func StartAgent

func StartAgent(log *zap.Logger, c Config) (*sdktrace.TracerProvider, error)

StartAgent starts an opentelemetry agent.

func TracerFromContext

func TracerFromContext(ctx context.Context) (tracer trace.Tracer)

TracerFromContext returns a tracer in ctx, otherwise returns a global tracer.

func WrapHandler

func WrapHandler(wrappedHandler http.Handler, componentName attribute.KeyValue, opts ...otelhttp.Option) http.Handler

WrapHandler wraps a http.Handler and instruments it using the given operation name. Internally it uses otelhttp.NewHandler and set the span status based on the http response status code.

Types

type Config

type Config struct {
	Name         string
	Endpoint     string
	Sampler      float64
	Batcher      string
	BatchTimeout time.Duration
	// OtlpHeaders represents the headers for HTTP transport.
	// For example:
	//  Authorization: 'Bearer <token>'
	OtlpHeaders map[string]string
	// OtlpHttpPath represents the path for OTLP HTTP transport.
	// For example
	// /v1/traces
	OtlpHttpPath string
}

A Config is an opentelemetry config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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