From e6a33e055a0cc66156535b6016ca24c805efb451 Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Wed, 29 Oct 2025 15:17:20 -0400 Subject: [PATCH] Fix OTEL init from semconv conflict (#3446) Signed-off-by: Christian Mesh --- docs/tracing.md | 7 ++++++- internal/tracing/init.go | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/tracing.md b/docs/tracing.md index 9a8ecdc662..312fcd101d 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -5,6 +5,11 @@ This document describes how to use and implement tracing in OpenTofu Core using > [!NOTE] > For background on the design decisions and motivation behind OpenTofu's tracing implementation, see the [OpenTelemetry Tracing RFC](https://github.com/opentofu/opentofu/blob/main/rfc/20250129-Tracing-For-Extra-Context.md). +> [!NOTE] +> If you are upgrading any dependent libraries which pull in a new OTEL version, you *MUST* update the semconv version in tracing/init.go to the latest version. +> Failing to do this will result in an error "Could not initialize telemetry: failed to create resource: error detecting resource: conflicting Schema URL". +> This sets the *maximum* supported schema version in our OTEL context. Semconv is backwards compatible with older versions, but the newest must be specified. + ## Overview OpenTofu provides distributed tracing capabilities via OpenTelemetry to help end users understand the execution flow and performance characteristics of OpenTofu operations. Tracing is particularly useful for: @@ -134,4 +139,4 @@ This helper supports various error types including standard errors, strings, and 1. **Focus on Key Operations**: Instrument high-level operations that are meaningful to end users rather than every internal function. 2. **Include Valuable Context**: Add attributes that help identify resources, modules, or operations. -3. **Respect Performance**: Avoid expensive computations solely for tracing. \ No newline at end of file +3. **Respect Performance**: Avoid expensive computations solely for tracing. diff --git a/internal/tracing/init.go b/internal/tracing/init.go index 919997be87..7814fda712 100644 --- a/internal/tracing/init.go +++ b/internal/tracing/init.go @@ -18,7 +18,10 @@ import ( "go.opentelemetry.io/otel/sdk" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.26.0" + + // This *MUST* always be updated to the latest version when OTEL dependencies are updated in OpenTofu + // Failing to do so will prevent OpenTofu from initializing tracing. + semconv "go.opentelemetry.io/otel/semconv/v1.37.0" "github.com/opentofu/opentofu/version" ) @@ -174,4 +177,4 @@ func OpenTelemetryInit(ctx context.Context) (context.Context, error) { })) return ctx, nil -} \ No newline at end of file +}