Skip to content

Commit 18da5d8

Browse files
ElenaZverevapellareddmathieu
authored
Switch version from function to string in otelgrpc (#8317)
Co-authored-by: Robert Pająk <pellared@hotmail.com> Co-authored-by: Damien Mathieu <42@dmathieu.com>
1 parent 1139186 commit 18da5d8

6 files changed

Lines changed: 10 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
4545
- Set `error.type` attribute instead of adding `exception` span events in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#8386)
4646
- 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)
4747
- The `Version()` function in `go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo` hae been replaced by `const Version`. (#8340)
48+
- The `Version()` function in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` has been replaced by `const Version`. (#8317)
4849

4950
<!-- Released section -->
5051
<!-- Don't change this section unless doing release -->

instrumentation/google.golang.org/grpc/otelgrpc/grpc_stats_handler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ func checkClientMetrics(t *testing.T, reader metric.Reader) {
722722
expectedScopeMetric := metricdata.ScopeMetrics{
723723
Scope: instrumentation.Scope{
724724
Name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc",
725-
Version: otelgrpc.Version(),
725+
Version: otelgrpc.Version,
726726
SchemaURL: semconv.SchemaURL,
727727
},
728728
Metrics: []metricdata.Metrics{
@@ -1100,7 +1100,7 @@ func checkServerMetrics(t *testing.T, reader metric.Reader) {
11001100
expectedScopeMetric := metricdata.ScopeMetrics{
11011101
Scope: instrumentation.Scope{
11021102
Name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc",
1103-
Version: otelgrpc.Version(),
1103+
Version: otelgrpc.Version,
11041104
SchemaURL: semconv.SchemaURL,
11051105
},
11061106
Metrics: []metricdata.Metrics{

instrumentation/google.golang.org/grpc/otelgrpc/grpc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
var wantInstrumentationScope = instrumentation.Scope{
2626
Name: "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc",
2727
SchemaURL: semconv.SchemaURL,
28-
Version: otelgrpc.Version(),
28+
Version: otelgrpc.Version,
2929
}
3030

3131
// newGrpcTest creates a grpc server, starts it, and returns the client, closes everything down during test cleanup.

instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ func NewServerHandler(opts ...Option) stats.Handler {
5252

5353
h.tracer = c.TracerProvider.Tracer(
5454
ScopeName,
55-
trace.WithInstrumentationVersion(Version()),
55+
trace.WithInstrumentationVersion(Version),
5656
)
5757

5858
meter := c.MeterProvider.Meter(
5959
ScopeName,
60-
metric.WithInstrumentationVersion(Version()),
60+
metric.WithInstrumentationVersion(Version),
6161
metric.WithSchemaURL(semconv.SchemaURL),
6262
)
6363

@@ -181,12 +181,12 @@ func NewClientHandler(opts ...Option) stats.Handler {
181181

182182
h.tracer = c.TracerProvider.Tracer(
183183
ScopeName,
184-
trace.WithInstrumentationVersion(Version()),
184+
trace.WithInstrumentationVersion(Version),
185185
)
186186

187187
meter := c.MeterProvider.Meter(
188188
ScopeName,
189-
metric.WithInstrumentationVersion(Version()),
189+
metric.WithInstrumentationVersion(Version),
190190
metric.WithSchemaURL(semconv.SchemaURL),
191191
)
192192

instrumentation/google.golang.org/grpc/otelgrpc/version.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
55

66
// Version is the current release version of the gRPC instrumentation.
7-
func Version() string {
8-
return "0.64.0"
9-
// This string is updated by the pre_release.sh script during release
10-
}
7+
const Version = "0.64.0"

instrumentation/google.golang.org/grpc/otelgrpc/version_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ var versionRegex = regexp.MustCompile(`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)
1919
`(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`)
2020

2121
func TestVersionSemver(t *testing.T) {
22-
v := otelgrpc.Version()
22+
v := otelgrpc.Version
2323
assert.NotNil(t, versionRegex.FindStringSubmatch(v), "version is not semver: %s", v)
2424
}

0 commit comments

Comments
 (0)