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

monitoring functional #26876

Merged
merged 43 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
90bdf7d
move datadog init to AppConfig.ready
snopoke Mar 9, 2020
7ad93fa
pluggable metrics
snopoke Mar 10, 2020
0694926
add histogram and tests
snopoke Mar 10, 2020
c1f8270
bucket values less than or equal
snopoke Mar 10, 2020
5034156
add prometheus client to requirements
snopoke Mar 10, 2020
172ef37
Merge branch 'master' into sk/monitoring
snopoke Mar 11, 2020
2be4e6a
make metrics lazy
snopoke Mar 11, 2020
eb8afe3
example histogram
snopoke Mar 11, 2020
54e91c0
Merge branch 'master' into sk/monitoring
snopoke Mar 11, 2020
54f2d1b
convert sumbission metrics
snopoke Mar 11, 2020
eba69c4
docstrings
snopoke Mar 11, 2020
01fbc07
stickler
snopoke Mar 11, 2020
450f211
keep tag_values as dict instead of splitting and re-combining
snopoke Mar 12, 2020
2c3edef
update links
snopoke Mar 12, 2020
8664161
remove unnecessary list
snopoke Mar 12, 2020
0bcedea
replace typle() with ()
snopoke Mar 12, 2020
9ba3d4a
Merge branch 'sk/monitoring' of github.com:dimagi/commcare-hq into sk…
snopoke Mar 12, 2020
904e358
fix tags
snopoke Mar 12, 2020
d68e104
pass other args
snopoke Mar 12, 2020
5c00052
revert change to datadog bucketing boundry
snopoke Mar 12, 2020
e00b7e1
remove unnecessary list
snopoke Mar 16, 2020
20e8a61
apply tags at the same time as recording the metric
snopoke Mar 16, 2020
0ab0006
dummy metric
snopoke Mar 16, 2020
02b40ee
functional interface
snopoke Mar 16, 2020
31cfba9
re-do configuration via settings
snopoke Mar 17, 2020
892e57b
move initialization into provider
snopoke Mar 17, 2020
dbdbd3f
replace datadog_gauge
snopoke Mar 17, 2020
5897eb9
instantiate provider
snopoke Mar 17, 2020
28a8a5b
hook up metrics view
snopoke Mar 17, 2020
abd0355
todo
snopoke Mar 17, 2020
75fa979
lint
snopoke Mar 17, 2020
017ca5a
PR feedback
snopoke Mar 18, 2020
770f4a0
log output from DebugMetrics
snopoke Mar 18, 2020
8bb9e03
move metrics view to hq/admin
snopoke Mar 18, 2020
9a49d26
move metrics_gauge_task to package init
snopoke Mar 18, 2020
74ce07f
fix import
snopoke Mar 18, 2020
f1874e4
add script for running metrics endpoint
snopoke Mar 18, 2020
d4220f0
update docs
snopoke Mar 18, 2020
0457c00
docs
snopoke Mar 18, 2020
3d79912
do setup in __init__
snopoke Mar 18, 2020
d4c3dc1
simplify prometheus server
snopoke Mar 19, 2020
1017c85
doc updates
snopoke Mar 19, 2020
d18075d
Apply suggestions from code review
snopoke Mar 19, 2020
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
6 changes: 6 additions & 0 deletions corehq/util/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from corehq.util.metrics.metrics import DummyMetrics, DelegatedMetrics, DEFAULT_BUCKETS
from dimagi.utils.modules import to_function

__all__ = [
'metrics_counter',
'metrics_gauge',
'metrics_histogram',
]

_metrics = None


Expand Down
6 changes: 5 additions & 1 deletion corehq/util/metrics/datadog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
class DatadogMetrics(HqMetrics):
def initialize(self):
if not settings.DATADOG_API_KEY or not settings.DATADOG_APP_KEY:
raise Exception("Datadog not configured. Set DATADOG_API_KEY and DATADOG_APP_KEY in settings.")
raise Exception(
"Datadog not configured."
"Set DATADOG_API_KEY and DATADOG_APP_KEY in settings or update METRICS_PROVIDERS"
"to remove the Datadog provider."
snopoke marked this conversation as resolved.
Show resolved Hide resolved
)

try:
from datadog import initialize
Expand Down
6 changes: 3 additions & 3 deletions corehq/util/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def _counter(self, name, value, tags, documentation):

@abstractmethod
def _gauge(self, name, value, tags, documentation):
pass
raise NotImplementedError

@abstractmethod
def _histogram(self, name, value, bucket_tag, buckets, bucket_unit, tags, documentation):
pass
raise NotImplementedError


class DummyMetrics:
Expand All @@ -92,7 +92,7 @@ def _record_metric(*args, **kwargs):
for delegate in self.delegates:
getattr(delegate, item)(*args, **kwargs)
return _record_metric
raise AttributeError
raise AttributeError(item)


def metrics_gauge_task(name, fn, run_every):
snopoke marked this conversation as resolved.
Show resolved Hide resolved
Expand Down