Comments (4)
I'm not sure I understand the use case here.
- For some of them, we first check if they are on pause or not (pause is triggered by an external event) and we only want an observation (and sub observations) if it's not on pause
How would you detect that a scheduled method would be on pause? What do you mean by that? Would it require the execution to be ongoing?
Then, I tried the following
All the solutions you've described could be implemented with an ObservationPredicate
that looks at the observation context and checks the ScheduledTaskObservationContext#getMethod()
for custom annotations. I don't think you would need to override any Spring Boot configuration nor implement your own ScheduledAnnotationBeanPostProcessor
.
I'm probably missing something here.
from spring-boot.
Hi @bclozel
How would you detect that a scheduled method would be on pause? What do you mean by that? Would it require the execution to be ongoing?
I have some scheduled tasks that are triggered frequently, but can decide by themselves to be on pause until a given time depending on some conditions.
For example, one scheduled task is used to purge data older than 30 days. Each time it's triggered, it retrieves the oldest data and purge it if it's older than 30 days. If it's not, then it decides to be on pause until this oldest data is 30 days old. That's just an example.
I'm probably missing something here.
Well, the problem is with children spans : if the ObservationPredicate says false, a NOOP observation is created and becomes the current observation. If the code called by the scheduled task creates also an observation, as its parent span is a NOOP, it will also be a NOOP. That's why it works for behavior 2, the scheduled task and children spans are NOOP. For behavior 3, I want children spans to be actual spans. With the ObservationPredicate, I can't have behavior 2 and behavior 3 depending on the use case.
from spring-boot.
I see, thanks for the feedback.
So it sounds like you would like to change the active/noop status of an observation after it's been created.
Unfortunately, I don't think there is anything we can do in the Spring Framework @Scheduled
instrumentation or in the Spring Boot auto-configuration. Please see this Micrometer issue (and especially the related ones) as I think this is really a Micrometer concern.
from spring-boot.
Some additional thoughts.
The Observation
API is one of the strengths of Micrometer. One can instrument apps and libraries for metrics, traces or both without introducing specific dependencies. Micrometer uses observation handlers that listen for the lifecycle of observations and turn them into metrics and traces. In this case, starting an observation has side-effects like starting to record a metric, adding headers to messages for tracing, and more. "Cancelling" an observation after it has started is challenging and would probably require specific checks that would hurt performance for instrumentations.
In your case, I understand that you probably don't want to record metrics for "paused jobs" as they're very short lived and are probably skewing numbers. For this, I think you could maybe let the observation be recorded, but add metadata to the observation context stating that it's been paused. This way, you can build your metrics dashboard using this dimension and avoid conflating paused/unpaused jobs.
from spring-boot.
Related Issues (20)
- Using Gradle's new file permission API is implemented in a way that prevents removal of the old API
- Using Gradle's new file permission API is implemented in a way that prevents removal of the old API
- Support loading config yaml files embedded in env vars via spring.config.import HOT 5
- mapstruct-processor jar is missing when package from springboot2.4 HOT 3
- Reduce warnings reported by Eclipse
- Migrate class references to full javadoc links
- Use javadoc macro for links in adoc files
- Reduce warnings reported by Eclipse
- Rename one instance of DataLdapTestIntegrationTests in spring-boot-test-autoconfigure
- Rename one instance of DataLdapTestIntegrationTests in spring-boot-test-autoconfigure
- Spring Jersey does not return 404 from Controller if entity is null HOT 3
- Some @ControllerEndpoint and @RestControllerEndpoint infrastructure remains undeprecated
- @ConditionalOnProperty for branch of values not match HOT 3
- Update link to documentation for log4j-spring-boot
- Update link to documentation for log4j-spring-boot
- Move "Customize the whitelabel Error Page" how-to
- "Use Spring Data repositories" How-to incorrectly refers to Repository annotations
- Upgrade to Testcontainers 1.20.0 HOT 1
- "Use Spring Data repositories" How-to incorrectly refers to Repository annotations
- "Use Spring Data repositories" How-to incorrectly refers to Repository annotations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.