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

Spring Boot logging and missing traces #165

Closed
Cimballi opened this issue Jul 19, 2021 · 5 comments · Fixed by #229
Closed

Spring Boot logging and missing traces #165

Cimballi opened this issue Jul 19, 2021 · 5 comments · Fixed by #229
Labels
component: parameter-store Parameter Store integration related issue type: enhancement Smaller enhancement in existing integration
Milestone

Comments

@Cimballi
Copy link

test-spring-logging.zip
From spring-projects/spring-boot#27406

I think there is a bug / problem in the way Spring Boot configures logging with Logback.

Using Spring Boot 2.4.8 and Spring Cloud Aws 2.31, I created a minimalist Spring Boot application with a dependency on "spring-cloud-starter-aws-parameter-store-config" using paramstore.

If I do not set any AWS credentials, the AWS SDK cannot connect, so there is an error. But Spring Boot only logs :

ERROR | org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter              | report                                   | 

***************************
APPLICATION FAILED TO START
***************************

I also added a test class without Spring Boot, using Logback and a similar AWS call, and the logs contain :

DEBUG | com.amazonaws.auth.AWSCredentialsProviderChain                                   | getCredentials                           | Unable to load credentials from WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path.
DEBUG | com.amazonaws.auth.AWSCredentialsProviderChain                                   | getCredentials                           | Unable to load credentials from com.amazonaws.auth.profile.ProfileCredentialsProvider@5ce4369b: Unable to load credentials into profile [default]: AWS Access Key ID is not specified.
WARN  | com.amazonaws.internal.InstanceMetadataServiceResourceFetcher                    | handleException                          | Fail to retrieve token 
com.amazonaws.SdkClientException: Failed to connect to service endpoint: 

So, as you can see all, those AWS logs are missing when using Spring Boot.
test-spring-logging.zip

@github-actions github-actions bot added the status: waiting-for-triage Team has not yet looked into this issue label Jul 19, 2021
@maciejwalkowiak
Copy link
Contributor

Thanks for reporting. As Andy explained in linked Spring Boot issue, AWS logs are not printed as the logging subsystem isn't ready yet. We cannot though use DeferredLog as this is a 3rd party package. We can make the logging message more self explanatory though.

Currently when I run your sample, I am getting following error message:

***************************
APPLICATION FAILED TO START
***************************

Description:

Config data resource '[AwsParamStoreConfigDataResource@758705fa context = '/config/application/', optional = false]' via location 'aws-parameterstore:' does not exist

Action:

Check that the value 'aws-parameterstore:' at class path resource [application.yml] - 13:15 is correct, or prefix it with 'optional:'

which gets resolved through ConfigDataNotFoundFailureAnalyzer. The actual cause of this exception is:

com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.

We could make it more self explanatory in AwsParamStoreConfigDataLoader and instead of simply throwing ConfigDataResourceNotFoundException, make a special case for SdkClientException when region or credentials cannot be resolved.

@maciejwalkowiak maciejwalkowiak added component: parameter-store Parameter Store integration related issue type: enhancement Smaller enhancement in existing integration and removed status: waiting-for-triage Team has not yet looked into this issue labels Jul 20, 2021
@Lucas3oo
Copy link

It would also be helpful if the execution message adds all context is can find.
Like which profiles are active etc.
I get this weird issue only in Fargate and not locally that the parameter store path is appended with the "default" profile.
E.g. /config/application_default

I don't have any spring profile settings defined (but I can't be 100% since the log is not there during startup.)

@maciejwalkowiak
Copy link
Contributor

@Lucas3oo "default" profile is the profile that is active when no other profile is active, perhaps this is where its coming from.

Have you considered using spring.config.import= instead?

@Lucas3oo
Copy link

Lucas3oo commented Feb 9, 2022

But the thing is it didn't act like this in previous version of Spring AWS cloud.
And why using spring.config.import= when the existing setup worked very well (until someone changed it)
I am not happy to change some setup that works. With spring.config.import= you still have to configure which "context" to read from so I don't see that way is any better.

@maciejwalkowiak
Copy link
Contributor

In merged PR i enabled logging for both spring.config.import and bootstrap so once 2.3.4 is released you should be able to see exactly which contexts are looked up in parameter store and which properties are loaded from this property source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: parameter-store Parameter Store integration related issue type: enhancement Smaller enhancement in existing integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants