1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-08-10 22:31:50 +02:00

Use existing schema URLs in tests (#6924)

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 <pellared@hotmail.com>
This commit is contained in:
Damien Mathieu
2025-06-24 09:02:21 +02:00
committed by GitHub
parent a365d8505d
commit 351a51f1ed
5 changed files with 28 additions and 20 deletions

View File

@@ -66,7 +66,7 @@ func TestTracerProvider(t *testing.T) {
return provider.Tracer(bazbar) return provider.Tracer(bazbar)
}, },
func() trace.Tracer { 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 { func() trace.Tracer {
return provider.Tracer(foobar, trace.WithInstrumentationAttributes(attribute.String("foo", "bar"))) return provider.Tracer(foobar, trace.WithInstrumentationAttributes(attribute.String("foo", "bar")))
@@ -74,7 +74,7 @@ func TestTracerProvider(t *testing.T) {
func() trace.Tracer { func() trace.Tracer {
return provider.Tracer( return provider.Tracer(
foobar, 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")), trace.WithInstrumentationAttributes(attribute.String("foo", "bar")),
) )
}, },

View File

@@ -155,22 +155,22 @@ func TestMerge(t *testing.T) {
}, },
{ {
name: "Merge with first resource with schema", 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), b: resource.NewSchemaless(kv42),
want: []attribute.KeyValue{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", name: "Merge with second resource with schema",
a: resource.NewSchemaless(kv41), 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}, 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", name: "Merge with different schemas",
a: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.4.0", kv41), a: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.21.0", kv41),
b: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.3.0", kv42), b: resource.NewWithAttributes("https://opentelemetry.io/schemas/1.20.0", kv42),
want: []attribute.KeyValue{kv42}, want: []attribute.KeyValue{kv42},
isErr: true, isErr: true,
}, },
@@ -378,21 +378,25 @@ func TestNew(t *testing.T) {
envars: "", envars: "",
options: []resource.Option{ options: []resource.Option{
resource.WithAttributes(attribute.String("A", "B")), 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{ resourceValues: map[string]string{
"A": "B", "A": "B",
}, },
schemaURL: "https://opentelemetry.io/schemas/1.0.0", schemaURL: "https://opentelemetry.io/schemas/1.21.0",
}, },
{ {
name: "With conflicting schema urls", name: "With conflicting schema urls",
envars: "", envars: "",
options: []resource.Option{ options: []resource.Option{
resource.WithDetectors( 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{ resourceValues: map[string]string{
string(semconv.HostNameKey): func() (hostname string) { string(semconv.HostNameKey): func() (hostname string) {
@@ -408,14 +412,18 @@ func TestNew(t *testing.T) {
envars: "", envars: "",
options: []resource.Option{ options: []resource.Option{
resource.WithDetectors( resource.WithDetectors(
resource.StringDetector("https://opentelemetry.io/schemas/1.0.0", semconv.HostNameKey, os.Hostname),
resource.StringDetector( 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, semconv.HostNameKey,
func() (string, error) { return "", errors.New("fail") }, 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{ resourceValues: map[string]string{
string(semconv.HostNameKey): func() (hostname string) { string(semconv.HostNameKey): func() (hostname string) {
@@ -791,7 +799,7 @@ type fakeDetector struct{}
func (f fakeDetector) Detect(_ context.Context) (*resource.Resource, error) { func (f fakeDetector) Detect(_ context.Context) (*resource.Resource, error) {
// A bit pedantic, but resource.NewWithAttributes returns an empty Resource when // A bit pedantic, but resource.NewWithAttributes returns an empty Resource when
// no attributes specified. We want to make sure that this is concurrent-safe. // 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{} var _ resource.Detector = &fakeDetector{}

View File

@@ -191,7 +191,7 @@ func TestFailedProcessorShutdownInUnregister(t *testing.T) {
func TestSchemaURL(t *testing.T) { func TestSchemaURL(t *testing.T) {
stp := NewTracerProvider() 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)) tracerIface := stp.Tracer("tracername", trace.WithSchemaURL(schemaURL))
// Verify that the SchemaURL of the constructed Tracer is correctly populated. // Verify that the SchemaURL of the constructed Tracer is correctly populated.

View File

@@ -1515,7 +1515,7 @@ func TestWithInstrumentationVersionAndSchema(t *testing.T) {
_, span := tp.Tracer( _, span := tp.Tracer(
"WithInstrumentationVersion", "WithInstrumentationVersion",
trace.WithInstrumentationVersion("v0.1.0"), 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") ).Start(ctx, "span0")
got, err := endSpan(te, span) got, err := endSpan(te, span)
if err != nil { if err != nil {
@@ -1533,7 +1533,7 @@ func TestWithInstrumentationVersionAndSchema(t *testing.T) {
instrumentationScope: instrumentation.Scope{ instrumentationScope: instrumentation.Scope{
Name: "WithInstrumentationVersion", Name: "WithInstrumentationVersion",
Version: "v0.1.0", 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 != "" { if diff := cmpDiff(got, want); diff != "" {

View File

@@ -212,7 +212,7 @@ func TestEndSpanConfig(t *testing.T) {
func TestTracerConfig(t *testing.T) { func TestTracerConfig(t *testing.T) {
v1 := "semver:0.0.1" v1 := "semver:0.0.1"
v2 := "semver:1.0.0" v2 := "semver:1.0.0"
schemaURL := "https://opentelemetry.io/schemas/1.2.0" schemaURL := "https://opentelemetry.io/schemas/1.21.0"
attrs := attribute.NewSet( attrs := attribute.NewSet(
attribute.String("user", "alice"), attribute.String("user", "alice"),
attribute.Bool("admin", true), attribute.Bool("admin", true),