feat(otelgrpc): reduce allocations in TagRPC #10007
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 385 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #10007"
general
weight: 0.35
MrAlias
Motivation
TagRPCis invoked on every gRPC request lifecycle across both client and server stats handlers. In high-throughput services, unnecessary heap allocations during context tagging add GC pressure and latency overhead.Previously,
internal.ParseFullMethodreturned a slice withcap=1, which forced a slice reallocation immediately when appendingsemconv.RPCSystemNameGRPCtoattrs. Additionally, both client and server handlers unconditionally created duplicate attribute slices (spanAttributesandmetricAttrs), even when no custom span attributes or metric attributes were configured.Summary
attrsininternal.ParseFullMethodwithlen=1, cap=2so appendingsemconv.RPCSystemNameGRPCfits without reallocation.spanAttributesandmetricAttrsin bothserverHandler.TagRPCandclientHandler.TagRPCwhen no custom attributes are supplied.Benchmarks
Benchmark command
``
bash id="p6t9w1"go test -run=^$ -bench='TagRPC' -benchmem -count=10
text id="r7k2mv"
goos: linux
goarch: amd64
go version: go1.26.5 linux/amd64
pkg: go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
cpu: Intel(R) Core(TM) i5-10300H CPU @ 2.50GHz
│ base_tagrpc_10.txt │ new_tagrpc_10.txt │
│ sec/op │ sec/op vs base │
ServerHandler_TagRPCNoOp-8 510.9n ± 1% 400.2n ± 1% -21.66% (p=0.000 n=10)
ClientHandler_TagRPCNoOp-8 510.1n ± 1% 395.1n ± 1% -22.56% (p=0.000 n=10)
geomean 510.5n 397.6n -22.11%
│ base_tagrpc_10.txt │ new_tagrpc_10.txt │
│ B/op │ B/op vs base │
ServerHandler_TagRPCNoOp-8 648.0 ± 0% 456.0 ± 0% -29.63% (p=0.000 n=10)
ClientHandler_TagRPCNoOp-8 648.0 ± 0% 456.0 ± 0% -29.63% (p=0.000 n=10)
geomean 648.0 456.0 -29.63%
│ base_tagrpc_10.txt │ new_tagrpc_10.txt │
│ allocs/op │ allocs/op vs base │
ServerHandler_TagRPCNoOp-8 11.000 ± 0% 9.000 ± 0% -18.18% (p=0.000 n=10)
ClientHandler_TagRPCNoOp-8 12.00 ± 0% 10.00 ± 0% -16.67% (p=0.000 n=10)
geomean 11.49 9.487 -17.43%
``
</details>
Results