Add dual-semconv support to RPC metrics#16298
Conversation
Add stable RPC metric rpc.client.call.duration (seconds) alongside old rpc.client.duration (milliseconds), and rpc.server.call.duration alongside rpc.server.duration, controlled by SemconvStability flags. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
|
|
||
| static final AttributeKey<String> RPC_METHOD = AttributeKey.stringKey("rpc.method"); | ||
|
|
||
| static final ContextKey<String> OLD_RPC_METHOD_CONTEXT_KEY = |
There was a problem hiding this comment.
@trask In #15932 you commented that under rpc/dup, stable semconv should take priority and there's no need for this extra context key.
The reason it exists: in dup mode, both old and stable metrics use the same rpc.method attribute key but with different values — old uses just the method name ("exampleMethod"), stable uses "service/method" format ("myservice.EchoService/exampleMethod"). Since both values live in the same Attributes object, stable wins and overwrites old.
Without this context key, the old rpc.server.duration / rpc.client.duration histograms would report rpc.method = "myservice.EchoService/exampleMethod" instead of "exampleMethod" — a breaking change for anyone querying old metrics during migration (which is the whole point of dup mode).
The context key is never emitted — it just passes the old method value through Context so the metrics classes can swap it back when recording to old histograms.
Happy to drop this if you think letting the values clash in dup mode is acceptable. Just wanted to make sure the trade-off is clear.
...io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcCommonAttributesExtractor.java
Outdated
Show resolved
Hide resolved
6fba477 to
c3b295e
Compare
Part of #15932 — split into smaller reviewable PRs. This is PR 4 of 5 (depends on #16130).
rpc.client.call.duration(seconds) alongside oldrpc.client.duration(milliseconds)rpc.server.call.duration(seconds) alongside oldrpc.server.duration(milliseconds)RpcMetricsAdvicewith separate old/stable attribute key lists (rpc.system.name,rpc.response.status_codefor stable)OLD_RPC_METHOD_CONTEXT_KEYinfrastructure for correctrpc.methodhandling in dup moderpc.*.request.size,rpc.*.response.size) remain old-only#15871