Skip to content

Commit

Permalink
continuing the QuantileSink enhancements. still need to work on consi…
Browse files Browse the repository at this point in the history
…stency among all the sinks.
  • Loading branch information
mahmoud committed Apr 11, 2016
1 parent 68e89ed commit e4b189a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lithoxyl/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def __repr__(self):


class QuantileSink(object):
def __init__(self, getter=None, use_p2=False):
def __init__(self, getter=None, **kwargs):
"""There are two approaches for quantile-based stats
accumulation. A standard, reservoir/replacement strategy
(QuantileAccumulator) and the P2 approach
Expand All @@ -280,9 +280,15 @@ def __init__(self, getter=None, use_p2=False):
getter = lambda event: event.duration
self.getter = getter

self._qa_type = QuantileAccumulator
default_acc = QuantileAccumulator
use_p2 = kwargs.pop('use_p2', False)
if use_p2:
self._qa_type = P2QuantileAccumulator
default_acc = P2QuantileAccumulator

acc_type = kwargs.pop('acc_type', default_acc)

self._acc_type = acc_type

self.qas = {}

def to_dict(self):
Expand All @@ -301,7 +307,7 @@ def on_end(self, event):
try:
acc = logger_accs[event.name]
except KeyError:
acc = logger_accs[event.name] = self._qa_type()
acc = logger_accs[event.name] = self._acc_type()

acc.add(self.getter(event))

Expand Down

0 comments on commit e4b189a

Please sign in to comment.