~wesmason/txstatsd/fix-counters

« back to all changes in this revision

Viewing changes to txstatsd/metrics/distinctmetric.py

  • Committer: Tarmac
  • Author(s): Guillermo Gonzalez
  • Date: 2013-03-08 14:09:07 UTC
  • mfrom: (104.2.4 py3ksupport)
  • Revision ID: tarmac@u1-server-deps-tarmac-lucid-20130308140907-j4ejxtmiybsjfflb
[r=sidnei] Initial py3k support, only the client side. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
"""
29
29
import random
30
30
import time
 
31
import sys
31
32
 
32
 
from zope.interface import implements
 
33
from zope.interface import implementer, implements
33
34
 
34
35
from txstatsd.metrics.metric import Metric
35
36
from txstatsd.itxstatsd import IMetric
121
122
    Keeps an estimate of the distinct numbers of items seen on various
122
123
    sliding windows of time.
123
124
    """
124
 
    implements(IMetric)
 
125
    if sys.version_info[0:2] == (2,6):
 
126
        implements(IMetric)
125
127
 
126
128
    def __init__(self, name, wall_time_func=time.time, prefix=""):
127
129
        """Construct a metric we expect to be periodically updated.
166
168
        for item, value in items.iteritems():
167
169
            metrics.append((self.prefix + self.name + item, value, timestamp))
168
170
        return metrics
 
171
 
 
172
# if we are running anything >= 2.7
 
173
if sys.version_info[0:2] >= (2,7):
 
174
    DistinctMetricReporter = implementer(IMetric)(DistinctMetricReporter)