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

Rollback wrapping of runnables on each schedule for Spring Scheduling #7290

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

amarziali
Copy link
Collaborator

@amarziali amarziali commented Jul 8, 2024

What Does This Do

This PR rollbacks instrumenting spring scheduling TaskScheduler which was wrapping the Runnable in each schedule.
This was done as part of #6249 in order to have the right Runnable names displayed on actuator's endpoints.

Wrapping the runnable on each schedule can cause side effects if a custom task scheduler is used and if inside the schedule method instanceof is used to check whenever the Runnable is of a certain type since we're wrapping it with SpringSchedulingRunnableWrapper.

In order to be less invasive and, at same time, preserve the right labelling on actuator, I've restored the old approach instrumenting Task instead of TaskScheduler which was causing that bad behaviour. I've also overridden the toString method of SpringSchedulingRunnableWrapper in order to target the wrapped runnable instead. This will work for spring boot actuator since the displayed name is obtained calling toString (https://github.com/spring-projects/spring-boot/blob/69630bba37caa3a092b19392949705a41234d703/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/scheduling/ScheduledTasksEndpoint.java#L285)

Motivation

Additional Notes

Jira ticket: APMS-12578

@amarziali amarziali added type: bug inst: spring Spring instrumentation labels Jul 8, 2024
@amarziali amarziali requested a review from a team as a code owner July 8, 2024 08:13
@amarziali amarziali changed the title Spring scheduling: do not wrap runnabled on each schedule Spring scheduling: do not wrap runnables on each schedule Jul 8, 2024
Copy link
Contributor

@mcculls mcculls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, thanks!

@amarziali amarziali enabled auto-merge (squash) July 8, 2024 08:38
@amarziali amarziali merged commit 3daca96 into master Jul 8, 2024
80 of 84 checks passed
@amarziali amarziali deleted the andrea.marziali/spring-scheduling-plusplus branch July 8, 2024 08:49
@github-actions github-actions bot added this to the 1.38.0 milestone Jul 8, 2024
@nayeem-kamal nayeem-kamal changed the title Spring scheduling: do not wrap runnables on each schedule Rollback wrapping of runnables on each schedule for Spring Scheduling Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inst: spring Spring instrumentation type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants