From 351a51f1ed18f0e35b1cf85400834d5c75d71322 Mon Sep 17 00:00:00 2001 From: Damien Mathieu <42@dmathieu.com> Date: Tue, 24 Jun 2025 09:02:21 +0200 Subject: [PATCH] Use existing schema URLs in tests (#6924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 1.2.0 schema URL isn't avaibable (anymore?). So link checks are failing. This upgrades the schema URLs to 1.21.0. See https://cloud-native.slack.com/archives/C02UN96HZH6/p1750664367346769 --------- Co-authored-by: Robert PajÄ…k --- bridge/opentracing/provider_test.go | 4 ++-- sdk/resource/resource_test.go | 36 ++++++++++++++++++----------- sdk/trace/provider_test.go | 2 +- sdk/trace/trace_test.go | 4 ++-- trace/config_test.go | 2 +- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/bridge/opentracing/provider_test.go b/bridge/opentracing/provider_test.go index b8762246f..091916141 100644 --- a/bridge/opentracing/provider_test.go +++ b/bridge/opentracing/provider_test.go @@ -66,7 +66,7 @@ func TestTracerProvider(t *testing.T) { return provider.Tracer(bazbar) }, func() trace.Tracer { - return provider.Tracer(foobar, trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0")) + return provider.Tracer(foobar, trace.WithSchemaURL("http://opentelemetry.io/schemas/1.21.0")) }, func() trace.Tracer { return provider.Tracer(foobar, trace.WithInstrumentationAttributes(attribute.String("foo", "bar"))) @@ -74,7 +74,7 @@ func TestTracerProvider(t *testing.T) { func() trace.Tracer { return provider.Tracer( foobar, - trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"), + trace.WithSchemaURL("https://opentelemetry.io/schemas/1.21.0"), trace.WithInstrumentationAttributes(attribute.String("foo", "bar")), ) }, diff --git a/sdk/resource/resource_test.go b/sdk/resource/resource_test.go index e5e7f12f4..c41a31a77 100644 --- a/sdk/resource/resource_test.go +++ b/sdk/resource/resource_test.go @@ -155,22 +155,22 @@ func TestMerge(t *testing.T) { }, { name: "Merge with first resource with schema", - a: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.4.0", kv41), + a: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0", kv41), b: resource.NewSchemaless(kv42), want: []attribute.KeyValue{kv42}, - schemaURL: "https://opentelemetry.io/schemas/1.4.0", + schemaURL: "https://opentelemetry.io/schemas/1.21.0", }, { name: "Merge with second resource with schema", a: resource.NewSchemaless(kv41), - b: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.4.0", kv42), + b: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0", kv42), want: []attribute.KeyValue{kv42}, - schemaURL: "https://opentelemetry.io/schemas/1.4.0", + schemaURL: "https://opentelemetry.io/schemas/1.21.0", }, { name: "Merge with different schemas", - a: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.4.0", kv41), - b: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.3.0", kv42), + a: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0", kv41), + b: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.20.0", kv42), want: []attribute.KeyValue{kv42}, isErr: true, }, @@ -378,21 +378,25 @@ func TestNew(t *testing.T) { envars: "", options: []resource.Option{ resource.WithAttributes(attribute.String("A", "B")), - resource.WithSchemaURL("https://opentelemetry.io/schemas/1.0.0"), + resource.WithSchemaURL("https://opentelemetry.io/schemas/1.21.0"), }, resourceValues: map[string]string{ "A": "B", }, - schemaURL: "https://opentelemetry.io/schemas/1.0.0", + schemaURL: "https://opentelemetry.io/schemas/1.21.0", }, { name: "With conflicting schema urls", envars: "", options: []resource.Option{ resource.WithDetectors( - resource.StringDetector("https://opentelemetry.io/schemas/1.0.0", semconv.HostNameKey, os.Hostname), + resource.StringDetector( + "https://opentelemetry.io/schemas/1.20.0", + semconv.HostNameKey, + os.Hostname, + ), ), - resource.WithSchemaURL("https://opentelemetry.io/schemas/1.1.0"), + resource.WithSchemaURL("https://opentelemetry.io/schemas/1.21.0"), }, resourceValues: map[string]string{ string(semconv.HostNameKey): func() (hostname string) { @@ -408,14 +412,18 @@ func TestNew(t *testing.T) { envars: "", options: []resource.Option{ resource.WithDetectors( - resource.StringDetector("https://opentelemetry.io/schemas/1.0.0", semconv.HostNameKey, os.Hostname), resource.StringDetector( - "https://opentelemetry.io/schemas/1.1.0", + "https://opentelemetry.io/schemas/1.19.0", + semconv.HostNameKey, + os.Hostname, + ), + resource.StringDetector( + "https://opentelemetry.io/schemas/1.20.0", semconv.HostNameKey, func() (string, error) { return "", errors.New("fail") }, ), ), - resource.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"), + resource.WithSchemaURL("https://opentelemetry.io/schemas/1.21.0"), }, resourceValues: map[string]string{ string(semconv.HostNameKey): func() (hostname string) { @@ -791,7 +799,7 @@ type fakeDetector struct{} func (f fakeDetector) Detect(_ context.Context) (*resource.Resource, error) { // A bit pedantic, but resource.NewWithAttributes returns an empty Resource when // no attributes specified. We want to make sure that this is concurrent-safe. - return resource.NewWithAttributes("https://opentelemetry.io/schemas/1.3.0"), nil + return resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0"), nil } var _ resource.Detector = &fakeDetector{} diff --git a/sdk/trace/provider_test.go b/sdk/trace/provider_test.go index bb4459284..9ec8267a5 100644 --- a/sdk/trace/provider_test.go +++ b/sdk/trace/provider_test.go @@ -191,7 +191,7 @@ func TestFailedProcessorShutdownInUnregister(t *testing.T) { func TestSchemaURL(t *testing.T) { stp := NewTracerProvider() - schemaURL := "https://opentelemetry.io/schemas/1.2.0" + schemaURL := "https://opentelemetry.io/schemas/1.21.0" tracerIface := stp.Tracer("tracername", trace.WithSchemaURL(schemaURL)) // Verify that the SchemaURL of the constructed Tracer is correctly populated. diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index c080778e7..77e9f5c86 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1515,7 +1515,7 @@ func TestWithInstrumentationVersionAndSchema(t *testing.T) { _, span := tp.Tracer( "WithInstrumentationVersion", trace.WithInstrumentationVersion("v0.1.0"), - trace.WithSchemaURL("https://opentelemetry.io/schemas/1.2.0"), + trace.WithSchemaURL("https://opentelemetry.io/schemas/1.21.0"), ).Start(ctx, "span0") got, err := endSpan(te, span) if err != nil { @@ -1533,7 +1533,7 @@ func TestWithInstrumentationVersionAndSchema(t *testing.T) { instrumentationScope: instrumentation.Scope{ Name: "WithInstrumentationVersion", Version: "v0.1.0", - SchemaURL: "https://opentelemetry.io/schemas/1.2.0", + SchemaURL: "https://opentelemetry.io/schemas/1.21.0", }, } if diff := cmpDiff(got, want); diff != "" { diff --git a/trace/config_test.go b/trace/config_test.go index 9a613ace2..00e6507e8 100644 --- a/trace/config_test.go +++ b/trace/config_test.go @@ -212,7 +212,7 @@ func TestEndSpanConfig(t *testing.T) { func TestTracerConfig(t *testing.T) { v1 := "semver:0.0.1" v2 := "semver:1.0.0" - schemaURL := "https://opentelemetry.io/schemas/1.2.0" + schemaURL := "https://opentelemetry.io/schemas/1.21.0" attrs := attribute.NewSet( attribute.String("user", "alice"), attribute.Bool("admin", true),