mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 06:29:29 +01:00
tracing: test for semconv/SDK version conflicts
This commit is contained in:
@@ -121,7 +121,7 @@ func NewTracerProvider(ctx context.Context, endpoint, caCert, name, namespace st
|
|||||||
klog.V(5).InfoS("no name provided, using default service name for tracing", "name", DefaultServiceName)
|
klog.V(5).InfoS("no name provided, using default service name for tracing", "name", DefaultServiceName)
|
||||||
name = DefaultServiceName
|
name = DefaultServiceName
|
||||||
}
|
}
|
||||||
resourceOpts := []sdkresource.Option{sdkresource.WithAttributes(semconv.ServiceNameKey.String(name)), sdkresource.WithSchemaURL(semconv.SchemaURL), sdkresource.WithProcess()}
|
resourceOpts := defaultResourceOpts(name)
|
||||||
if namespace != "" {
|
if namespace != "" {
|
||||||
resourceOpts = append(resourceOpts, sdkresource.WithAttributes(semconv.ServiceNamespaceKey.String(namespace)))
|
resourceOpts = append(resourceOpts, sdkresource.WithAttributes(semconv.ServiceNamespaceKey.String(namespace)))
|
||||||
}
|
}
|
||||||
@@ -141,6 +141,10 @@ func NewTracerProvider(ctx context.Context, endpoint, caCert, name, namespace st
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultResourceOpts(name string) []sdkresource.Option {
|
||||||
|
return []sdkresource.Option{sdkresource.WithAttributes(semconv.ServiceNameKey.String(name)), sdkresource.WithSchemaURL(semconv.SchemaURL), sdkresource.WithProcess()}
|
||||||
|
}
|
||||||
|
|
||||||
// Shutdown shuts down the global trace exporter.
|
// Shutdown shuts down the global trace exporter.
|
||||||
func Shutdown(ctx context.Context) error {
|
func Shutdown(ctx context.Context) error {
|
||||||
tp, ok := provider.(*sdktrace.TracerProvider)
|
tp, ok := provider.(*sdktrace.TracerProvider)
|
||||||
|
|||||||
17
pkg/tracing/tracing_test.go
Normal file
17
pkg/tracing/tracing_test.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package tracing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
sdkresource "go.opentelemetry.io/otel/sdk/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCreateTraceableResource(t *testing.T) {
|
||||||
|
ctx := context.TODO()
|
||||||
|
resourceOpts := defaultResourceOpts("descheduler")
|
||||||
|
_, err := sdkresource.New(ctx, resourceOpts...)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error initialising tracer provider: %!", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user