Fix broken OTEL due to #43298 (#43705)

Resolves broken OTEL on main, which was introduced with dependabot
update #43298

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated OpenTelemetry semantic conventions dependency to the latest
version.

* **Tests**
  * Added test coverage for OpenTelemetry resource creation validation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Victor Lyuboslavsky 2026-04-17 09:05:26 -05:00 committed by GitHub
parent b815310740
commit bd74265aa6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 2 deletions

View file

@ -114,7 +114,7 @@ import (
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
"google.golang.org/grpc"
_ "google.golang.org/grpc/encoding/gzip" // Because we use gzip compression for OTLP
)

View file

@ -32,6 +32,8 @@ import (
"github.com/smallstep/pkcs7"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
)
// safeStore is a wrapper around mock.Store to allow for concurrent calling to
@ -1322,3 +1324,20 @@ func TestHostVitalsLabelMembershipJob(t *testing.T) {
// Only one label (the host vitals label) should have been processed.
require.Equal(t, 1, numCalls)
}
// TestOTELResourceCreation verifies that the OTEL resource can be created without schema URL
// conflicts. The SDK's WithTelemetrySDK() detector embeds its own schema URL, which must match
// the semconv version we import. A mismatch (e.g. after a dependabot SDK bump that doesn't
// update our semconv import) causes a runtime error on server startup.
func TestOTELResourceCreation(t *testing.T) {
res, err := resource.New(t.Context(),
resource.WithSchemaURL(semconv.SchemaURL),
resource.WithAttributes(
semconv.ServiceName("fleet-test"),
semconv.ServiceVersion("0.0.0-test"),
),
resource.WithTelemetrySDK(),
)
require.NoError(t, err)
require.NotNil(t, res)
}

View file

@ -36,7 +36,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/jmoiron/sqlx"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.39.0"
semconv "go.opentelemetry.io/otel/semconv/v1.40.0"
)
const (