-
Notifications
You must be signed in to change notification settings - Fork 879
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
In io.opentelemetry.instrumentation.grpc.v1_6
the Setter duplicates instead of replacing
#11237
Comments
Lifecycle of Metadata is a single RPC call. Maybe the better behavior is |
I saw you created relevant PR. So I assigned this to you now. @wgy035 |
@cleverchuk would it be possible to provide a sample application that reproduces the issue. We need to build a test for this before #11308 can be merged. |
@laurit Reproduction needs to create a custom propagator. So when there's a custom propagator that injects let's say a vendor specific key into the class GrpcPropagator implements TextMapPropagator {
@Override
public Collection<String> fields() {
return null;
}
@Override
public <C> void inject(Context context, C carrier, TextMapSetter<C> setter) {
setter.set(carrier, "key", "value");
setter.set(carrier, "key", "value");
}
@Override
public <C> Context extract(Context context, C carrier, TextMapGetter<C> getter) {
return null;
}
}
@Test
void checkThatIterableSizeIsGreaterThanOne() {
GrpcPropagator tested = new GrpcPropagator();
Metadata metadata = new Metadata();
tested.inject(Context.current(), metadata, MetadataSetter.INSTANCE);
int size = 0;
for (String s : metadata.getAll(
Metadata.Key.of("key", Metadata.ASCII_STRING_MARSHALLER))) {
size++;
}
assertTrue(size > 1);
} |
Describe the bug
In this code block the carrier happens to be implemented as a multi-value map. This makes adding the same key with new value a none replacing operation. This behavior will cause the metadata transported across multiple services to keep growing as they update the
traceparent
ortracestate
or any key.Steps to reproduce
Setup three
grpc
service that communicate in linear fashion i.e A -> B -> C each instrumented with the agent. Log the carrier to console.Expected behavior
For example if the agent is updating
tracestate
with the name of the service then the metadata log line in each service should likeA: [tracestate=name=A]
B: [tracestate=name=B]
C: [tracestate=name=C]
Actual behavior
A: [tracestate=name=A]
B: [tracestate=name=B, tracestate=name=A]
C: [tracestate=name=C, tracestate=name=B, tracestate=name=A]
Javaagent or library instrumentation version
v2.3.0
Environment
JDK: openjdk:17
OS: MacOS 14.4.1
Additional context
No response
The text was updated successfully, but these errors were encountered: