Skip to content

Commit

Permalink
Restrict scheduling seconds (#86)
Browse files Browse the repository at this point in the history
* Do not run heartbeats during fastchecks

* Don't schedule too early or too late in the minute
dlopes7 authored Sep 13, 2024
1 parent 7c3ff08 commit ce3d6b7
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dynatrace_extension/__about__.py
Original file line number Diff line number Diff line change
@@ -2,4 +2,5 @@
#
# SPDX-License-Identifier: MIT

__version__ = "1.2.11"

__version__ = "1.2.12"
4 changes: 2 additions & 2 deletions dynatrace_extension/sdk/callback.py
Original file line number Diff line number Diff line change
@@ -89,13 +89,13 @@ def name(self):
def initial_wait_time(self) -> float:
if not self.running_in_sim:
"""
Here we chose a random second between 1 and 59 to start the callback
Here we chose a random second between 5 and 55 to start the callback
This is to distribute load for extension running on this host
When running from the simulator, this is not done
"""

now = self.get_current_time_with_cluster_diff()
random_second = random.randint(1, 59) # noqa: S311
random_second = random.randint(5, 55) # noqa: S311
next_execution = datetime.now().replace(second=random_second, microsecond=0)
if next_execution <= now:
# The random chosen second already passed this minute

0 comments on commit ce3d6b7

Please sign in to comment.