-
Notifications
You must be signed in to change notification settings - Fork 319
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: add runtime hints for logging #1933
Conversation
1119f05
to
77e831c
Compare
force-pushed to rebase on main. |
…property when doing native test.
…oot-starter-parent.
.github/workflows/NativeTests.yaml
Outdated
- name: Install pubsub-emulator | ||
if: ${{ matrix.it == 'pubsub-emulator' }} | ||
run: | | ||
gcloud components install pubsub-emulator beta && \ | ||
gcloud components update |
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.
I think matrix.it
is always null. Can this step be removed?
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.
will do.
public class LoggingRuntimeHints implements RuntimeHintsRegistrar { | ||
@Override | ||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) { | ||
hints | ||
.reflection() | ||
.registerTypes( | ||
Arrays.asList( | ||
TypeReference.of(LoggingAppender.class), | ||
TypeReference.of(TraceIdLoggingEnhancer.class), | ||
TypeReference.of(StackdriverJsonLayout.class)), | ||
hint -> | ||
hint.withMembers( | ||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, | ||
MemberCategory.INVOKE_PUBLIC_METHODS)); | ||
} | ||
} |
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.
Out of curiosity, do we notice any advantages with using the RuntimeHintsRegistrar class over using static reflection configurations?
Mostly in terms of choosing the static jsons vs a dynamic way of registering classes for reflection, I'm wondering if we will run into any breaking changes when we upgrade our Spring stack that introduces some changes to it's class definition.
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.
Good question! I went this way because it's documented and to be consistent to spring conventions, I notice spring-boot and spring-data projects are using this RuntimeHintsRegistar
(e.g. logging autoconfig)
Some other benefit include: this allows hints be tested; It's easy use spring concepts when registering hints (for example in vision, this is for the test resources, but you can easily refer to spring resources when registering.)
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.
Thanks for the context! Considering this resolved to unblock this PR. Discussion has been moved offline.
Kudos, SonarCloud Quality Gate passed! |
public class LoggingRuntimeHints implements RuntimeHintsRegistrar { | ||
@Override | ||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) { | ||
hints | ||
.reflection() | ||
.registerTypes( | ||
Arrays.asList( | ||
TypeReference.of(LoggingAppender.class), | ||
TypeReference.of(TraceIdLoggingEnhancer.class), | ||
TypeReference.of(StackdriverJsonLayout.class)), | ||
hint -> | ||
hint.withMembers( | ||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, | ||
MemberCategory.INVOKE_PUBLIC_METHODS)); | ||
} | ||
} |
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.
Thanks for the context! Considering this resolved to unblock this PR. Discussion has been moved offline.
Need rebase after setups in #1931 are merged in.This pr adds:
CI for native is setup to run on sample integration tests that:
it.xx
property added to systemPropertyVariablesModification to
spring-cloud-gcp-samples/pom.xml
so that:--define notAllModules=true
in mvn cmd.This is needed because native test would fail on no test configuration found.
To verify locally:
mvn spring-boot:run
, package withmvn clean package -Pnative-sample-config -Pnative
./target/spring-cloud-gcp-logging-sample
mvn -PnativeTest clean test -Pnative-sample-config