diff --git a/RELEASES.md b/RELEASES.md index 32c52e936..38126aa83 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -423,6 +423,9 @@ The deprecated properties in [`config.toml`](./docs/cri/config.md) are shown in |`[plugins."io.containerd.grpc.v1.cri".registry]` | `auths` | containerd v1.3 | containerd v2.0 | Use [`ImagePullSecrets`](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/). See also [#8228](https://github.com/containerd/containerd/issues/8228). | |`[plugins."io.containerd.grpc.v1.cri".registry]` | `configs` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) | |`[plugins."io.containerd.grpc.v1.cri".registry]` | `mirrors` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) | +|`[plugins."io.containerd.tracing.processor.v1.otlp"]` | `endpoint`, `protocol`, `insecure` | containerd v1.6.29 | containerd v2.0 | Use [OTLP environment variables](https://opentelemetry.io/docs/specs/otel/protocol/exporter/), e.g. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_SDK_DISABLED | +|`[plugins."io.containerd.internal.v1.tracing"]` | `service_name`, `sampling_ratio` | containerd v1.6.29 | containerd v2.0 | Instead use [OTel environment variables](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/), e.g. OTEL_SERVICE_NAME, OTEL_TRACES_SAMPLER* | + > **Note** > diff --git a/pkg/deprecation/deprecation.go b/pkg/deprecation/deprecation.go index 9b85e2d0b..c9f264d7e 100644 --- a/pkg/deprecation/deprecation.go +++ b/pkg/deprecation/deprecation.go @@ -31,6 +31,10 @@ const ( CRIRegistryAuths Warning = Prefix + "cri-registry-auths" // CRIRegistryConfigs is a warning for the use of the `configs` property CRIRegistryConfigs Warning = Prefix + "cri-registry-configs" + // OTLPTracingConfig is a warning for the use of the `otlp` property + TracingOTLPConfig Warning = Prefix + "tracing-processor-config" + // TracingServiceConfig is a warning for the use of the `tracing` property + TracingServiceConfig Warning = Prefix + "tracing-service-config" ) var messages = map[Warning]string{ @@ -43,6 +47,11 @@ var messages = map[Warning]string{ "Use `ImagePullSecrets` instead.", CRIRegistryConfigs: "The `configs` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0." + "Use `config_path` instead.", + + TracingOTLPConfig: "The `otlp` property of `[plugins.\"io.containerd.tracing.processor.v1\".otlp]` is deprecated since containerd v1.6 and will be removed in containerd v2.0." + + "Use OTLP environment variables instead: https://opentelemetry.io/docs/specs/otel/protocol/exporter/", + TracingServiceConfig: "The `tracing` property of `[plugins.\"io.containerd.internal.v1\".tracing]` is deprecated since containerd v1.6 and will be removed in containerd v2.0." + + "Use OTEL environment variables instead: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/", } // Valid checks whether a given Warning is valid diff --git a/pkg/tracing/plugin/otlp.go b/pkg/tracing/plugin/otlp.go index 489233a7c..60a03a0ec 100644 --- a/pkg/tracing/plugin/otlp.go +++ b/pkg/tracing/plugin/otlp.go @@ -24,8 +24,10 @@ import ( "net/url" "time" + "github.com/containerd/containerd/v2/pkg/deprecation" "github.com/containerd/containerd/v2/pkg/tracing" "github.com/containerd/containerd/v2/plugins" + "github.com/containerd/containerd/v2/plugins/services/warning" "github.com/containerd/errdefs" "github.com/containerd/plugin" "github.com/containerd/plugin/registry" @@ -48,6 +50,9 @@ func init() { Type: plugins.TracingProcessorPlugin, Config: &OTLPConfig{}, InitFn: func(ic *plugin.InitContext) (interface{}, error) { + if err := warnOTLPConfig(ic); err != nil { + return nil, err + } cfg := ic.Config.(*OTLPConfig) exp, err := newExporter(ic.Context, cfg) if err != nil { @@ -67,6 +72,9 @@ func init() { TraceSamplingRatio: 1.0, }, InitFn: func(ic *plugin.InitContext) (interface{}, error) { + if err := warnTraceConfig(ic); err != nil { + return nil, err + } // get TracingProcessorPlugin which is a dependency plugins, err := ic.GetByType(plugins.TracingProcessorPlugin) if err != nil { @@ -191,3 +199,54 @@ func newTracer(ctx context.Context, config *TraceConfig, procs []trace.SpanProce func propagators() propagation.TextMapPropagator { return propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}) } + +func warnTraceConfig(ic *plugin.InitContext) error { + ctx := ic.Context + cfg := ic.Config.(*TraceConfig) + var warn bool + if cfg.ServiceName != "" { + warn = true + } + if cfg.TraceSamplingRatio != 0 { + warn = true + } + + if !warn { + return nil + } + + wp, err := ic.GetSingle(plugins.WarningPlugin) + if err != nil { + return err + } + ws := wp.(warning.Service) + ws.Emit(ctx, deprecation.TracingServiceConfig) + return nil +} + +func warnOTLPConfig(ic *plugin.InitContext) error { + ctx := ic.Context + cfg := ic.Config.(*OTLPConfig) + var warn bool + if cfg.Endpoint != "" { + warn = true + } + if cfg.Protocol != "" { + warn = true + } + if cfg.Insecure { + warn = true + } + + if !warn { + return nil + } + + wp, err := ic.GetSingle(plugins.WarningPlugin) + if err != nil { + return err + } + ws := wp.(warning.Service) + ws.Emit(ctx, deprecation.TracingOTLPConfig) + return nil +}