Skip to content

Commit 753a525

Browse files
committed
Deprecate otel configs
Signed-off-by: Brian Goff <[email protected]>
1 parent fea1bc2 commit 753a525

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

RELEASES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ The deprecated properties in [`config.toml`](./docs/cri/config.md) are shown in
423423
|`[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). |
424424
|`[plugins."io.containerd.grpc.v1.cri".registry]` | `configs` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) |
425425
|`[plugins."io.containerd.grpc.v1.cri".registry]` | `mirrors` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) |
426+
|`[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 |
427+
|`[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* |
428+
426429

427430
> **Note**
428431
>

pkg/deprecation/deprecation.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const (
3131
CRIRegistryAuths Warning = Prefix + "cri-registry-auths"
3232
// CRIRegistryConfigs is a warning for the use of the `configs` property
3333
CRIRegistryConfigs Warning = Prefix + "cri-registry-configs"
34+
// OTLPTracingConfig is a warning for the use of the `otlp` property
35+
TracingOTLPConfig Warning = Prefix + "tracing-processor-config"
36+
// TracingServiceConfig is a warning for the use of the `tracing` property
37+
TracingServiceConfig Warning = Prefix + "tracing-service-config"
3438
)
3539

3640
var messages = map[Warning]string{
@@ -43,6 +47,11 @@ var messages = map[Warning]string{
4347
"Use `ImagePullSecrets` instead.",
4448
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." +
4549
"Use `config_path` instead.",
50+
51+
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." +
52+
"Use OTLP environment variables instead: https://opentelemetry.io/docs/specs/otel/protocol/exporter/",
53+
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." +
54+
"Use OTEL environment variables instead: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/",
4655
}
4756

4857
// Valid checks whether a given Warning is valid

pkg/tracing/plugin/otlp.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import (
2424
"net/url"
2525
"time"
2626

27+
"github.com/containerd/containerd/v2/pkg/deprecation"
2728
"github.com/containerd/containerd/v2/pkg/tracing"
2829
"github.com/containerd/containerd/v2/plugins"
30+
"github.com/containerd/containerd/v2/plugins/services/warning"
2931
"github.com/containerd/errdefs"
3032
"github.com/containerd/plugin"
3133
"github.com/containerd/plugin/registry"
@@ -48,6 +50,9 @@ func init() {
4850
Type: plugins.TracingProcessorPlugin,
4951
Config: &OTLPConfig{},
5052
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
53+
if err := warnOTLPConfig(ic); err != nil {
54+
return nil, err
55+
}
5156
cfg := ic.Config.(*OTLPConfig)
5257
exp, err := newExporter(ic.Context, cfg)
5358
if err != nil {
@@ -67,6 +72,9 @@ func init() {
6772
TraceSamplingRatio: 1.0,
6873
},
6974
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
75+
if err := warnTraceConfig(ic); err != nil {
76+
return nil, err
77+
}
7078
// get TracingProcessorPlugin which is a dependency
7179
plugins, err := ic.GetByType(plugins.TracingProcessorPlugin)
7280
if err != nil {
@@ -191,3 +199,54 @@ func newTracer(ctx context.Context, config *TraceConfig, procs []trace.SpanProce
191199
func propagators() propagation.TextMapPropagator {
192200
return propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
193201
}
202+
203+
func warnTraceConfig(ic *plugin.InitContext) error {
204+
ctx := ic.Context
205+
cfg := ic.Config.(*TraceConfig)
206+
var warn bool
207+
if cfg.ServiceName != "" {
208+
warn = true
209+
}
210+
if cfg.TraceSamplingRatio != 0 {
211+
warn = true
212+
}
213+
214+
if !warn {
215+
return nil
216+
}
217+
218+
wp, err := ic.GetSingle(plugins.WarningPlugin)
219+
if err != nil {
220+
return err
221+
}
222+
ws := wp.(warning.Service)
223+
ws.Emit(ctx, deprecation.TracingServiceConfig)
224+
return nil
225+
}
226+
227+
func warnOTLPConfig(ic *plugin.InitContext) error {
228+
ctx := ic.Context
229+
cfg := ic.Config.(*OTLPConfig)
230+
var warn bool
231+
if cfg.Endpoint != "" {
232+
warn = true
233+
}
234+
if cfg.Protocol != "" {
235+
warn = true
236+
}
237+
if cfg.Insecure {
238+
warn = true
239+
}
240+
241+
if !warn {
242+
return nil
243+
}
244+
245+
wp, err := ic.GetSingle(plugins.WarningPlugin)
246+
if err != nil {
247+
return err
248+
}
249+
ws := wp.(warning.Service)
250+
ws.Emit(ctx, deprecation.TracingOTLPConfig)
251+
return nil
252+
}

0 commit comments

Comments
 (0)