From a32ef13ca18099fc748d69515f2f1b5bcef1c944 Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Fri, 16 Aug 2024 02:14:28 +0200 Subject: [PATCH] HTTP migration, Env Var name (#5997) This change renames the environment variable used for compatibility mode to `OTEL_SEMCONV_STABILITY_OPT_IN` as per the recommendation in the spec. Follow up from [this comment](https://github.com/open-telemetry/opentelemetry-go-contrib/issues/5132#issuecomment-2265511876). Co-authored-by: Aaron Clawson --- CHANGELOG.md | 2 ++ .../net/http/otelhttp/internal/semconv/bench_test.go | 2 +- instrumentation/net/http/otelhttp/internal/semconv/env.go | 4 ++-- .../net/http/otelhttp/internal/semconv/httpconv_test.go | 6 +++--- .../net/http/otelhttp/internal/semconv/v1.20.0_test.go | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cc84bc0f74..41521bc3d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `go.opentelemetry.io/contrib/config` package supports configuring `with_resource_constant_labels` for the prometheus exporter. (#5890) - Add new runtime metrics to `go.opentelemetry.io/contrib/instrumentation/runtime`, which are still disabled by default. (#5870) - Support for the `OTEL_HTTP_CLIENT_COMPATIBILITY_MODE=http/dup` environment variable in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to emit attributes for both the v1.20.0 and v1.26.0 semantic conventions. (#5401) +- The `go.opentelemetry.io/contrib/bridges/otelzerolog` module. + This module provides an OpenTelemetry logging bridge for `github.com/rs/zerolog`. (#5405) ### Removed diff --git a/instrumentation/net/http/otelhttp/internal/semconv/bench_test.go b/instrumentation/net/http/otelhttp/internal/semconv/bench_test.go index b24abba4cbc..0cce1ef6d24 100644 --- a/instrumentation/net/http/otelhttp/internal/semconv/bench_test.go +++ b/instrumentation/net/http/otelhttp/internal/semconv/bench_test.go @@ -14,7 +14,7 @@ import ( var benchHTTPServerRequestResults []attribute.KeyValue // BenchmarkHTTPServerRequest allows comparison between different version of the HTTP server. -// To use an alternative start this test with OTEL_HTTP_CLIENT_COMPATIBILITY_MODE set to the +// To use an alternative start this test with OTEL_SEMCONV_STABILITY_OPT_IN set to the // version under test. func BenchmarkHTTPServerRequest(b *testing.B) { // Request was generated from TestHTTPServerRequest request. diff --git a/instrumentation/net/http/otelhttp/internal/semconv/env.go b/instrumentation/net/http/otelhttp/internal/semconv/env.go index d95391becec..9cae4cab86a 100644 --- a/instrumentation/net/http/otelhttp/internal/semconv/env.go +++ b/instrumentation/net/http/otelhttp/internal/semconv/env.go @@ -111,7 +111,7 @@ func (s HTTPServer) RecordMetrics(ctx context.Context, md MetricData) { } func NewHTTPServer(meter metric.Meter) HTTPServer { - env := strings.ToLower(os.Getenv("OTEL_HTTP_CLIENT_COMPATIBILITY_MODE")) + env := strings.ToLower(os.Getenv("OTEL_SEMCONV_STABILITY_OPT_IN")) duplicate := env == "http/dup" server := HTTPServer{ duplicate: duplicate, @@ -125,7 +125,7 @@ type HTTPClient struct { } func NewHTTPClient() HTTPClient { - env := strings.ToLower(os.Getenv("OTEL_HTTP_CLIENT_COMPATIBILITY_MODE")) + env := strings.ToLower(os.Getenv("OTEL_SEMCONV_STABILITY_OPT_IN")) return HTTPClient{duplicate: env == "http/dup"} } diff --git a/instrumentation/net/http/otelhttp/internal/semconv/httpconv_test.go b/instrumentation/net/http/otelhttp/internal/semconv/httpconv_test.go index 82bb0133168..91a499b07bc 100644 --- a/instrumentation/net/http/otelhttp/internal/semconv/httpconv_test.go +++ b/instrumentation/net/http/otelhttp/internal/semconv/httpconv_test.go @@ -17,7 +17,7 @@ import ( ) func TestNewTraceRequest(t *testing.T) { - t.Setenv("OTEL_HTTP_CLIENT_COMPATIBILITY_MODE", "http/dup") + t.Setenv("OTEL_SEMCONV_STABILITY_OPT_IN", "http/dup") serv := NewHTTPServer(nil) want := func(req testServerReq) []attribute.KeyValue { return []attribute.KeyValue{ @@ -131,7 +131,7 @@ func TestNewMethod(t *testing.T) { } func TestNewTraceRequest_Client(t *testing.T) { - t.Setenv("OTEL_HTTP_CLIENT_COMPATIBILITY_MODE", "http/dup") + t.Setenv("OTEL_SEMCONV_STABILITY_OPT_IN", "http/dup") body := strings.NewReader("Hello, world!") url := "https://example.com:8888/foo/bar?stuff=morestuff" req := httptest.NewRequest("pOST", url, body) @@ -156,7 +156,7 @@ func TestNewTraceRequest_Client(t *testing.T) { } func TestNewTraceResponse_Client(t *testing.T) { - t.Setenv("OTEL_HTTP_CLIENT_COMPATIBILITY_MODE", "http/dup") + t.Setenv("OTEL_SEMCONV_STABILITY_OPT_IN", "http/dup") testcases := []struct { resp http.Response want []attribute.KeyValue diff --git a/instrumentation/net/http/otelhttp/internal/semconv/v1.20.0_test.go b/instrumentation/net/http/otelhttp/internal/semconv/v1.20.0_test.go index 7fc0e90eb45..a35033f49c1 100644 --- a/instrumentation/net/http/otelhttp/internal/semconv/v1.20.0_test.go +++ b/instrumentation/net/http/otelhttp/internal/semconv/v1.20.0_test.go @@ -17,7 +17,7 @@ import ( func TestV120TraceRequest(t *testing.T) { // Anything but "http" or "http/dup" works. - t.Setenv("OTEL_HTTP_CLIENT_COMPATIBILITY_MODE", "old") + t.Setenv("OTEL_SEMCONV_STABILITY_OPT_IN", "old") serv := NewHTTPServer(nil) want := func(req testServerReq) []attribute.KeyValue { return []attribute.KeyValue{