From 8041c7b865ed5b6ed67df400db9d9f24a3c3c588 Mon Sep 17 00:00:00 2001 From: Ziqi Zhao Date: Thu, 20 Oct 2022 07:06:24 +0800 Subject: [PATCH] fix for reviews Signed-off-by: Ziqi Zhao --- CHANGELOG.md | 6 +----- instrumentation/README.md | 2 +- instrumentation/google.golang.org/grpc/otelgrpc/config.go | 5 +++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cee9b8d9d1e..f90690044bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Add trace context propagation support to `instrumentation/github.com/aws/aws-sdk-go-v2/otelaws` (#2856). -- [otelgrpc] add metric `rpc.server.duration` to otelgrpc instrumentation library. (#2700) +- [otelgrpc] Add `WithMeterProvider` function to enable metric and add metric `rpc.server.duration` to otelgrpc instrumentation library. (#2700) ## [1.11.0/0.36.3/0.5.1] @@ -32,10 +32,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `Inject` function in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` is deprecated. (#2838) - The `Extract` function in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` is deprecated. (#2838) -### Added - -- [otelgrpc] Add `WithMeterProvider` function to enable metric and add metric `rpc.server.duration` to otelgrpc instrumentation library. (#2700) - ## [0.36.1] ### Changed diff --git a/instrumentation/README.md b/instrumentation/README.md index 76b34325b38..f645f7c2d5c 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -53,7 +53,7 @@ The following instrumentation packages are provided for popular Go packages and | [github.com/labstack/echo](./github.com/labstack/echo/otelecho) | | ✓ | | [github.com/Shopify/sarama](./github.com/Shopify/sarama/otelsarama) | | ✓ | | [go.mongodb.org/mongo-driver](./go.mongodb.org/mongo-driver/mongo/otelmongo) | | ✓ | -| [google.golang.org/grpc](./google.golang.org/grpc/otelgrpc) | | ✓ | +| [google.golang.org/grpc](./google.golang.org/grpc/otelgrpc) | ✓ | ✓ | | [gopkg.in/macaron.v1](./gopkg.in/macaron.v1/otelmacaron) | | ✓ | | [host](./host) | ✓ | | | [net/http](./net/http/otelhttp) | ✓ | ✓ | diff --git a/instrumentation/google.golang.org/grpc/otelgrpc/config.go b/instrumentation/google.golang.org/grpc/otelgrpc/config.go index 478e006019f..369ebae24a5 100644 --- a/instrumentation/google.golang.org/grpc/otelgrpc/config.go +++ b/instrumentation/google.golang.org/grpc/otelgrpc/config.go @@ -19,7 +19,9 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/global" + "go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric/unit" "go.opentelemetry.io/otel/propagation" semconv "go.opentelemetry.io/otel/semconv/v1.12.0" "go.opentelemetry.io/otel/trace" @@ -70,8 +72,7 @@ func newConfig(opts []Option) *config { metric.WithSchemaURL(semconv.SchemaURL), ) var err error - // the unit of rpc.server.duration is milliseconds - if c.rpcServerDuration, err = c.meter.SyncInt64().Histogram("rpc.server.duration"); err != nil { + if c.rpcServerDuration, err = c.meter.SyncInt64().Histogram("rpc.server.duration", instrument.WithUnit(unit.Milliseconds)); err != nil { otel.Handle(err) }