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

Issue with the sleuth Baggage for setting local fields using property "spring.sleuth.baggage.local-fields" #2138

Closed
bharatvarshney2022 opened this issue Mar 29, 2022 · 11 comments

Comments

@bharatvarshney2022
Copy link

Describe the bug
Issue with the sleuth Baggage for setting local fields using property "spring.sleuth.baggage.local-fields", "spring.sleuth.bagdgage.correlation-fields", understanding is that if we set this property with specified property then local fields(which are not supposed to travel over wire) will be setup and injected in the MDC map.
Which is not happening currently!!

Whereas if "spring.sleuth.baggage.remote-fields" and "spring.sleuth.bagdgage.correlation-fields" properties are set then its working as expected, values are transferred to MDC automatically and injected in the headers which can be transferred over wire automatically.
Which is working as expected.

Sample

E.g

Version

Pom.xml

<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
<sleuth.version>2.2.6.RELEASE</sleuth.version>

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-zipkin</artifactId>
  <version>${sleuth.version}</version>
</dependency>

application.properties
spring.sleuth.bagdgage.correlation-fields=user_name
spring.sleuth.baggage.local-fields=user_name

Controller classes if we access like MDC.get("user_name")
Not able to get the value over here!!!


Value of the "user_name" is passed as the header value in the REST API call.
user_name:testing_header

@marcingrzejszczak
Copy link
Contributor

Can you provide a complete, minimal, verifiable sample that reproduces the problem rather than pasted code? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Also please update to the latest version of cloud and boot and please tell us if the problem persists.

@bharatvarshney2022
Copy link
Author

Thanks @marcingrzejszczak for the suggestions. Checked with the latest version, still not worked.
Will upload the sample code base shortly.

@tarunlalwani
Copy link

@bharatvarshney2022 , please update the latest sample code

@spring-cloud-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-cloud-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@norbertwnuk
Copy link

norbertwnuk commented May 27, 2022

I would like ask to re-open this defect, observe exactly the same behavior for MDC and BaggageField.getAllValues(), when the header is not added to remote-fields. At least for BaggageField.getAllValues() is seems to be related to MAP_STRING_STRING_BUILDER logic. This behavior is inconsistent with what documentation says about BaggageField and MDC when combined with local fields.

spring:
  sleuth:
    baggage:
      remote-fields:
        - x-request-id
      local-fields:
        - x-request-id-2
      correlation-fields:
        - x-request-id
        - x-request-id-2
      tag-fields:
        - x-request-id
        - x-request-id-2

image

image

@marcingrzejszczak
Copy link
Contributor

Have you configured the BaggageFields to flush on update? Maybe that's why you don't see it yet. Do you have a sample that I could play around with?

@norbertwnuk
Copy link

norbertwnuk commented May 30, 2022

@marcingrzejszczak - from what i see flush on update does not change the behavior, the sample code is here.

@norbertwnuk
Copy link

@marcingrzejszczak - can we re-open this issue / should I create a new one - since the failing example has been attached above.

@grassehh
Copy link

grassehh commented Jul 11, 2023

Hello, it seems this issue is still present with Spring Boot 3 / Micrometer. I have created an issue to Brave because after some analysis it seems to be an implementatiion behavior (Seems to have something to do with the way the correlation fields are stored in TraceContext.extraList property).

@marcingrzejszczak
Copy link
Contributor

The issue seems to be there in Brave

@marcingrzejszczak marcingrzejszczak closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants