mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Fix OTEL init from semconv conflict (#3446)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
@@ -5,6 +5,11 @@ This document describes how to use and implement tracing in OpenTofu Core using
|
|||||||
> [!NOTE]
|
> [!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).
|
> 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
|
## 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:
|
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.
|
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.
|
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.
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ import (
|
|||||||
"go.opentelemetry.io/otel/sdk"
|
"go.opentelemetry.io/otel/sdk"
|
||||||
"go.opentelemetry.io/otel/sdk/resource"
|
"go.opentelemetry.io/otel/sdk/resource"
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
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"
|
"github.com/opentofu/opentofu/version"
|
||||||
)
|
)
|
||||||
@@ -174,4 +177,4 @@ func OpenTelemetryInit(ctx context.Context) (context.Context, error) {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user