From b3895271075d7fc767e90e2f8193145ab441df81 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Fri, 26 Apr 2024 15:54:09 +0200 Subject: [PATCH] filters: deprecate OpenTracing in FilterContext (#3044) Deprecate OpenTracing FilterContext getters and remove their usage from filters. For #2104 Signed-off-by: Alexander Yastrebov --- filters/filters.go | 7 +++++++ filters/openpolicyagent/openpolicyagent.go | 2 +- proxy/context.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/filters/filters.go b/filters/filters.go index ac8e06d3bd..d3e060e826 100644 --- a/filters/filters.go +++ b/filters/filters.go @@ -108,9 +108,16 @@ type FilterContext interface { Metrics() Metrics // Allow filters to add Tags, Baggage to the trace or set the ComponentName. + // + // Deprecated: OpenTracing is deprecated, see https://github.com/zalando/skipper/issues/2104. + // Use opentracing.SpanFromContext(ctx.Request().Context()).Tracer() to get the proxy span Tracer. Tracer() opentracing.Tracer // Allow filters to create their own spans + // + // Deprecated: OpenTracing is deprecated, see https://github.com/zalando/skipper/issues/2104. + // Filter spans should be children of the proxy span, + // use opentracing.SpanFromContext(ctx.Request().Context()) to get the proxy span. ParentSpan() opentracing.Span // Returns a clone of the FilterContext including a brand new request object. diff --git a/filters/openpolicyagent/openpolicyagent.go b/filters/openpolicyagent/openpolicyagent.go index ad1c6e4f19..a21c4477d8 100644 --- a/filters/openpolicyagent/openpolicyagent.go +++ b/filters/openpolicyagent/openpolicyagent.go @@ -625,7 +625,7 @@ func (opa *OpenPolicyAgentInstance) startSpanFromContextWithTracer(tr opentracin } func (opa *OpenPolicyAgentInstance) StartSpanFromFilterContext(fc filters.FilterContext) (opentracing.Span, context.Context) { - return opa.startSpanFromContextWithTracer(fc.Tracer(), fc.ParentSpan(), fc.Request().Context()) + return opa.StartSpanFromContext(fc.Request().Context()) } func (opa *OpenPolicyAgentInstance) StartSpanFromContext(ctx context.Context) (opentracing.Span, context.Context) { diff --git a/proxy/context.go b/proxy/context.go index 468dc4ac98..f65757a426 100644 --- a/proxy/context.go +++ b/proxy/context.go @@ -296,7 +296,7 @@ func (c *context) Split() (filters.FilterContext, error) { } func (c *context) Loopback() { - loopSpan := c.Tracer().StartSpan(c.proxy.tracing.initialOperationName, opentracing.ChildOf(c.ParentSpan().Context())) + loopSpan := c.tracer.StartSpan(c.proxy.tracing.initialOperationName, opentracing.ChildOf(c.parentSpan.Context())) defer loopSpan.Finish() err := c.proxy.do(c, loopSpan) if c.response != nil && c.response.Body != nil {