Repository navigation
Fix routing key order in OTLP metrics v1 forwarder - #292
Merged
Merged
Conversation
generateRoutingKey previously concatenated values in the arrival order of resource attributes, so the same service could produce different keys (e.g. ",X,Y" vs ",Y,X") when the attribute order changed between reports. Since the key feeds the load balancer hash and the upstream cache, this could route the same service to different backends and break cache stickiness. Build the key in metadataKeys order instead: index the first value of each attribute key, then join in configured order. Semantics are otherwise unchanged: the first resource yielding a non-empty key still wins, and both error branches are preserved. Also fix a typo in the trailing error message (anly -> only).
Member
|
infra-e2e should need to update to follow Ubuntu latest changed. |
mrproliu
reviewed
Nov 1, 2026
mrproliu
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Could you help to update the changed.md?
Contributor
Author
|
Done — added a 1.4.0 Bug Fixes entry to CHANGES.md (commit 97c3d46). Thanks for the review! |
mrproliu
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
plugins/forwarder/grpc/otlpmetricsv1/forwarder.go'sgenerateRoutingKeyconcatenated routing values in the arrival order of the resource attributes (outer loop over attributes, inner loop overmetadataKeys), not in the configuredmetadataKeysorder. The same service can therefore produce different keys across reports when the attribute order changes, e.g.,X,Yvs,Y,X.Call chain / impact
Forwarder.Forward->generateRoutingKey->lb.WithLoadBalanceConfig(ctx, key, loadCachedPeer(key))->satelliteDynamicPicker.Pick, which computeshashCode(routeKey) % connCountwherehashCodeiscrc32.ChecksumIEEE(plugins/client/grpc/lb/load_balancer.go). A different key string can therefore hash to a different backend, and theupstreamCacheentry keyed by the old string no longer matches, so cache stickiness is lost.Fix
Build the key in
metadataKeysorder: index the first value of each attribute key, then join values in configured order. Otherwise unchanged:anly->only.GetStringValue(), as before.Tests (RED -> GREEN)
New
plugins/forwarder/grpc/otlpmetricsv1/forwarder_test.gocovers: same attribute set in two arrival orders yields the same key inmetadataKeysorder; a resource without a routing key is skipped; attributes without any routing key still error.Before the fix, the order test failed with:
routing key depends on attribute arrival order: ",my-job,my-service" vs ",my-service,my-job"After the fix, local run of the affected package only:
go test ./plugins/forwarder/grpc/otlpmetricsv1/ -v3 passed, 0 failed (TestGenerateRoutingKeyFollowsMetadataKeyOrder, TestGenerateRoutingKeySkipsResourceWithoutRoutingKey, TestGenerateRoutingKeyNoRoutingKey);
go veton the package is clean.Note: this PR is on the SkyWalking PMC track and is not claimed toward any external PR-count goal.