-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add dual-semconv support to RPC metrics #16298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9af44cf
c5ffdac
15fc741
98a6473
01fbee6
86ce475
2352c20
5b82e61
6c3a8b5
c3b295e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,33 @@ | |
| import io.opentelemetry.api.common.AttributeKey; | ||
| import io.opentelemetry.api.common.AttributesBuilder; | ||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.context.ContextKey; | ||
| import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; | ||
| import io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE> | ||
| public abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE> | ||
| implements AttributesExtractor<REQUEST, RESPONSE> { | ||
|
|
||
| static final AttributeKey<String> RPC_METHOD = AttributeKey.stringKey("rpc.method"); | ||
|
|
||
| static final ContextKey<String> OLD_RPC_METHOD_CONTEXT_KEY = | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @trask In #15932 you commented that under The reason it exists: in dup mode, both old and stable metrics use the same Without this context key, the old The context key is never emitted — it just passes the old method value through 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, it makes sense to me |
||
| ContextKey.named("otel-rpc-old-method"); | ||
|
|
||
| @SuppressWarnings("deprecation") // for getMethod() | ||
| public static <REQUEST> ContextCustomizer<REQUEST> oldMethodContextCustomizer( | ||
| RpcAttributesGetter<REQUEST, ?> getter) { | ||
| return (context, request, startAttributes) -> { | ||
| if (emitOldRpcSemconv() && emitStableRpcSemconv()) { | ||
| String oldMethod = getter.getMethod(request); | ||
| if (oldMethod != null) { | ||
| return context.with(OLD_RPC_METHOD_CONTEXT_KEY, oldMethod); | ||
| } | ||
| } | ||
| return context; | ||
| }; | ||
| } | ||
|
|
||
| // Stable semconv keys | ||
| static final AttributeKey<String> RPC_SYSTEM_NAME = AttributeKey.stringKey("rpc.system.name"); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.