Skip to content
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

fix grpc set metadata multi-value #11308

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

wgy035
Copy link

@wgy035 wgy035 commented May 8, 2024

Resolves #11237
removeAll key before put in grpc MetadataSetter

@wgy035 wgy035 requested a review from a team as a code owner May 8, 2024 13:00
Copy link

linux-foundation-easycla bot commented May 8, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@steverao
Copy link
Contributor

steverao commented May 9, 2024

@wgy035 Please sign the CLA.

@trask
Copy link
Member

trask commented May 9, 2024

@wgy035 can you add a test for this? (check out #2727 for possible inspiration)

@wgy035
Copy link
Author

wgy035 commented May 21, 2024

Got it. And now I'm trying to add a test.


public class GrpcPropagator implements TextMapPropagator {

public static final String FIELD = "X-grpc-field";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static final String FIELD = "X-grpc-field";
private static final String FIELD = "X-grpc-field";

Copy link
Author

Choose a reason for hiding this comment

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

done


@Override
public List<String> fields() {
return Collections.singletonList(FIELD);
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

helpful suggestions


@Test
void checkThatIterableSizeEqualsOne() {
GrpcPropagator tested = new GrpcPropagator();
Copy link
Contributor

Choose a reason for hiding this comment

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

I would define a more meaningful name here, if it's hard to do here, is the propagator a better choice than now?

Copy link
Author

Choose a reason for hiding this comment

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

I've already change the name

@laurit
Copy link
Contributor

laurit commented May 29, 2024

@wgy035 I have crated a PR for your PR wgy035#1 that changes the test so that it uses a standard propagator and verifies that injecting the tracing context twice results in the last inject overwriting the first one.

Improve grpc metadata overwrite test
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.

In io.opentelemetry.instrumentation.grpc.v1_6 the Setter duplicates instead of replacing
4 participants