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>
  • Loading branch information
cpuguy83 committed Feb 20, 2024
1 parent fea1bc2 commit 753a525
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
3 changes: 3 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
>
Expand Down
9 changes: 9 additions & 0 deletions pkg/deprecation/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down
59 changes: 59 additions & 0 deletions pkg/tracing/plugin/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

0 comments on commit 753a525

Please sign in to comment.