-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Templatize the otelhttp semconv module (#6626)
Co-authored-by: Sam Xie <[email protected]> Co-authored-by: Robert Pająk <[email protected]>
- Loading branch information
1 parent
df8e435
commit dafdad1
Showing
24 changed files
with
2,823 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/bench_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/env_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package semconv // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv" | ||
|
||
// Generate semconv package: | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/bench_test.go.tmpl "--data={}" --out=bench_test.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/env.go.tmpl "--data={}" --out=env.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/env_test.go.tmpl "--data={}" --out=env_test.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/httpconv.go.tmpl "--data={}" --out=httpconv.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/httpconv_test.go.tmpl "--data={}" --out=httpconv_test.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/util.go.tmpl "--data={}" --out=util.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/util_test.go.tmpl "--data={}" --out=util_test.go | ||
//go:generate gotmpl --body=../../../../../../internal/shared/semconv/v1.20.0.go.tmpl "--data={}" --out=v1.20.0.go |
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/httpconv.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/httpconv_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/test/common_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
instrumentation/net/http/otelhttp/internal/semconv/test/gen.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package test // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/internal/semconv/test" | ||
|
||
// Generate semconv/test package: | ||
//go:generate gotmpl --body=../../../../../../../internal/shared/semconv/test/common_test.go.tmpl "--data={}" --out=common_test.go | ||
//go:generate gotmpl --body=../../../../../../../internal/shared/semconv/test/httpconv_test.go.tmpl "--data={}" --out=httpconv_test.go | ||
//go:generate gotmpl --body=../../../../../../../internal/shared/semconv/test/v1.20.0_test.go.tmpl "--data={}" --out=v1.20.0_test.go |
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/test/httpconv_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/test/v1.20.0_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/util_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
instrumentation/net/http/otelhttp/internal/semconv/v1.20.0.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Code created by gotmpl. DO NOT MODIFY. | ||
// source: internal/shared/semconv/bench_test.go.tmpl | ||
|
||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package semconv | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
"testing" | ||
|
||
"go.opentelemetry.io/otel/attribute" | ||
) | ||
|
||
var benchHTTPServerRequestResults []attribute.KeyValue | ||
|
||
// BenchmarkHTTPServerRequest allows comparison between different version of the HTTP server. | ||
// 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. | ||
req := &http.Request{ | ||
Method: http.MethodGet, | ||
URL: &url.URL{ | ||
Path: "/", | ||
}, | ||
Proto: "HTTP/1.1", | ||
ProtoMajor: 1, | ||
ProtoMinor: 1, | ||
Header: http.Header{ | ||
"User-Agent": []string{"Go-http-client/1.1"}, | ||
"Accept-Encoding": []string{"gzip"}, | ||
}, | ||
Body: http.NoBody, | ||
Host: "127.0.0.1:39093", | ||
RemoteAddr: "127.0.0.1:38738", | ||
RequestURI: "/", | ||
} | ||
serv := NewHTTPServer(nil) | ||
|
||
b.ReportAllocs() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
benchHTTPServerRequestResults = serv.RequestTraceAttrs("", req) | ||
} | ||
} |
Oops, something went wrong.