Documentation ¶
Index ¶
- Constants
- Variables
- func Extract(ctx context.Context, p propagation.TextMapPropagator, metadata *metadata.MD) (baggage.Baggage, sdktrace.SpanContext)
- func Inject(ctx context.Context, p propagation.TextMapPropagator, metadata *metadata.MD)
- func NewTransport(base http.RoundTripper, opts ...otelhttp.Option) http.RoundTripper
- func RequestFilter(req *http.Request) bool
- func SetOperationAttributes(ctx context.Context)
- func SpanNameFormatter(_operation string, r *http.Request) string
- func StartAgent(log *zap.Logger, c Config) (*sdktrace.TracerProvider, error)
- func TracerFromContext(ctx context.Context) (tracer trace.Tracer)
- func WrapHandler(wrappedHandler http.Handler, componentName attribute.KeyValue, ...) http.Handler
- type Config
Constants ¶
const ( WgOperationName = attribute.Key("wg.operation.name") WgOperationType = attribute.Key("wg.operation.type") WgComponentName = attribute.Key("wg.component.name") )
const TraceName = "wundergraph"
TraceName represents the tracing name.
Variables ¶
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") )
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 ¶
func Extract(ctx context.Context, p propagation.TextMapPropagator, metadata *metadata.MD) ( baggage.Baggage, sdktrace.SpanContext)
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 SetOperationAttributes ¶
func SpanNameFormatter ¶
SpanNameFormatter formats the span name based on the http request
func StartAgent ¶
StartAgent starts an opentelemetry agent.
func TracerFromContext ¶
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.