-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
SchedulerFactoryBeanCustomizer now runs first so user customization is not overridden #3095
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…erride what it does
adinauer
requested review from
romtsn,
stefanosiano and
markushi
as code owners
December 13, 2023 06:59
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
8838e01 | 387.41 ms | 467.00 ms | 79.59 ms |
4e260b3 | 384.08 ms | 477.56 ms | 93.48 ms |
93a76ca | 377.41 ms | 448.22 ms | 70.81 ms |
0bd723b | 375.20 ms | 452.41 ms | 77.20 ms |
86f0096 | 368.63 ms | 446.92 ms | 78.29 ms |
0404ea3 | 332.47 ms | 401.12 ms | 68.66 ms |
b172d4e | 412.60 ms | 492.68 ms | 80.08 ms |
93a76ca | 397.30 ms | 455.16 ms | 57.87 ms |
8ff8fd0 | 432.77 ms | 495.18 ms | 62.41 ms |
7eccfdb | 389.94 ms | 461.29 ms | 71.35 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
8838e01 | 1.72 MiB | 2.29 MiB | 578.15 KiB |
4e260b3 | 1.72 MiB | 2.27 MiB | 554.95 KiB |
93a76ca | 1.72 MiB | 2.29 MiB | 576.75 KiB |
0bd723b | 1.72 MiB | 2.29 MiB | 578.09 KiB |
86f0096 | 1.72 MiB | 2.29 MiB | 576.50 KiB |
0404ea3 | 1.72 MiB | 2.29 MiB | 577.52 KiB |
b172d4e | 1.72 MiB | 2.29 MiB | 578.09 KiB |
93a76ca | 1.72 MiB | 2.29 MiB | 576.75 KiB |
8ff8fd0 | 1.72 MiB | 2.27 MiB | 558.15 KiB |
7eccfdb | 1.72 MiB | 2.27 MiB | 556.93 KiB |
lbloder
reviewed
Dec 18, 2023
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 Changes look good 👍
Maybe we could add tests for this behavior?
Something like this:
@Test
fun `Sentry quartz job listener is added`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true")
.withUserConfiguration(QuartzAutoConfiguration::class.java)
.run {
val jobListeners = it.getBean(Scheduler::class.java).listenerManager.jobListeners
assertThat(jobListeners).hasSize(1)
assertThat(jobListeners[0]).matches(
{ it.name == "sentry-job-listener" },
"is sentry job listener"
)
}
}
@Test
fun `user defined SchedulerFactoryBeanCustomizer overrides Sentry Customizer`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true")
.withUserConfiguration(QuartzAutoConfiguration::class.java, CustomSchedulerFactoryBeanCustomizerConfiguration::class.java)
.run {
val jobListeners = it.getBean(Scheduler::class.java).listenerManager.jobListeners
assertThat(jobListeners).hasSize(1)
assertThat(jobListeners[0]).matches(
{ it.name == "custom-job-listener" },
"is custom job listener"
)
}
}
@Configuration(proxyBeanMethods = false)
open class CustomSchedulerFactoryBeanCustomizerConfiguration {
class MyJobListener: JobListener {
override fun getName() = "custom-job-listener"
override fun jobToBeExecuted(context: JobExecutionContext?) {
//do nothing
}
override fun jobExecutionVetoed(context: JobExecutionContext?) {
//do nothing
}
override fun jobWasExecuted(
context: JobExecutionContext?,
jobException: JobExecutionException?
) {
//do nothing
}
}
@Bean
open fun mySchedulerFactoryBeanCustomizer(): SchedulerFactoryBeanCustomizer {
return SchedulerFactoryBeanCustomizer { schedulerFactoryBean -> schedulerFactoryBean.setGlobalJobListeners(MyJobListener()) }
}
}
lbloder
approved these changes
Dec 19, 2023
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.
LGTM 👍
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
We now set
@Order(Ordered.HIGHEST_PRECEDENCE)
on ourSchedulerFactoryBeanCustomizer
bean so it is called before any userSchedulerFactoryBeanCustomizer
.Due to limited API we cannot simply read all global job listeners or add ours to the list. All we can do is "set" a list containing our own thereby replacing whatever was set before.
If a user has a
SchedulerFactoryBeanCustomizer
and sets global job listeners, it should now be Sentry functionality that breaks, not user functionality. To get back the Sentry functionalitySentryJobListener
has to be added manually to the global job listeners by the user.💡 Motivation and Context
Fixes #3088
💚 How did you test it?
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps