Deprecate otel configs

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2024-01-26 00:40:31 +00:00
parent fea1bc2dc7
commit 753a525b3b
3 changed files with 71 additions and 0 deletions

View File

@@ -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

View File

@@ -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
}