cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to monitor Spring @Scheduled classes in Dynatrace?

arpitkumar
Visitor

Spring supports concept of creating methods running as Scheduled Jobs (using java annotation concept of @Scheduled). 

Is there a way in Dynatrace to actually monitor those for performance collectively? (I know the Elastic APM supports this out of box). 

I came across a way to creating Custom Entry Point, but that has a problem of any developer changing class name or move the class to different package - the monitoring breaks. 

5 REPLIES 5

radek_jasinski
DynaMight Guru
DynaMight Guru

Hi,

In this case, defining a Custom Service will be best. As you noticed, we set there to a specific package, class and method. How often do you change the structure of your application code that this will be a problem?

https://www.dynatrace.com/support/help/shortlink/custom-services#java-and-net-services

Regards,
Radek

Have a nice day!

The problem is not code changing; the problem is segregation of concern. Even with pure devops model, there is likely chance of this breaking cause the devs can always rename code, add new methods. Anyways - this is what we have done for now. 

 

Follow Up Question --> I have opted for Automatically Detect Methods -- if a new method is added, will the Custom Service Detection automatically add / monitor the new method or we have to come and refresh something in the system?

Hi @arpitkumar 
the whole trick is not to instrument method You thinking about, but generic method that is used to actually trigger those @Schedulled methods. In framework there is such one that is being inherited by all of those customely created methods.
If You will instrument this base one You will get everything You need including new and renamed ones in one swoop.
I highly recommend capturing additional requestArrtibute with arguments of this base one, as one of them is containing actual method You put @Schedulled annotation on.

Thanks Michal for your response. I don't think it make sense to instrument the internal framework of Spring and monitor that - because that is the one behind the scene triggering methods which are marked as @Scheduled 

And should I presume from your answer that if I instruments specific methods, then any new ones added are not picked up. 

IF You instrument framework then new ones are AUTOMATICALLY instrumented/monitored - You want that, as single instrumentation covers everything (BTW this is how Dynatrace covers frameworks and important technologies)
IF You instrument methods directly new ones ARE NOT instrumented/monitored.
Hope this clarifies it 😄 

Featured Posts