Documentation
¶
Index ¶
- func Middleware(serverName string, opts ...Option) func(next http.Handler) http.Handler
- type Option
- func WithChiRoutes(routes chi.Routes) Option
- func WithFilter(filter func(r *http.Request) bool) Option
- func WithPropagators(propagators propagation.TextMapPropagator) Option
- func WithRequestMethodInSpanName(isActive bool) Option
- func WithSpanCustomizer(customizer func(r *http.Request, span oteltrace.Span) oteltrace.Span) Option
- func WithTracerProvider(provider oteltrace.TracerProvider) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option specifies instrumentation configuration options.
func WithChiRoutes ¶
func WithChiRoutes(routes chi.Routes) Option
WithChiRoutes specified the routes that being used by application. Its main purpose is to provide route pattern as span name during span creation. If this option is not set, by default the span will be given name at the end of span execution. For some people, this behavior is not desirable since they want to override the span name on underlying handler. By setting this option, it is possible for them to override the span name.
func WithFilter ¶
WithFilter is used for filtering request that should not be traced. This is useful for filtering health check request, etc. A Filter must return true if the request should be traced.
func WithPropagators ¶
func WithPropagators(propagators propagation.TextMapPropagator) Option
WithPropagators specifies propagators to use for extracting information from the HTTP requests. If none are specified, global ones will be used.
func WithRequestMethodInSpanName ¶
WithRequestMethodInSpanName is used for adding http request method to span name. While this is not necessary for vendors that properly implemented the tracing specs (e.g Jaeger, AWS X-Ray, etc...), but for other vendors such as Elastic and New Relic this might be helpful.
See following threads for details:
- https://github.com/shah-pf/otelchi/pull/3#issuecomment-1005883910 - https://github.com/shah-pf/otelchi/issues/6#issuecomment-1034461912
func WithSpanCustomizer ¶
func WithSpanCustomizer(customizer func(r *http.Request, span oteltrace.Span) oteltrace.Span) Option
WithSpanCustomizer is used for customizing span and it's attributes based on custom logic. This is useful for adding additional attributes to the span A SpanCustomizer must return instance of the customized span
func WithTracerProvider ¶
func WithTracerProvider(provider oteltrace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.