github.com/caddyserver/caddy/v2/modules/caddyhttp/tracing
No package summary is available.
Package
Files: 3. Third party imports: 10. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Constants
Vars
globalTracerProvider stores global tracer provider and is responsible for graceful shutdown when nobody is using it.
Types
Tracing
Tracing implements an HTTP handler that adds support for distributed tracing, using OpenTelemetry. This module is responsible for the injection and propagation of the trace context. Configure this module via environment variables (see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md). Some values can be overwritten in the configuration file.
| Field name | Field type | Comment |
|---|---|---|
| SpanName |
|
SpanName is a span name. It should follow the naming guidelines here: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#span |
| otel |
|
otel implements opentelemetry related logic. |
| logger |
|
No comment on field. |
nextCall
nextCall store the next handler, and the error value return on calling it (if any)
| Field name | Field type | Comment |
|---|---|---|
| next |
|
No comment on field. |
| err |
|
No comment on field. |
openTelemetryWrapper
openTelemetryWrapper is responsible for the tracing injection, extraction and propagation.
| Field name | Field type | Comment |
|---|---|---|
| propagators |
|
No comment on field. |
| handler |
|
No comment on field. |
| spanName |
|
No comment on field. |
tracerProvider
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
| mu |
|
No comment on field. |
| tracerProvider |
|
No comment on field. |
| tracerProvidersCounter |
|
No comment on field. |
Functions
func (*Tracing) Cleanup
Cleanup implements caddy.CleanerUpper and closes any idle connections. It calls Shutdown method for a trace provider https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#shutdown.
Uses: fmt.Errorf.func (*Tracing) Provision
Provision implements caddy.Provisioner.
func (*Tracing) ServeHTTP
ServeHTTP implements caddyhttp.MiddlewareHandler.
func (*Tracing) UnmarshalCaddyfile
UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
tracing {
[span <span_name>]
}
Uses: caddyfile.Dispenser.
func (*openTelemetryWrapper) ServeHTTP
ServeHTTP propagates call to the by wrapped by otelhttp next handler.
func (Tracing) CaddyModule
CaddyModule returns the Caddy module information.
Private functions
func init
func newOpenTelemetryWrapper
newOpenTelemetryWrapper is responsible for the openTelemetryWrapper initialization using provided configuration.
References: autoprop.NewTextMapPropagator, fmt.Errorf, http.HandlerFunc, otelhttp.NewHandler, otelhttp.WithPropagators, otelhttp.WithSpanNameFormatter, otelhttp.WithTracerProvider, otlptracegrpc.New, sdktrace.WithBatcher, sdktrace.WithResource.func parseCaddyfile
func cleanup
cleanup flush all remaining data and shutdown a tracerProvider
func newResource
newResource creates a resource that describe current handler instance and merge it with a default attributes value.
References: resource.Default, resource.Merge, resource.NewSchemaless, semconv.WebEngineName, semconv.WebEngineVersion.func serveHTTP
serveHTTP injects a tracing context and call the next handler.
References: caddyhttp.ExtraLogFields, caddyhttp.ExtraLogFieldsCtxKey, caddyhttp.SetVar, propagation.HeaderCarrier, trace.SpanContextFromContext, zap.String.func spanNameFormatter
spanNameFormatter performs the replacement of placeholders in the span name
func cleanupTracerProvider
cleanupTracerProvider gracefully shutdown a TracerProvider
References: context.Background, fmt.Errorf, zap.Error, zapcore.ErrorLevel.func getTracerProvider
getTracerProvider create or return an existing global TracerProvider
References: sdktrace.NewTracerProvider.Tests
Files: 3. Third party imports: 1. Imports from organisation: 0. Tests: 8. Benchmarks: 0.