diff --git a/CHANGELOG.md b/CHANGELOG.md index 73dbe1eb237..43568022bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Set `error.type` attribute instead of adding `exception` span events in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#8386) - Set `error.type` attribute instead of adding `exception` span events in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`. (#8386) - The `Version()` function in `go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo` hae been replaced by `const Version`. (#8340) +- The `Version()` function in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` has been replaced by `const Version`. (#8317) diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/grpc_stats_handler_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/grpc_stats_handler_test.go index 00fd633b8af..4245391e677 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/grpc_stats_handler_test.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/grpc_stats_handler_test.go @@ -722,7 +722,7 @@ func checkClientMetrics(t *testing.T, reader metric.Reader) { expectedScopeMetric := metricdata.ScopeMetrics{ Scope: instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc", - Version: otelgrpc.Version(), + Version: otelgrpc.Version, SchemaURL: semconv.SchemaURL, }, Metrics: []metricdata.Metrics{ @@ -1100,7 +1100,7 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) { expectedScopeMetric := metricdata.ScopeMetrics{ Scope: instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc", - Version: otelgrpc.Version(), + Version: otelgrpc.Version, SchemaURL: semconv.SchemaURL, }, Metrics: []metricdata.Metrics{ diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/grpc_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/grpc_test.go index 74070d85fb7..4d6fc7579e9 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/grpc_test.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/grpc_test.go @@ -25,7 +25,7 @@ import ( var wantInstrumentationScope = instrumentation.Scope{ Name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc", SchemaURL: semconv.SchemaURL, - Version: otelgrpc.Version(), + Version: otelgrpc.Version, } // newGrpcTest creates a grpc server, starts it, and returns the client, closes everything down during test cleanup. diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go b/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go index 220aa8c3135..ec322d9de5e 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go @@ -52,12 +52,12 @@ func NewServerHandler(opts ...Option) stats.Handler { h.tracer = c.TracerProvider.Tracer( ScopeName, - trace.WithInstrumentationVersion(Version()), + trace.WithInstrumentationVersion(Version), ) meter := c.MeterProvider.Meter( ScopeName, - metric.WithInstrumentationVersion(Version()), + metric.WithInstrumentationVersion(Version), metric.WithSchemaURL(semconv.SchemaURL), ) @@ -181,12 +181,12 @@ func NewClientHandler(opts ...Option) stats.Handler { h.tracer = c.TracerProvider.Tracer( ScopeName, - trace.WithInstrumentationVersion(Version()), + trace.WithInstrumentationVersion(Version), ) meter := c.MeterProvider.Meter( ScopeName, - metric.WithInstrumentationVersion(Version()), + metric.WithInstrumentationVersion(Version), metric.WithSchemaURL(semconv.SchemaURL), ) diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/version.go b/instrumentation/google.golang.org/grpc/otelgrpc/version.go index 98f148be5dd..e3e1578626c 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/version.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/version.go @@ -4,7 +4,4 @@ package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" // Version is the current release version of the gRPC 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" diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/version_test.go b/instrumentation/google.golang.org/grpc/otelgrpc/version_test.go index 6dfa1e6f528..64bbec34ac2 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/version_test.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/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 := otelgrpc.Version() + v := otelgrpc.Version assert.NotNil(t, versionRegex.FindStringSubmatch(v), "version is not semver: %s", v) }