Skip to content

Commit

Permalink
Deprecate otel configs
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 753a525)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
  • Loading branch information
cpuguy83 authored and vvoland committed Mar 25, 2024
1 parent be5ec97 commit f235489
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,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**
>
Expand Down
8 changes: 8 additions & 0 deletions pkg/deprecation/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const (
RuntimeRuncV1 Warning = Prefix + "runtime-runc-v1"
// CRICRIUPath is a warning for the use of the `CriuPath` property
CRICRIUPath Warning = Prefix + "cri-criu-path"
// 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{
Expand Down Expand Up @@ -82,6 +86,10 @@ var messages = map[Warning]string{
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.",
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. " +
"Use a criu binary in $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
Expand Down
59 changes: 59 additions & 0 deletions tracing/plugin/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import (

"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/pkg/deprecation"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services/warning"
"github.com/containerd/containerd/tracing"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel"
Expand All @@ -46,6 +48,9 @@ func init() {
Type: plugin.TracingProcessorPlugin,
Config: &OTLPConfig{},
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
if err := warnOTLPConfig(ic); err != nil {
return nil, err
}
cfg := ic.Config.(*OTLPConfig)
if cfg.Endpoint == "" {
return nil, fmt.Errorf("no OpenTelemetry endpoint: %w", plugin.ErrSkipPlugin)
Expand All @@ -64,6 +69,9 @@ func init() {
Config: &TraceConfig{ServiceName: "containerd", TraceSamplingRatio: 1.0},
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
//get TracingProcessorPlugin which is a dependency
if err := warnTraceConfig(ic); err != nil {
return nil, err
}
plugins, err := ic.GetByType(plugin.TracingProcessorPlugin)
if err != nil {
return nil, fmt.Errorf("failed to get tracing processors: %w", err)
Expand Down Expand Up @@ -195,3 +203,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.Get(plugin.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.Get(plugin.WarningPlugin)
if err != nil {
return err
}
ws := wp.(warning.Service)
ws.Emit(ctx, deprecation.TracingOTLPConfig)
return nil
}

0 comments on commit f235489

Please sign in to comment.