opentelemetry-go-contrib icon indicating copy to clipboard operation
opentelemetry-go-contrib copied to clipboard

[otelgrpc] add metric rpc.server.duration support

Open fatsheep9146 opened this issue 3 years ago • 8 comments

Signed-off-by: Ziqi Zhao [email protected]

Enhance instrumentation library otelgrpc for grpc to satisfy opentelemetry grpc server metric semantic conventions.

This pr is meant to add metric rpc.server.duration for the first step.

I use example code to test, and produce the data for unary and stream request

{
    "Name": "rpc.server.duration{service.name=unknown_service:main,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.9.0,instrumentation.name=go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc,instrumentation.version=semver:0.34.0,net.peer.ip=127.0.0.1,net.peer.port=55809,rpc.grpc.status_code=0,rpc.method=SayHelloServerStream,rpc.service=api.HelloService,rpc.system=grpc}",
    "Sum": 502.366387
},
{
    "Name": "rpc.server.duration{service.name=unknown_service:main,telemetry.sdk.language=go,telemetry.sdk.name=opentelemetry,telemetry.sdk.version=1.9.0,instrumentation.name=go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc,instrumentation.version=semver:0.34.0,net.peer.ip=127.0.0.1,net.peer.port=55809,rpc.grpc.status_code=0,rpc.method=SayHelloBidiStream,rpc.service=api.HelloService,rpc.system=grpc}",
    "Sum": 253.394227
}

fatsheep9146 avatar Aug 31 '22 05:08 fatsheep9146

You need to run go mod tidy from the otelgrpc package to fix the tests. Also, this will need a changelog entry.

dmathieu avatar Aug 31 '22 06:08 dmathieu

Codecov Report

Merging #2700 (41f7fb7) into main (bba2c55) will increase coverage by 0.0%. The diff coverage is 63.6%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2700   +/-   ##
=====================================
  Coverage   69.3%   69.4%           
=====================================
  Files        145     146    +1     
  Lines       6729    6752   +23     
=====================================
+ Hits        4667    4689   +22     
+ Misses      1948    1946    -2     
- Partials     114     117    +3     
Impacted Files Coverage Δ
...ogle.golang.org/grpc/otelgrpc/metadata_supplier.go 51.1% <51.1%> (ø)
...entation/google.golang.org/grpc/otelgrpc/config.go 65.1% <80.0%> (ø)
...ion/google.golang.org/grpc/otelgrpc/interceptor.go 83.0% <100.0%> (-0.6%) :arrow_down:

codecov[bot] avatar Aug 31 '22 10:08 codecov[bot]

@dmathieu @Aneurysm9 All checks are passed, could you help review this again?

fatsheep9146 avatar Sep 02 '22 12:09 fatsheep9146

Could you help review this again? @dmathieu

fatsheep9146 avatar Sep 07 '22 15:09 fatsheep9146

@Aneurysm9 @jmacd @MrAlias @hanyuancheung

Could you help review this again?

fatsheep9146 avatar Sep 09 '22 09:09 fatsheep9146

Hi, stumbled across this, and had two questions about the units

  • ~Why milliseconds? Looks like its a float64 anyway, so the position of the decimal makes no technical difference, so seconds would seem like a better choice simply for being the SI standard.~ nevermind, spotted the unit specification in the upstream spec.
  • Does the unit need to be indicated somewhere? I had to dig into the recording code to find it.

devnev avatar Sep 11 '22 09:09 devnev

@devnev I think you can visit here to find the info about all metrics. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#rpc-server

Hi, stumbled across this, and had two questions about the units

  • ~Why milliseconds? Looks like its a float64 anyway, so the position of the decimal makes no technical difference, so seconds would seem like a better choice simply for being the SI standard.~ nevermind, spotted the unit specification in the upstream spec.
  • Does the unit need to be indicated somewhere? I had to dig into the recording code to find it.

fatsheep9146 avatar Sep 13 '22 05:09 fatsheep9146

ping @pellared @Aneurysm9 @MrAlias @jmacd @dashpole @MadVikingGod @evantorrie @XSAM , could you help review this again?

fatsheep9146 avatar Sep 19 '22 05:09 fatsheep9146

ping @pellared @Aneurysm9 @MrAlias @jmacd @dashpole @MadVikingGod @evantorrie @XSAM could you help review this?

fatsheep9146 avatar Sep 27 '22 05:09 fatsheep9146

Is the plan to add the other specified metrics (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#rpc-server) in follow on PRs? If so, can you open an issue to track the work?

MrAlias avatar Oct 04 '22 18:10 MrAlias

Is the plan to add the other specified metrics (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#rpc-server) in follow on PRs? If so, can you open an issue to track the work?

Absolutely, I already open an issue #2840 to track, and I will add the metric one by one. @MrAlias

fatsheep9146 avatar Oct 07 '22 02:10 fatsheep9146

Could you help review this again? @MrAlias

fatsheep9146 avatar Oct 19 '22 23:10 fatsheep9146

@jmacd @pellared @Aneurysm9 Could you help review this again?

fatsheep9146 avatar Oct 23 '22 05:10 fatsheep9146

BTW... The new spec is moved to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc-metrics.md

liufuyang avatar Feb 21 '23 12:02 liufuyang