22 Oct 2024 10:05 PM
I have an extension, which for a particular monitoring configuration, and once per hour, needs to run slightly more than 60 seconds. A log entry is created for each of the invocations, and looks like this:
Method=query: Callback Method=query took 64.1117 seconds to execute, which is longer than the interval of 60.0s
Is this something that can be configured, eventually at the monitoring configuration level?
Solved! Go to Solution.
22 Oct 2024 10:21 PM - edited 22 Oct 2024 10:21 PM
Hi @AntonioSousa,
I'm guessing you are using the query method that runs once per minute and then calculating the once per hour to run via a counter or some other method?
You can switch to the setting the main method of your extension to use be called via the schedule (https://dynatrace-extensions.github.io/dt-extensions-python-sdk/api/extension.html#dynatrace_extensi...) method that takes in an interval which you can either hard code or pass in via the monitoring config.
For example, you can pull the frequency from the config and use it to give yourself more minutes before the callback error is thrown.
from datetime import timedelta
...
def initialize(self):
frequency = self.activation_config.get("frequency", 1)
self.schedule(callback=self.main_method, interval=timedelta(minutes=frequency), args=())
def main_method(self):
# Do your work here
25 Nov 2024 06:05 PM - edited 25 Nov 2024 06:07 PM
Hi @DavidMass ,
I applied the recommended code shown below and I am still receiving the same error Antonio reported. When manually running __,main.py__ , I can see the frequency set to 20min( Please reference the second output shown below). Any guidance you can provide would be greatly appreciated.
Thank You!
22 Oct 2024 10:58 PM
Yes, using the strategy that was available in EF1 🙂
Going to try it out, but have questions:
22 Oct 2024 11:10 PM
I understand 👍
With the EF2 SDK, you don't need to have a query method. It is now still a special method but it's just scheduled (using a similar method to the self.schedule way) internally within the SDK at a hard coded interval (1 minute). If it's not defined the SDK will still work.
Yes, you can have both your main_method and a query method where query would run once a minute (automatically) and then you would need to "manually" schedule your main_method. You can also schedule more than 1 method each with it's own interval.
Using that set up, no, it would be scheduled to run whenever the AG receives the configuration so there is no way to guarantee it to run at a specific minute in the hour.
Off the top of my head though, you could have a delay where in the initialize method you "sleep" until the minute you want comes up and then schedule it.
21 Nov 2024 10:43 PM
Hello Antonio,
I created a custom XenServer extension, and I am encountering the same error message. Error shown below,
Method=query: Callback Method=query took 62.5491 seconds to execute, which is longer than the interval of 60.0s
Did you have successful results applying the fix David Mass recommended?
23 Oct 2024 12:03 AM - edited 23 Oct 2024 12:04 AM
Hello @AntonioSousa ,
when checking the extension source in github I've found that there's constants were defined in the file extension.py as the following figure
HEARTBEAT_INTERVAL = timedelta(seconds=50)
METRIC_SENDING_INTERVAL = timedelta(seconds=30)
SFM_METRIC_SENDING_INTERVAL = timedelta(seconds=60)
TIME_DIFF_INTERVAL = timedelta(seconds=60)
after searching for `SFM_METRIC_SENDING_INTERVAL` I've found that it's used in class `Extension` as the following figure
so you can try simply redefine them with your own values within your own extension file __main__.py, I hope you get it works.
BR,
Mostafa Hussein.
27 Nov 2024 06:46 PM
Please do NOT do this, these are internal values of the periods in which we communicate to the EEC, it has nothing to do with the original issue.
To fix the original issue just schedule methods to run for more than 60 seconds, do NOT attempt to schedule the query method itself, as that one is a special method that is always scheduled to run every 60 seconds.