Fix OTEL init from semconv conflict (#3446)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
Christian Mesh
2025-10-29 15:17:20 -04:00
committed by GitHub
parent e1938ccca9
commit 58b722c423
2 changed files with 11 additions and 3 deletions

View File

@@ -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.
3. **Respect Performance**: Avoid expensive computations solely for tracing.

View File

@@ -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
}
}