-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support Tracing of Dependency Injection #11449
base: 4.8.x
Are you sure you want to change the base?
Conversation
3735137
to
e01e206
Compare
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
type, | ||
generics | ||
); | ||
Optional<String> q = annotationMetadata.getAnnotationNameByStereotype(AnnotationUtil.QUALIFIER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can use similar code to Qualifiers.forArgument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code here is in core which can't reference inject
inject/src/main/java/io/micronaut/context/ApplicationContextBuilder.java
Outdated
Show resolved
Hide resolved
return Set.of(); | ||
} | ||
|
||
void startTrace( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move all the tracing code into some other class, not to have it in a public enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the trace methods are not currently public but package private. In the future yes it would be good to add a public API but for the moment it is package private / internal
try (BeanResolutionContext resolutionContext = newResolutionContext(beanDefinition, null)) { | ||
T bean; | ||
if (beanDefinition instanceof InstantiatableBeanDefinition<T> instantiatableBeanDefinition) { | ||
bean = resolveByBeanFactory(resolutionContext, instantiatableBeanDefinition, qualifier, argumentValues); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't create a new out-scope variable, just call return postBeanCreated
right after. Next else is not needed. Same pattern repeats a few times
inject/src/main/java/io/micronaut/context/env/PropertySource.java
Outdated
Show resolved
Hide resolved
inject/src/main/java/io/micronaut/context/env/PropertySource.java
Outdated
Show resolved
Hide resolved
Can you show an example of the output? |
079f97d
to
25e2da1
Compare
Adds the ability to trace the behaviour of dependency and configuration injection. Can be activated a number of different ways, the simplest being an environment variable:
Which enables useful output such as what is the configuration profile of the application, where configuration is read from, what beans are created, how long the bean took to be created, the graph of the bean creation and where it was created from.
To support this, the PR also adds property origin tracking so that one can inspect where a property originated from.
In addition, some of the changes in
DefaultBeanContext
are in order to reduce stack trace sizes which were starting to get out of hand.