Skip to content

Instantly share code, notes, and snippets.

@schmichael
Created September 13, 2011 19:17
Show Gist options
  • Save schmichael/1214780 to your computer and use it in GitHub Desktop.
Save schmichael/1214780 to your computer and use it in GitHub Desktop.
mmstats example
import os
import mmstats
import libgettid
class MyStats(mmstats.BaseMmStats):
pid = mmstats.StaticUIntField(label="sys.pid", value=os.getpid)
tid = mmstats.StaticInt64Field(label="sys.tid", value=libgettid.gettid)
uid = mmstats.StaticUInt64Field(label="sys.uid", value=os.getuid)
gid = mmstats.StaticUInt64Field(label="sys.gid", value=os.getgid)
errors = mmstats.UIntStat(label="com.urbanairship.app.errors")
warnings = mmstats.UIntStat(label="com.urbanairship.app.warnings")
queries = mmstats.UIntStat(label="com.urbanairship.app.queries")
cache_hits = mmstats.UIntStat(label="com.urbanairship.app.cache_hits")
cache_misses = mmstats.UIntStat(label="com.urbanairship.app.cache_misses")
degraded = mmstats.BoolStat(label="com.urbanairship.app.degraded")
stats = MyStats(filename="mmstats-test-mystats")
stats.degraded = True
stats.errors += 1
stats.cache_hits += 1000
assert stats.cache_hits == 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment