Skip to content

Commit

Permalink
Merge pull request #123 from bebyx/feature/auto_resolve_after
Browse files Browse the repository at this point in the history
Feature/auto_resolve_after
  • Loading branch information
venky526 authored Jul 25, 2023
2 parents e454870 + 968bc25 commit 141a49e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.10.1 (2023-7-24)

* Added `auto_resolve_after` parameter in `Detect` class.

## 2.10.0 (2023-7-19)

* Added `AmazonEventBridgeNotification` for Amazon EventBridge integration within detectors.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.10.0
current_version = 2.10.1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

setup(
name='signal_analog',
version='2.10.0',
version='2.10.1',
description='A troposphere-like library for managing SignalFx'
+ 'Charts, Dashboards, and Detectors.',
long_description=readme + '\n\n' + history,
Expand Down
2 changes: 1 addition & 1 deletion signal_analog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

__author__ = """Fernando Freire"""
__email__ = '[email protected]'
__version__ = '2.10.0'
__version__ = '2.10.1'

logging_config = pkg_resources.resource_string(
__name__, 'logging.yaml').decode('utf-8')
Expand Down
22 changes: 13 additions & 9 deletions signal_analog/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,8 @@ def __init__(self):

class Detect(Function):

def __init__(self, on, off=None, mode=None):
"""Creates a object.
def __init__(self, on, off=None, mode=None, auto_resolve_after=None):
"""Creates an object.
A 'detect' object is used to create events when a condition is met
and when it clears. These events can be used to notify people of when
Expand All @@ -1003,18 +1003,22 @@ def __init__(self, on, off=None, mode=None):
Arguments:
on: Data when expression that will fire an event with the status "anomalous".
off: Data when expression that will fire an event with the status "ok". If not specified then the 'off' is
equivalent to not on
equivalent to not on
mode: String mode of the detector
paired - both on and off conditions are always evaluated simultaneously. The alert is raised if on
is true and off is false, and the alert is cleared if the off is true and on is false.
paired: both on and off conditions are always evaluated simultaneously. The alert is raised if on
is true and off is false, and the alert is cleared if the off is true and on is false.
split - the on condition is evaluated only if there is no alert, and the alert is raised when the
on condition evaluates to true. The off condition is only evaluated when the alert is raised, and
the alert is cleared when the off condition evaluates to true.
split: the on condition is evaluated only if there is no alert, and the alert is raised when the
on condition evaluates to true. The off condition is only evaluated when the alert is raised, and
the alert is cleared when the off condition evaluates to true.
auto_resolve_after: After any input data stream stops receiving data points for the specified duration,
the detector clears active alerts.
"""
super(Detect, self).__init__("detect")
self.args = [Arg(on), KWArg("off", off), KWArg("mode", mode)]
self.args = [Arg(on),
KWArg("off", off), KWArg("mode", mode),
KWArg("auto_resolve_after", auto_resolve_after)]


class Op(Function):
Expand Down
3 changes: 2 additions & 1 deletion tests/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def detects(draw):
on = draw(flows())
off = draw(ascii())
mode = draw(sampled_from(["paired", "split"]))
return flow.Detect(on, off=off, mode=mode)
auto_resolve_after = draw(ascii())
return flow.Detect(on, off=off, mode=mode, auto_resolve_after=auto_resolve_after)


@composite
Expand Down

0 comments on commit 141a49e

Please sign in to comment.