Skip to content

Commit

Permalink
HTTP migration, Env Var name (#5997)
Browse files Browse the repository at this point in the history
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](#5132 (comment)).

Co-authored-by: Aaron Clawson <[email protected]>
  • Loading branch information
MadVikingGod and MadVikingGod authored Aug 16, 2024
1 parent bb9ac54 commit a32ef13
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/net/http/otelhttp/internal/semconv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit a32ef13

Please sign in to comment.