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

Move Goexpvar to pytest #2089

Merged
merged 5 commits into from
Aug 22, 2018
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ jobs:
env: CHECK=gearmand
- stage: test
env: CHECK=gitlab
- stage: test
env: CHECK=go_expvar
- stage: test
env: CHECK=gunicorn
- stage: test
Expand Down
23 changes: 17 additions & 6 deletions go_expvar/datadog_checks/go_expvar/go_expvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import requests

# project
from checks import AgentCheck
from datadog_checks.checks import AgentCheck

DEFAULT_MAX_METRICS = 350
PATH = "path"
Expand Down Expand Up @@ -59,6 +59,7 @@

GO_EXPVAR_URL_PATH = "/debug/vars"


class GoExpvar(AgentCheck):

def __init__(self, name, init_config, agentConfig, instances=None):
Expand All @@ -76,7 +77,8 @@ def _get_data(self, url, instance):
del ssl_params[key]

# Load SSL configuration, if available.
# ssl_verify can be a bool or a string (http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification)
# ssl_verify can be a bool or a string
# (http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification)
if isinstance(ssl_params.get('ssl_verify'), bool) or isinstance(ssl_params.get('ssl_verify'), basestring):
verify = ssl_params.get('ssl_verify')
else:
Expand Down Expand Up @@ -108,7 +110,10 @@ def _load(self, instance):
url = parsed_url._replace(path=GO_EXPVAR_URL_PATH).geturl()

tags = instance.get('tags', [])
tags.append("expvar_url:%s" % url)
expvar_url_tag = "expvar_url:%s" % url
if expvar_url_tag not in tags:
tags.append(expvar_url_tag)

data = self._get_data(url, instance)
metrics = DEFAULT_METRICS + instance.get("metrics", [])
max_metrics = instance.get("max_returned_metrics", DEFAULT_MAX_METRICS)
Expand Down Expand Up @@ -210,9 +215,15 @@ def deep_get(self, content, keys, traversed_path=None):
]
}
}
-keys: ["key1", "key2", "1", "value"] would return [(["key1", "key2", "1", "value"], 72)]
-keys: ["key1", "key2", "1", "*"] would return [(["key1", "key2", "1", "value"], 72), (["key1", "key2", "1", "name"], "object2")]
-keys: ["key1", "key2", "*", "value"] would return [(["key1", "key2", "1", "value"], 72), (["key1", "key2", "0", "value"], 42)]
-keys: ["key1", "key2", "1", "value"]
would return:
[(["key1", "key2", "1", "value"], 72)]
-keys: ["key1", "key2", "1", "*"]
would return:
[(["key1", "key2", "1", "value"], 72), (["key1", "key2", "1", "name"], "object2")]
-keys: ["key1", "key2", "*", "value"]
would return:
[(["key1", "key2", "1", "value"], 72), (["key1", "key2", "0", "value"], 42)]
'''

if traversed_path is None:
Expand Down
Empty file removed go_expvar/test/__init__.py
Empty file.
63 changes: 0 additions & 63 deletions go_expvar/test/ci/go_expvar.rake

This file was deleted.

Loading