Skip to content

Commit f235489

Browse files
cpuguy83vvoland
authored andcommitted
Deprecate otel configs
Signed-off-by: Brian Goff <[email protected]> (cherry picked from commit 753a525) Signed-off-by: Paweł Gronowski <[email protected]>
1 parent be5ec97 commit f235489

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

RELEASES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ The deprecated properties in [`config.toml`](./docs/cri/config.md) are shown in
394394
|`[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). |
395395
|`[plugins."io.containerd.grpc.v1.cri".registry]` | `configs` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) |
396396
|`[plugins."io.containerd.grpc.v1.cri".registry]` | `mirrors` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) |
397+
|`[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 |
398+
|`[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* |
399+
397400

398401
> **Note**
399402
>

pkg/deprecation/deprecation.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const (
5353
RuntimeRuncV1 Warning = Prefix + "runtime-runc-v1"
5454
// CRICRIUPath is a warning for the use of the `CriuPath` property
5555
CRICRIUPath Warning = Prefix + "cri-criu-path"
56+
// OTLPTracingConfig is a warning for the use of the `otlp` property
57+
TracingOTLPConfig Warning = Prefix + "tracing-processor-config"
58+
// TracingServiceConfig is a warning for the use of the `tracing` property
59+
TracingServiceConfig Warning = Prefix + "tracing-service-config"
5660
)
5761

5862
var messages = map[Warning]string{
@@ -82,6 +86,10 @@ var messages = map[Warning]string{
8286
RuntimeRuncV1: "The `io.containerd.runc.v1` runtime is deprecated since containerd v1.4 and removed in containerd v2.0. Use the `io.containerd.runc.v2` runtime instead.",
8387
CRICRIUPath: "The `CriuPath` property of `[plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.*.options]` is deprecated since containerd v1.7 and will be removed in containerd v2.0. " +
8488
"Use a criu binary in $PATH instead.",
89+
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." +
90+
"Use OTLP environment variables instead: https://opentelemetry.io/docs/specs/otel/protocol/exporter/",
91+
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." +
92+
"Use OTEL environment variables instead: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/",
8593
}
8694

8795
// Valid checks whether a given Warning is valid

tracing/plugin/otlp.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import (
2525

2626
"github.com/containerd/containerd/errdefs"
2727
"github.com/containerd/containerd/log"
28+
"github.com/containerd/containerd/pkg/deprecation"
2829
"github.com/containerd/containerd/plugin"
30+
"github.com/containerd/containerd/services/warning"
2931
"github.com/containerd/containerd/tracing"
3032
"github.com/sirupsen/logrus"
3133
"go.opentelemetry.io/otel"
@@ -46,6 +48,9 @@ func init() {
4648
Type: plugin.TracingProcessorPlugin,
4749
Config: &OTLPConfig{},
4850
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
51+
if err := warnOTLPConfig(ic); err != nil {
52+
return nil, err
53+
}
4954
cfg := ic.Config.(*OTLPConfig)
5055
if cfg.Endpoint == "" {
5156
return nil, fmt.Errorf("no OpenTelemetry endpoint: %w", plugin.ErrSkipPlugin)
@@ -64,6 +69,9 @@ func init() {
6469
Config: &TraceConfig{ServiceName: "containerd", TraceSamplingRatio: 1.0},
6570
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
6671
//get TracingProcessorPlugin which is a dependency
72+
if err := warnTraceConfig(ic); err != nil {
73+
return nil, err
74+
}
6775
plugins, err := ic.GetByType(plugin.TracingProcessorPlugin)
6876
if err != nil {
6977
return nil, fmt.Errorf("failed to get tracing processors: %w", err)
@@ -195,3 +203,54 @@ func newTracer(ctx context.Context, config *TraceConfig, procs []trace.SpanProce
195203
func propagators() propagation.TextMapPropagator {
196204
return propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})
197205
}
206+
207+
func warnTraceConfig(ic *plugin.InitContext) error {
208+
ctx := ic.Context
209+
cfg := ic.Config.(*TraceConfig)
210+
var warn bool
211+
if cfg.ServiceName != "" {
212+
warn = true
213+
}
214+
if cfg.TraceSamplingRatio != 0 {
215+
warn = true
216+
}
217+
218+
if !warn {
219+
return nil
220+
}
221+
222+
wp, err := ic.Get(plugin.WarningPlugin)
223+
if err != nil {
224+
return err
225+
}
226+
ws := wp.(warning.Service)
227+
ws.Emit(ctx, deprecation.TracingServiceConfig)
228+
return nil
229+
}
230+
231+
func warnOTLPConfig(ic *plugin.InitContext) error {
232+
ctx := ic.Context
233+
cfg := ic.Config.(*OTLPConfig)
234+
var warn bool
235+
if cfg.Endpoint != "" {
236+
warn = true
237+
}
238+
if cfg.Protocol != "" {
239+
warn = true
240+
}
241+
if cfg.Insecure {
242+
warn = true
243+
}
244+
245+
if !warn {
246+
return nil
247+
}
248+
249+
wp, err := ic.Get(plugin.WarningPlugin)
250+
if err != nil {
251+
return err
252+
}
253+
ws := wp.(warning.Service)
254+
ws.Emit(ctx, deprecation.TracingOTLPConfig)
255+
return nil
256+
}

0 commit comments

Comments
 (0)