Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created July 1, 2017 00:44
Show Gist options
  • Save gnilchee/89a9417b550386bf887ecbd058646a21 to your computer and use it in GitHub Desktop.
Save gnilchee/89a9417b550386bf887ecbd058646a21 to your computer and use it in GitHub Desktop.
send custom stats to datadog
#!/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