Skip to content

Add dual-semconv support to RPC metrics#16298

Merged
trask merged 10 commits intoopen-telemetry:mainfrom
zeitlinger:rpc-metrics-dual-semconv
Feb 27, 2026
Merged

Add dual-semconv support to RPC metrics#16298
trask merged 10 commits intoopen-telemetry:mainfrom
zeitlinger:rpc-metrics-dual-semconv

Conversation

@zeitlinger
Copy link
Member

Part of #15932 — split into smaller reviewable PRs. This is PR 4 of 5 (depends on #16130).

  • Add stable metric rpc.client.call.duration (seconds) alongside old rpc.client.duration (milliseconds)
  • Add stable metric rpc.server.call.duration (seconds) alongside old rpc.server.duration (milliseconds)
  • Update RpcMetricsAdvice with separate old/stable attribute key lists (rpc.system.name, rpc.response.status_code for stable)
  • Add OLD_RPC_METHOD_CONTEXT_KEY infrastructure for correct rpc.method handling in dup mode
  • Size metrics (rpc.*.request.size, rpc.*.response.size) remain old-only
  • Tests validate all three modes: old-only, stable-only, and dup

#15871

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>
@zeitlinger zeitlinger requested a review from a team as a code owner February 26, 2026 11:18

static final AttributeKey<String> RPC_METHOD = AttributeKey.stringKey("rpc.method");

static final ContextKey<String> OLD_RPC_METHOD_CONTEXT_KEY =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, it makes sense to me

@trask trask force-pushed the rpc-metrics-dual-semconv branch from 6fba477 to c3b295e Compare February 27, 2026 01:06
@trask trask merged commit 56a4853 into open-telemetry:main Feb 27, 2026
93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants