Skip to content

Commit

Permalink
beta feature for extended event window
Browse files Browse the repository at this point in the history
  • Loading branch information
steveny91 committed Dec 15, 2023
1 parent bff422a commit 2111162
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
16 changes: 16 additions & 0 deletions ddev/src/ddev/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# file generated by setuptools_scm
# don't change, don't track in version control
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Tuple, Union
VERSION_TUPLE = Tuple[Union[int, str], ...]
else:
VERSION_TUPLE = object

version: str
__version__: str
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE

__version__ = version = '5.2.1.dev1'
__version_tuple__ = version_tuple = (5, 2, 1, 'dev1')
17 changes: 15 additions & 2 deletions silk/datadog_checks/silk/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from copy import deepcopy
from math import ceil

from six.moves.urllib.parse import urljoin, urlparse

Expand All @@ -26,6 +27,7 @@ def __init__(self, name, init_config, instances):
self.metrics_to_collect = dict(METRICS)

server = self.instance.get("host_address")
self.extend_events_window = self.instance.get("extend_events_window", False)

if server is None:
raise ConfigurationError("host_address is a required parameter.")
Expand Down Expand Up @@ -212,7 +214,7 @@ def collect_events(self, system_tags):
# Use `self.latest_event_query` as starting time and `collect_events_timestamp` as ending time
event_query = EVENT_PATH.format(int(self.latest_event_query), int(collect_events_timestamp))
raw_events, _ = self._get_data(event_query)

# breakpoint()
for event in raw_events:
try:
tags = self._tags + system_tags
Expand All @@ -228,4 +230,15 @@ def collect_events(self, system_tags):
self.log.error("Unable to fetch events: %s", str(e))

# Update latest event query to last event time
self.latest_event_query = collect_events_timestamp
if self.extend_events_window:
if len(raw_events) > 0:
self.latest_event_query = ceil(raw_events[-1].get('timestamp'))
self.log.debug("Update next event query start timestamp to %s", self.latest_event_query)
else:
self.log.debug(
"No events found in this query window. Keeping the same query window. Start: %s, end: %s",
self.latest_event_query,
collect_events_timestamp,
)
else:
self.latest_event_query = collect_events_timestamp

0 comments on commit 2111162

Please sign in to comment.