Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make service check statuses available as constants #2960

Merged
merged 1 commit into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions datadog_checks_base/datadog_checks/base/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using_stub_aggregator = True

from ..config import is_affirmative
from ..constants import ServiceCheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why move this to a new file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's a constant so it makes sense. Also there are others below like ONE_PER_CONTEXT_METRIC_TYPES that we should eventually move there as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being able to access them from base seems very handy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that makes sense. But since these all still need to be members of the class it would just cut down on duplication in the AgentCheck classes, I suppose

from ..utils.common import ensure_bytes, ensure_unicode
from ..utils.proxy import config_proxy_skip
from ..utils.limiter import Limiter
Expand All @@ -45,7 +46,7 @@ class __AgentCheck7(object):
"""
The base class for any Agent based integrations
"""
OK, WARNING, CRITICAL, UNKNOWN = (0, 1, 2, 3)
OK, WARNING, CRITICAL, UNKNOWN = ServiceCheck

"""
DEFAULT_METRIC_LIMIT allows to set a limit on the number of metric name and tags combination
Expand Down Expand Up @@ -403,7 +404,7 @@ class __AgentCheck6(object):
"""
The base class for any Agent based integrations
"""
OK, WARNING, CRITICAL, UNKNOWN = (0, 1, 2, 3)
OK, WARNING, CRITICAL, UNKNOWN = ServiceCheck

"""
DEFAULT_METRIC_LIMIT allows to set a limit on the number of metric name and tags combination
Expand Down
6 changes: 6 additions & 0 deletions datadog_checks_base/datadog_checks/base/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# (C) Datadog, Inc. 2019
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from collections import namedtuple

ServiceCheck = namedtuple('ServiceCheck', 'OK WARNING CRITICAL UNKNOWN')(0, 1, 2, 3)