Skip to content

Instantly share code, notes, and snippets.

@dcramer
Created May 21, 2013 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcramer/5617510 to your computer and use it in GitHub Desktop.
Save dcramer/5617510 to your computer and use it in GitHub Desktop.
"""
sentry.tsdb.models
~~~~~~~~~~~~~~~~~~
Get a key:
>>> key = Key.objects.get_or_create(
>>> name='events.group.{}'.format(group_id)
>>> )
Increment the key for the current time:
>>> now = timezone.now()
>>> Point.objects.incr(key, timestamp=now)
Periodically flush unused data:
>>> if random.random() > 0.9:
>>> Point.objects.trim()
Get some datas:
>>> points = Point.objects.fetch(key, now, now - timedelta(days=1))
>>> for (timestamp, value) in points:
>>> print timestamp, value
:copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment