Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Added

- Change `Version()` function in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to a `const Version` string. (#8142)
<!-- Released section -->
<!-- Don't change this section unless doing release -->

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func newConfig(opts ...Option) *config {

c.Meter = c.MeterProvider.Meter(
ScopeName,
metric.WithInstrumentationVersion(Version()),
metric.WithInstrumentationVersion(Version),
)

return c
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/net/http/otelhttp/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ 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)

want := metricdata.ScopeMetrics{
Scope: instrumentation.Scope{
Name: ScopeName,
Version: Version(),
Version: Version,
},
Metrics: []metricdata.Metrics{
{
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/net/http/otelhttp/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,15 @@ 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)

want := metricdata.ScopeMetrics{
Scope: instrumentation.Scope{
Name: ScopeName,
Version: Version(),
Version: Version,
},
Metrics: []metricdata.Metrics{
{
Expand Down
5 changes: 1 addition & 4 deletions instrumentation/net/http/otelhttp/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@
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.64.0"
// This string is updated by the pre_release.sh script during release
}
const Version = "0.64.0"
2 changes: 1 addition & 1 deletion instrumentation/net/http/otelhttp/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}