Last active
December 14, 2015 08:39
-
-
Save hughes/5059451 to your computer and use it in GitHub Desktop.
Recording data with Statistician
This file contains 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
import requests | |
import simplejson | |
data = { | |
"metric": "your-metric-slug", | |
"value": somevalue, | |
"timestamp": sometime.isoformat() # optional, defaults to now | |
} | |
headers = { | |
"content-type": "application/json" | |
} | |
r = requests.post("http://statistician-url/api/v1/metric_data/", data=simplejson.dumps(data), headers=headers) | |
assert r.status_code is 201, "Couldn't record the stat" # 201 created |
This file contains 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
import Stats | |
Stats.record("your-metric-slug", somevalue, timestamp=sometime) # timestamp optional |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment