Created
July 1, 2017 00:44
-
-
Save gnilchee/89a9417b550386bf887ecbd058646a21 to your computer and use it in GitHub Desktop.
send custom stats to datadog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from datadog import statsd | |
import requests | |
import time | |
def get_endpoint_status(url): | |
response = requests.get(url) | |
resp_time_miliseconds = response.elapsed.microseconds / 1000 | |
result = {'status_code': response.status_code, 'response_time': resp_time_miliseconds} | |
return result | |
increment = 5 | |
while increment > 0: | |
stats = get_endpoint_status('https://results-hub.athlinks.com/status/sockets') | |
statsd.gauge('stats.response_time.results-hub.prod', stats['response_time']) | |
statsd.gauge('stats.status_code.results-hub.prod', stats['status_code']) | |
increment -= 1 | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment