-
Notifications
You must be signed in to change notification settings - Fork 783
Sleuth overrides a user's logging.pattern.level when it's configured in bootstrap.yml #1863
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
Comments
My understanding was that the Sleuth's environment post processor was adding the default at the end of all property sources cc @dsyer (https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceEnvironmentPostProcessor.java#L46-L50). Which means that the client could override it by simply providing property of their own. |
Yeah, that seems to be what happens but the ordering is then changed later on such that |
Interesting... Do we have any idea when this stopped happening? Is it a problem in the latest boot too (where |
Oh I see the analysis - spring-projects/spring-boot#25418 (comment) - I'll go through it |
In general in Spring Cloud 2020.x the spring:
config:
import: 'optional:configserver:'
spring.application.name: spring-logging-sleuth-override
logging.pattern.level: '%clr(%5p) %clr([traceid=%X{traceId:-} spanid=%X{spanId:-} parentspanid=%X{parentId:-}]){green}' As for the Sleuth code - it was written years ago and hasn't changed at all. We're adding our map with the default logging pattern at the end of all property sources private void addOrReplace(MutablePropertySources propertySources, Map<String, Object> map) {
MapPropertySource target = null;
if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
PropertySource<?> source = propertySources.get(PROPERTY_SOURCE_NAME);
if (source instanceof MapPropertySource) {
target = (MapPropertySource) source;
for (String key : map.keySet()) {
if (!target.containsProperty(key)) {
target.getSource().put(key, map.get(key));
}
}
}
}
if (target == null) {
target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
}
if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
propertySources.addLast(target);
}
} We're inserting ourselves last. I even ensured that the
it stops working well for the actual context
|
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. |
I'm not sure what feedback you're waiting for here. As we discussed on Slack, I'm not sure that this has ever worked. I went as far back as Spring Boot 2.2.0 and it didn't look like the property source ended up in the right place once all the bootstrap stuff had settled down. @artemy Is switching from the bootstrap context to a |
@wilkinsona thanks for the investigation. Yes, using |
I'm closing this issue with the note that the correct way to go is to use |
What about users of Spring Boot 2.3 where |
I've added a parameter |
I can see this spring.sleuth.default-logging-pattern-enabled is available in 2.2 Was there a reason this was not ported to v3.x? |
Yes, because starting from Sleuth 3.x you should not be using |
Thanks for the prompt response! We're not using
Is this a valid case to port the |
The thing is that your stuff should not be overridden by what Sleuth does. Can you create a small reproducer for this? |
@marcingrzejszczak Created a minimal reproduction repo https://github.com/spicalous/sleuth-override-example |
I've raised a PR to reintroduce the configuration back #2196 Please let me know your thoughts :) |
* 1863: port over default-logging-pattern-enabled flag to v3 #1863 * #1863 fix logic + add tests Co-authored-by: lertlub <[email protected]>
Describe the bug
Sleuth's default
logging.pattern.level
should not apply when the user has configured their own, however it is taking precedence when the user has configured their own in bootstrap.yml. Please see spring-projects/spring-boot#25418 for details. I'm not sure if this is a Sleuth problem or a more general Spring Cloud Commons problem.Sample
There's a sample in the Spring Boot issue along with some initial analysis.
The text was updated successfully, but these errors were encountered: