Introduce trace verbosity config and produce less spans by default
This commit is contained in:
parent
77ef7fe490
commit
8c23eb6833
93 changed files with 1005 additions and 524 deletions
|
|
@ -18,7 +18,6 @@ import (
|
|||
"github.com/traefik/traefik/v3/pkg/middlewares/observability"
|
||||
"github.com/traefik/traefik/v3/pkg/middlewares/retry"
|
||||
traefiktls "github.com/traefik/traefik/v3/pkg/tls"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
|
|
@ -93,33 +92,45 @@ func NewServiceMiddleware(ctx context.Context, next http.Handler, registry metri
|
|||
}
|
||||
}
|
||||
|
||||
// WrapEntryPointHandler Wraps metrics entrypoint to alice.Constructor.
|
||||
func WrapEntryPointHandler(ctx context.Context, registry metrics.Registry, entryPointName string) alice.Constructor {
|
||||
// EntryPointMetricsHandler returns the metrics entrypoint handler.
|
||||
func EntryPointMetricsHandler(ctx context.Context, registry metrics.Registry, entryPointName string) alice.Constructor {
|
||||
return func(next http.Handler) (http.Handler, error) {
|
||||
if registry == nil || !registry.IsEpEnabled() {
|
||||
return next, nil
|
||||
}
|
||||
|
||||
return NewEntryPointMiddleware(ctx, next, registry, entryPointName), nil
|
||||
}
|
||||
}
|
||||
|
||||
// WrapRouterHandler Wraps metrics router to alice.Constructor.
|
||||
func WrapRouterHandler(ctx context.Context, registry metrics.Registry, routerName string, serviceName string) alice.Constructor {
|
||||
// RouterMetricsHandler returns the metrics router handler.
|
||||
func RouterMetricsHandler(ctx context.Context, registry metrics.Registry, routerName string, serviceName string) alice.Constructor {
|
||||
return func(next http.Handler) (http.Handler, error) {
|
||||
if registry == nil || !registry.IsRouterEnabled() {
|
||||
return next, nil
|
||||
}
|
||||
|
||||
return NewRouterMiddleware(ctx, next, registry, routerName, serviceName), nil
|
||||
}
|
||||
}
|
||||
|
||||
// WrapServiceHandler Wraps metrics service to alice.Constructor.
|
||||
func WrapServiceHandler(ctx context.Context, registry metrics.Registry, serviceName string) alice.Constructor {
|
||||
// ServiceMetricsHandler returns the metrics service handler.
|
||||
func ServiceMetricsHandler(ctx context.Context, registry metrics.Registry, serviceName string) alice.Constructor {
|
||||
return func(next http.Handler) (http.Handler, error) {
|
||||
if registry == nil || !registry.IsSvcEnabled() {
|
||||
return next, nil
|
||||
}
|
||||
|
||||
return NewServiceMiddleware(ctx, next, registry, serviceName), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metricsMiddleware) GetTracingInformation() (string, string, trace.SpanKind) {
|
||||
return m.name, typeName, trace.SpanKindInternal
|
||||
func (m *metricsMiddleware) GetTracingInformation() (string, string) {
|
||||
return m.name, typeName
|
||||
}
|
||||
|
||||
func (m *metricsMiddleware) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
if val := req.Context().Value(observability.DisableMetricsKey); val != nil {
|
||||
if !observability.MetricsEnabled(req.Context()) {
|
||||
m.next.ServeHTTP(rw, req)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue