From b56f58577a3b118b17d145ffcf35b17bac4b75a2 Mon Sep 17 00:00:00 2001 From: dogedede <167682813+dogedede@users.noreply.github.com> Date: Fri, 7 Nov 2025 20:32:20 +0800 Subject: [PATCH 1/7] refactor(otelhttp): change Version() func to const Version string --- instrumentation/net/http/otelhttp/common.go | 2 +- instrumentation/net/http/otelhttp/config.go | 2 +- instrumentation/net/http/otelhttp/handler_test.go | 4 ++-- instrumentation/net/http/otelhttp/transport_test.go | 4 ++-- instrumentation/net/http/otelhttp/version.go | 5 ++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/instrumentation/net/http/otelhttp/common.go b/instrumentation/net/http/otelhttp/common.go index a83a026274a..3ae08243441 100644 --- a/instrumentation/net/http/otelhttp/common.go +++ b/instrumentation/net/http/otelhttp/common.go @@ -23,5 +23,5 @@ const ( type Filter func(*http.Request) bool func newTracer(tp trace.TracerProvider) trace.Tracer { - return tp.Tracer(ScopeName, trace.WithInstrumentationVersion(Version())) + return tp.Tracer(ScopeName, trace.WithInstrumentationVersion(Version)) } diff --git a/instrumentation/net/http/otelhttp/config.go b/instrumentation/net/http/otelhttp/config.go index 38fb79c0328..aa085476d96 100644 --- a/instrumentation/net/http/otelhttp/config.go +++ b/instrumentation/net/http/otelhttp/config.go @@ -67,7 +67,7 @@ func newConfig(opts ...Option) *config { c.Meter = c.MeterProvider.Meter( ScopeName, - metric.WithInstrumentationVersion(Version()), + metric.WithInstrumentationVersion(Version), ) return c diff --git a/instrumentation/net/http/otelhttp/handler_test.go b/instrumentation/net/http/otelhttp/handler_test.go index 30d1272d215..07649df8251 100644 --- a/instrumentation/net/http/otelhttp/handler_test.go +++ b/instrumentation/net/http/otelhttp/handler_test.go @@ -174,7 +174,7 @@ func TestHandlerBasics(t *testing.T) { func assertScopeMetrics(t *testing.T, sm metricdata.ScopeMetrics, attrs attribute.Set) { assert.Equal(t, instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp", - Version: Version(), + Version: Version, }, sm.Scope) require.Len(t, sm.Metrics, 3) @@ -182,7 +182,7 @@ func assertScopeMetrics(t *testing.T, sm metricdata.ScopeMetrics, attrs attribut want := metricdata.ScopeMetrics{ Scope: instrumentation.Scope{ Name: ScopeName, - Version: Version(), + Version: Version, }, Metrics: []metricdata.Metrics{ { diff --git a/instrumentation/net/http/otelhttp/transport_test.go b/instrumentation/net/http/otelhttp/transport_test.go index dd7c66f402a..d4d20b2bfa5 100644 --- a/instrumentation/net/http/otelhttp/transport_test.go +++ b/instrumentation/net/http/otelhttp/transport_test.go @@ -860,7 +860,7 @@ func TestTransportMetrics(t *testing.T) { func assertClientScopeMetrics(t *testing.T, sm metricdata.ScopeMetrics, attrs attribute.Set) { assert.Equal(t, instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp", - Version: Version(), + Version: Version, }, sm.Scope) require.Len(t, sm.Metrics, 2) @@ -868,7 +868,7 @@ func assertClientScopeMetrics(t *testing.T, sm metricdata.ScopeMetrics, attrs at want := metricdata.ScopeMetrics{ Scope: instrumentation.Scope{ Name: ScopeName, - Version: Version(), + Version: Version, }, Metrics: []metricdata.Metrics{ { diff --git a/instrumentation/net/http/otelhttp/version.go b/instrumentation/net/http/otelhttp/version.go index dfb53cf1f3a..44ff6b72ae7 100644 --- a/instrumentation/net/http/otelhttp/version.go +++ b/instrumentation/net/http/otelhttp/version.go @@ -4,7 +4,6 @@ package otelhttp // import "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" // Version is the current release version of the otelhttp instrumentation. -func Version() string { - return "0.63.0" +const Version = "0.63.0" // This string is updated by the pre_release.sh script during release -} + From 0a266f56ec78c589f9a5417dde55327cebe12ba7 Mon Sep 17 00:00:00 2001 From: dogedede <167682813+dogedede@users.noreply.github.com> Date: Fri, 7 Nov 2025 21:13:32 +0800 Subject: [PATCH 2/7] Change Version() function to const Version string in otelhttp (#8134) --- CHANGELOG.md | 4 ++++ instrumentation/net/http/otelhttp/version_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d56c0b70e..dda34c848da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1622,3 +1622,7 @@ First official tagged release of `contrib` repository. [Go 1.18]: https://go.dev/doc/go1.18 [GO-2024-2687]: https://pkg.go.dev/vuln/GO-2024-2687 + +### Changed + +- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) diff --git a/instrumentation/net/http/otelhttp/version_test.go b/instrumentation/net/http/otelhttp/version_test.go index d030fa16194..d51441178b0 100644 --- a/instrumentation/net/http/otelhttp/version_test.go +++ b/instrumentation/net/http/otelhttp/version_test.go @@ -19,6 +19,6 @@ var versionRegex = regexp.MustCompile(`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*) `(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`) func TestVersionSemver(t *testing.T) { - v := otelhttp.Version() + v := otelhttp.Version assert.NotNil(t, versionRegex.FindStringSubmatch(v), "version is not semver: %s", v) } From db55d5cc70d7337618cfe60bfeca2095299680a5 Mon Sep 17 00:00:00 2001 From: dogedede <167682813+dogedede@users.noreply.github.com> Date: Fri, 7 Nov 2025 21:43:22 +0800 Subject: [PATCH 3/7] docs(changelog): update changelog for otelhttp version change --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda34c848da..3fd5faa65bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Changed + +- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) + # Changelog All notable changes to this project will be documented in this file. @@ -1623,6 +1627,4 @@ First official tagged release of `contrib` repository. [GO-2024-2687]: https://pkg.go.dev/vuln/GO-2024-2687 -### Changed -- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) From 50d5f279e930206c75335a236319e84ae2795033 Mon Sep 17 00:00:00 2001 From: dogedede <167682813+dogedede@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:13:24 +0800 Subject: [PATCH 4/7] Update CHANGELOG for otelhttp Version change --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fd5faa65bb..fd2702b414d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -### Changed - -- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) - # Changelog All notable changes to this project will be documented in this file. @@ -25,7 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Add unmarshaling and validation for `AttributeType`, `AttributeNameValue`, `SimpleSpanProcessor`, `SimpleLogRecordProcessor`, `ZipkinSpanExporter`, `NameStringValuePair`, `InstrumentType`, `ExperimentalPeerInstrumentationServiceMappingElem`, `ExporterDefaultHistogramAggregation`, `PullMetricReader` to v1.0.0 model in `go.opentelemetry.io/contrib/otelconf`. (#8127) ### Changed - +- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) - Improve performance by reducing allocations in the gRPC stats handler in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8035) ### Deprecated From 7f7e25aac3206eed9d12c9cf4a97027bfa40c0a3 Mon Sep 17 00:00:00 2001 From: dogedede <167682813+dogedede@users.noreply.github.com> Date: Sat, 8 Nov 2025 19:04:41 +0800 Subject: [PATCH 5/7] fix(otelhttp): change Version() to const and update changelog --- CHANGELOG.md | 3 +-- instrumentation/net/http/otelhttp/version.go | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd2702b414d..cedb22d87da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Add unmarshaling and validation for `AttributeType`, `AttributeNameValue`, `SimpleSpanProcessor`, `SimpleLogRecordProcessor`, `ZipkinSpanExporter`, `NameStringValuePair`, `InstrumentType`, `ExperimentalPeerInstrumentationServiceMappingElem`, `ExporterDefaultHistogramAggregation`, `PullMetricReader` to v1.0.0 model in `go.opentelemetry.io/contrib/otelconf`. (#8127) ### Changed + - Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) - Improve performance by reducing allocations in the gRPC stats handler in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8035) @@ -1622,5 +1623,3 @@ First official tagged release of `contrib` repository. [Go 1.18]: https://go.dev/doc/go1.18 [GO-2024-2687]: https://pkg.go.dev/vuln/GO-2024-2687 - - diff --git a/instrumentation/net/http/otelhttp/version.go b/instrumentation/net/http/otelhttp/version.go index 44ff6b72ae7..c1b804a505a 100644 --- a/instrumentation/net/http/otelhttp/version.go +++ b/instrumentation/net/http/otelhttp/version.go @@ -5,5 +5,3 @@ package otelhttp // import "go.opentelemetry.io/contrib/instrumentation/net/http // Version is the current release version of the otelhttp instrumentation. const Version = "0.63.0" - // This string is updated by the pre_release.sh script during release - From 9f7f07cb3770bfdc4a2b30e322f7a31e2ca32e31 Mon Sep 17 00:00:00 2001 From: Andy <167682813+dogedede@users.noreply.github.com> Date: Mon, 10 Nov 2025 12:58:12 +0800 Subject: [PATCH 6/7] Update CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flcă‚› --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cedb22d87da..c1c84ebaf93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed -- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8134) +- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8142) - Improve performance by reducing allocations in the gRPC stats handler in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8035) ### Deprecated From 37c0b45c6e599f137ea166908292b1f1de6b9806 Mon Sep 17 00:00:00 2001 From: Andy <167682813+dogedede@users.noreply.github.com> Date: Mon, 10 Nov 2025 22:41:59 +0800 Subject: [PATCH 7/7] Update CHANGELOG.md Co-authored-by: Damien Mathieu <42@dmathieu.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c84ebaf93..56d370fa43d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed -- Change `Version()` function in `otelhttp` package to a `const Version` string. (#8142) +- Change `Version()` function in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to a `const Version` string. (#8142) - Improve performance by reducing allocations in the gRPC stats handler in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8035) ### Deprecated