Add functionality for counting events
Similar to the existing streams functionality, this patch exposes in quincy the ability added to winchester and quince to count filtered events. There are corresponding changes in winchester, quince, and klugman. Change-Id: If2cdb66c4752fd19eac642a6fbec3c5d45745d29
This commit is contained in:
parent
ffc736c302
commit
f392a3f97a
@ -110,21 +110,7 @@ class StreamItem(common.FalconBase):
|
|||||||
self.impl.reset_stream(stream_id)
|
self.impl.reset_stream(stream_id)
|
||||||
|
|
||||||
|
|
||||||
class EventCollection(common.FalconBase):
|
def _find_events(impl, req, resp, count=False):
|
||||||
# Retrieve events, independent of stream.
|
|
||||||
# GET - list stream with qualifiers
|
|
||||||
|
|
||||||
# Qualifiers:
|
|
||||||
# datetime are ISO-8601 format, UTC
|
|
||||||
# from_datetime - events with timestamp > from_datetime
|
|
||||||
# default: now - 1hr
|
|
||||||
# to_datetime - events with timestamp < to_datetime
|
|
||||||
# default: now
|
|
||||||
# event_name - events of event type
|
|
||||||
# traits - find traits with specific traits
|
|
||||||
# mark - marker for paged results
|
|
||||||
# limit - max number of events to return (default: 200)
|
|
||||||
def on_get(self, req, resp):
|
|
||||||
from_datetime = req.get_param('from_datetime')
|
from_datetime = req.get_param('from_datetime')
|
||||||
to_datetime = req.get_param('to_datetime')
|
to_datetime = req.get_param('to_datetime')
|
||||||
event_name = req.get_param('event_name')
|
event_name = req.get_param('event_name')
|
||||||
@ -147,20 +133,48 @@ class EventCollection(common.FalconBase):
|
|||||||
if to_datetime:
|
if to_datetime:
|
||||||
to_datetime = parser.parse(to_datetime)
|
to_datetime = parser.parse(to_datetime)
|
||||||
|
|
||||||
events = self.impl.find_events(from_datetime=from_datetime,
|
return impl.find_events(from_datetime=from_datetime,
|
||||||
to_datetime=to_datetime,
|
to_datetime=to_datetime,
|
||||||
event_name=event_name,
|
event_name=event_name,
|
||||||
traits=traits,
|
traits=traits,
|
||||||
mark=mark, limit=limit)
|
mark=mark, limit=limit, count=count)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_event(impl, req, resp, message_id):
|
||||||
|
return impl.get_event(message_id)
|
||||||
|
|
||||||
|
|
||||||
|
class EventCollection(common.FalconBase):
|
||||||
|
# Retrieve events, independent of stream.
|
||||||
|
# GET - list stream with qualifiers
|
||||||
|
|
||||||
|
# Qualifiers:
|
||||||
|
# datetime are ISO-8601 format, UTC
|
||||||
|
# from_datetime - events with timestamp > from_datetime
|
||||||
|
# default: now - 1hr
|
||||||
|
# to_datetime - events with timestamp < to_datetime
|
||||||
|
# default: now
|
||||||
|
# event_name - events of event type
|
||||||
|
# traits - find traits with specific traits
|
||||||
|
# mark - marker for paged results
|
||||||
|
# limit - max number of events to return (default: 200)
|
||||||
|
def on_get(self, req, resp):
|
||||||
|
events = _find_events(self.impl, req, resp)
|
||||||
|
|
||||||
resp.body = jsonutil.dumps(events)
|
resp.body = jsonutil.dumps(events)
|
||||||
|
|
||||||
|
|
||||||
class EventItem(common.FalconBase):
|
class EventItem(common.FalconBase):
|
||||||
def on_get(self, req, resp, message_id):
|
def on_get(self, req, resp, message_id):
|
||||||
|
# could be /events/123 or /events/count
|
||||||
message_id = message_id.lower()
|
message_id = message_id.lower()
|
||||||
event = self.impl.get_event(message_id)
|
count = message_id == 'count'
|
||||||
resp.body = jsonutil.dumps([event])
|
if count:
|
||||||
|
events = _find_events(self.impl, req, resp, count=count)
|
||||||
|
else:
|
||||||
|
events = _get_event(self.impl, req, resp, message_id)
|
||||||
|
|
||||||
|
resp.body = jsonutil.dumps(events)
|
||||||
|
|
||||||
|
|
||||||
class Schema(object):
|
class Schema(object):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = quincy
|
name = quincy
|
||||||
version = 0.2
|
version = 0.3
|
||||||
author = Dark Secret Software Inc.
|
author = Dark Secret Software Inc.
|
||||||
author-email = admin@darksecretsoftware.com
|
author-email = admin@darksecretsoftware.com
|
||||||
summary = StackTach.v3 REST API (no implementation)
|
summary = StackTach.v3 REST API (no implementation)
|
||||||
|
Loading…
Reference in New Issue
Block a user