02 Jan 2025 09:19 AM - last edited on 07 Jan 2025 10:02 AM by MaciejNeumann
Hello,
We have created custom services in Dynatrace to detect @Scheduled methods in our Java application. Given the significant number of @Scheduled methods in our application, is there a way to configure Dynatrace to auto-detect these methods using rules or other configurations?
Thanks in advance.
Regards,
Siva Kumar
02 Jan 2025 10:04 AM
Hello @sivakumarp ,
Yes there's a way to auto-detect & monitor them. As far as I'm aware custom services can be used for this. And you'll define the technology as Java and fill out the rest as necessary. I believe this way it's a lot easier as well since it will all be done through the Dynatrace UI.
I have also attached an image as to where you can find custom services.
That's what I would do personally, so I hope that helped!
-Habiba Abdelaziz
02 Jan 2025 10:15 AM
Hi Habiba_A,
Thanks for the response.
As I mentioned earlier, we have successfully created custom services for detecting @Scheduled methods, and they are available in Dynatrace. Given the substantial number of schedulers in our application, I'm now exploring options for auto-detecting these methods using rules or other configurations.
02 Jan 2025 10:30 AM
In a recent case, I have done that configuration via API. That certainly helps when leading with large number of Custom Services.
The link is here. If you have doubts, use the same API to get an existing config, and then replicate it with this one...
06 Jan 2025 10:06 AM
Yes, but typically you should instrument the particular abstract class being executed to automatically capture every task scheduled. I do it it for example with Quarz scheduler this way. You can also add request naming rules to better identify the executed task, if necessary.
06 Jan 2025 12:27 PM - edited 06 Jan 2025 12:27 PM
@sivakumarp For example, for the Quartz scheduler, instrument the org.quartz.Job interface and the execute method (create a custom service which bounds to this class and method execution). You may want to capture additional metadata using request attributes from the execution method's context argument.
This is just an example for Quartz, if your apps use different schedulers, I'd recommend following the same approach.
11 Jan 2025 04:33 AM
@Julius_Loman could you share how to instrument the execute method? I assume DynaTrace SDK needs to be used for this. If you could share a link to documentation how to do this it would be great. Thank you!