Skip to content

Instantly share code, notes, and snippets.

@hughes
Last active December 14, 2015 08:39
Show Gist options
  • Save hughes/5059451 to your computer and use it in GitHub Desktop.
Save hughes/5059451 to your computer and use it in GitHub Desktop.
Recording data with Statistician
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
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