コード例 #1
0
 def test_hash_with_single_client(self):
     clients = [
         FakeClient("127.0.0.1", 10001),
     ]
     client = ConsistentHashingClient(clients)
     bar = Metric(client, "bar")
     foo = Metric(client, "foo")
     dba = Metric(client, "dba")
     bar.send("1")
     foo.send("1")
     dba.send("1")
     self.assertEqual(clients[0].data, ["bar:1", "foo:1", "dba:1"])
コード例 #2
0
ファイル: metrics.py プロジェクト: 10allday-services/txstatsd
 def decrement(self, name, value=1, sample_rate=1, tags=None):
     """Report and decrease in name by count."""
     key, name = self.key_and_fqn(name, tags)
     if key not in self._metrics:
         metric = Metric(self.connection, name, sample_rate, tags)
         self._metrics[key] = metric
     self._metrics[key].send("%s|c" % -value)
コード例 #3
0
 def decrement(self, name, value=1, sample_rate=1):
     """Report and decrease in name by count."""
     name = self.fully_qualify_name(name)
     if not name in self._metrics:
         metric = Metric(self.connection,
                         name,
                         sample_rate)
         self._metrics[name] = metric
     self._metrics[name].send("%s|c" % -value)
コード例 #4
0
ファイル: metrics.py プロジェクト: 10allday-services/txstatsd
 def timing(self, name, duration=None, sample_rate=1, tags=None):
     """Report that this sample performed in duration seconds.
        Default duration is the actual elapsed time since
        the last call to this method or reset_timing()"""
     if duration is None:
         duration = self.calculate_duration()
     key, name = self.key_and_fqn(name, tags)
     if key not in self._metrics:
         metric = Metric(self.connection, name, sample_rate, tags)
         self._metrics[key] = metric
     self._metrics[key].send("%s|ms" % (duration * 1000))
コード例 #5
0
 def timing(self, name, duration=None, sample_rate=1):
     """Report that this sample performed in duration seconds.
        Default duration is the actual elapsed time since
        the last call to this method or reset_timing()"""
     if duration is None:
         duration = self.calculate_duration()
     name = self.fully_qualify_name(name)
     if not name in self._metrics:
         metric = Metric(self.connection,
                         name,
                         sample_rate)
         self._metrics[name] = metric
     self._metrics[name].send("%s|ms" % (duration * 1000))