本文整理汇总了Python中sentry.utils.snuba.query函数的典型用法代码示例。如果您正苦于以下问题:Python query函数的具体用法?Python query怎么用?Python query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了query函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_fail
def test_fail(self):
now = datetime.now()
with pytest.raises(snuba.SnubaError):
snuba.query(
start=now - timedelta(days=1),
end=now + timedelta(days=1),
filter_keys={'project_id': [self.project.id]},
groupby=[")("],
)
开发者ID:Kayle009,项目名称:sentry,代码行数:9,代码来源:test_snuba.py
示例2: __get_tag_values
def __get_tag_values(self, project_id, group_id, environment_id, key):
start, end = self.get_time_range()
tag = 'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
}
if group_id is not None:
filters['issue'] = [group_id]
conditions = [[tag, '!=', '']]
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, [tag], conditions, filters, aggregations,
referrer='tagstore.__get_tag_values')
if group_id is None:
ctor = TagValue
else:
ctor = functools.partial(GroupTagValue, group_id=group_id)
return set([ctor(key=key, value=value, **fix_tag_value_data(data))
for value, data in result.items()])
开发者ID:binlee1990,项目名称:sentry,代码行数:26,代码来源:backend.py
示例3: __get_tag_key
def __get_tag_key(self, project_id, group_id, environment_id, key):
start, end = self.get_time_range()
tag = u'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
}
if group_id is not None:
filters['issue'] = [group_id]
conditions = [[tag, '!=', '']]
aggregations = [
['uniq', tag, 'values_seen'],
['count()', '', 'count']
]
result = snuba.query(start, end, [], conditions, filters, aggregations,
referrer='tagstore.__get_tag_key')
if result is None or result['count'] == 0:
raise TagKeyNotFound if group_id is None else GroupTagKeyNotFound
else:
data = {
'key': key,
'values_seen': result['values_seen'],
'count': result['count'],
}
if group_id is None:
return TagKey(**data)
else:
return GroupTagKey(group_id=group_id, **data)
开发者ID:alexandrul,项目名称:sentry,代码行数:29,代码来源:backend.py
示例4: __get_tag_value
def __get_tag_value(self, project_id, group_id, environment_id, key, value):
start, end = self.get_time_range()
tag = u'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
}
if group_id is not None:
filters['issue'] = [group_id]
conditions = [[tag, '=', value]]
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
data = snuba.query(start, end, [], conditions, filters, aggregations,
referrer='tagstore.__get_tag_value')
if not data['times_seen'] > 0:
raise TagValueNotFound if group_id is None else GroupTagValueNotFound
else:
data.update({
'key': key,
'value': value,
})
if group_id is None:
return TagValue(**fix_tag_value_data(data))
else:
return GroupTagValue(group_id=group_id, **fix_tag_value_data(data))
开发者ID:alexandrul,项目名称:sentry,代码行数:29,代码来源:backend.py
示例5: get_group_tag_value_iter
def get_group_tag_value_iter(self, project_id, group_id, environment_id, key, callbacks=()):
start, end = self.get_time_range()
results = snuba.query(
start=start,
end=end,
groupby=['tags_value'],
filter_keys={
'project_id': [project_id],
'environment': [environment_id],
'tags_key': [key],
'issue': [group_id],
},
aggregations=[
['count()', '', 'times_seen'],
['min', 'timestamp', 'first_seen'],
['max', 'timestamp', 'last_seen'],
],
orderby='-first_seen', # Closest thing to pre-existing `-id` order
# TODO: This means they can't actually iterate all GroupTagValues.
limit=1000,
)
group_tag_values = [
GroupTagValue(
group_id=group_id,
key=key,
value=value,
**fix_tag_value_data(data)
) for value, data in six.iteritems(results)
]
for cb in callbacks:
cb(group_tag_values)
return group_tag_values
开发者ID:binlee1990,项目名称:sentry,代码行数:35,代码来源:backend.py
示例6: get_group_list_tag_value
def get_group_list_tag_value(self, project_id, group_id_list, environment_id, key, value):
start, end = self.get_time_range()
tag = u'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
'issue': group_id_list,
}
conditions = [
[tag, '=', value]
]
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['issue'], conditions, filters, aggregations,
referrer='tagstore.get_group_list_tag_value')
return {
issue: GroupTagValue(
group_id=issue,
key=key,
value=value,
**fix_tag_value_data(data)
) for issue, data in six.iteritems(result)
}
开发者ID:alexandrul,项目名称:sentry,代码行数:28,代码来源:backend.py
示例7: get_group_seen_values_for_environments
def get_group_seen_values_for_environments(self, project_ids, group_id_list, environment_ids,
start=None, end=None):
# Get the total times seen, first seen, and last seen across multiple environments
if start is None or end is None:
start, end = self.get_time_range()
filters = {
'project_id': project_ids,
'issue': group_id_list,
}
conditions = None
if environment_ids:
filters['environment'] = environment_ids
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['issue'], conditions, filters, aggregations,
referrer='tagstore.get_group_seen_values_for_environments')
return {
issue: fix_tag_value_data(data) for issue, data in six.iteritems(result)
}
开发者ID:yaoqi,项目名称:sentry,代码行数:25,代码来源:backend.py
示例8: get_release_tags
def get_release_tags(self, project_ids, environment_id, versions):
start, end = self.get_time_range()
filters = {
'project_id': project_ids,
'environment': [environment_id],
}
# NB we add release as a condition rather than a filter because
# this method is already dealing with version strings rather than
# release ids which would need to be translated by the snuba util.
tag = 'sentry:release'
col = u'tags[{}]'.format(tag)
conditions = [[col, 'IN', versions]]
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['project_id', col],
conditions, filters, aggregations,
referrer='tagstore.get_release_tags')
values = []
for project_data in six.itervalues(result):
for value, data in six.iteritems(project_data):
values.append(
TagValue(
key=tag,
value=value,
**fix_tag_value_data(data)
)
)
return set(values)
开发者ID:alexandrul,项目名称:sentry,代码行数:34,代码来源:backend.py
示例9: _get_event_count
def _get_event_count():
return snuba.query(
start=now - timedelta(days=1),
end=now + timedelta(days=1),
groupby=['project_id'],
filter_keys={'project_id': [self.project.id]},
).get(self.project.id, 0)
开发者ID:yaoqi,项目名称:sentry,代码行数:7,代码来源:test_eventstream.py
示例10: get_release_tags
def get_release_tags(self, project_ids, environment_id, versions):
start, end = self.get_time_range()
filters = {
'project_id': project_ids,
'environment': [environment_id],
}
# NB we add release as a condition rather than a filter because
# this method is already dealing with version strings rather than
# release ids which would need to be translated by the snuba util.
conditions = [['release', 'IN', versions]]
aggregations = [
['count()', '', 'count'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['release'], conditions, filters, aggregations)
return [ObjectWrapper({
'times_seen': val['count'],
'first_seen': val['first_seen'],
'last_seen': val['last_seen'],
'key': 'release',
'value': name,
}) for name, val in six.iteritems(result)]
开发者ID:hosmelq,项目名称:sentry,代码行数:25,代码来源:backend.py
示例11: test_use_group_id
def test_use_group_id(self):
base_time = datetime.utcnow()
group = self.create_group()
self._insert_event_for_time(base_time, group_id=group.id)
with self.options({'snuba.use_group_id_column': True}):
# verify filter_keys and aggregation
assert snuba.query(
start=base_time - timedelta(days=1),
end=base_time + timedelta(days=1),
groupby=['issue'],
filter_keys={
'project_id': [self.project.id],
'issue': [group.id]
},
) == {group.id: 1}
# verify raw_query selecting issue row
assert snuba.raw_query(
start=base_time - timedelta(days=1),
end=base_time + timedelta(days=1),
selected_columns=['issue', 'timestamp'],
filter_keys={
'project_id': [self.project.id],
'issue': [group.id]
},
)['data'] == [{
'issue': group.id,
'timestamp': base_time.strftime('%Y-%m-%dT%H:%M:%S+00:00'),
}]
开发者ID:Kayle009,项目名称:sentry,代码行数:30,代码来源:test_snuba.py
示例12: get_top_group_tag_values
def get_top_group_tag_values(self, project_id, group_id, environment_id, key, limit=3):
start, end = self.get_time_range()
tag = 'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
'issue': [group_id],
}
conditions = [[tag, '!=', '']]
aggregations = [
['count()', '', 'count'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, [tag], conditions, filters,
aggregations, limit=limit, orderby='-count')
return [ObjectWrapper({
'times_seen': val['count'],
'first_seen': val['first_seen'],
'last_seen': val['last_seen'],
'key': key,
'value': name,
'group_id': group_id,
}) for name, val in six.iteritems(result)]
开发者ID:hosmelq,项目名称:sentry,代码行数:26,代码来源:backend.py
示例13: get_group_tag_keys_and_top_values
def get_group_tag_keys_and_top_values(self, project_id, group_id, environment_id, user=None):
from sentry import tagstore
start, end = self.get_time_range()
filters = {
'project_id': [project_id],
'environment': [environment_id],
'issue': [group_id],
}
aggregations = [
['count()', '', 'count'],
['topK(10)', 'tags_value', 'top'],
['uniq', 'tags_value', 'uniq'],
]
conditions = [
['tags_value', 'IS NOT NULL', None],
]
results = snuba.query(start, end, ['tags_key'], conditions, filters, aggregations)
return [{
'id': key,
'name': tagstore.get_tag_key_label(key),
'key': tagstore.get_standardized_key(key),
'uniqueValues': res['uniq'],
'totalValues': res['count'],
'topValues': [{
'id': val,
'name': tagstore.get_tag_value_label(key, val),
'key': tagstore.get_standardized_key(key),
'value': val,
} for val in res['top']],
} for key, res in six.iteritems(results)]
开发者ID:hosmelq,项目名称:sentry,代码行数:31,代码来源:backend.py
示例14: get_group_tag_values_for_users
def get_group_tag_values_for_users(self, event_users, limit=100):
start, end = self.get_time_range()
filters = {
'project_id': [eu.project_id for eu in event_users]
}
conditions = [
['tags[sentry:user]', 'IN', filter(None, [eu.tag_value for eu in event_users])]
]
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['issue', 'user_id'], conditions, filters,
aggregations, orderby='-last_seen', limit=limit,
referrer='tagstore.get_group_tag_values_for_users')
values = []
for issue, users in six.iteritems(result):
for name, data in six.iteritems(users):
values.append(
GroupTagValue(
group_id=issue,
key='sentry:user',
value=name,
**fix_tag_value_data(data)
)
)
return values
开发者ID:alexandrul,项目名称:sentry,代码行数:30,代码来源:backend.py
示例15: get_group_list_tag_value
def get_group_list_tag_value(self, project_id, group_ids, environment_id, key, value):
start, end = self.get_time_range()
tag = 'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
'issue': group_ids,
}
conditions = [
[tag, '=', value]
]
aggregations = [
['count()', '', 'count'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['issue'], conditions, filters, aggregations)
return {
issue: ObjectWrapper({
'times_seen': val['count'],
'first_seen': val['first_seen'],
'last_seen': val['last_seen'],
'key': key,
'value': value,
'group_id': issue,
}) for issue, val in six.iteritems(result)}
开发者ID:hosmelq,项目名称:sentry,代码行数:28,代码来源:backend.py
示例16: get_group_tag_value
def get_group_tag_value(self, project_id, group_id, environment_id, key, value):
from sentry.tagstore.exceptions import GroupTagValueNotFound
start, end = self.get_time_range()
tag = 'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
}
if group_id is not None:
filters['issue'] = [group_id]
conditions = [
[tag, '=', value]
]
aggregations = [['count()', '', 'count']]
result = snuba.query(start, end, [], conditions, filters, aggregations)
if result == 0:
raise GroupTagValueNotFound
else:
return ObjectWrapper({
'times_seen': result,
'key': key,
'value': value,
'group_id': group_id,
})
开发者ID:hosmelq,项目名称:sentry,代码行数:26,代码来源:backend.py
示例17: test
def test(self):
"This is just a simple 'hello, world' example test."
now = datetime.now()
events = [{
'event_id': 'x' * 32,
'primary_hash': '1' * 32,
'group_id': 1,
'project_id': self.project.id,
'message': 'message',
'platform': 'python',
'datetime': now.strftime('%Y-%m-%dT%H:%M:%S.%fZ'),
'data': {
'received': time.mktime(now.timetuple()),
}
}]
self.snuba_insert(events)
assert snuba.query(
start=now - timedelta(days=1),
end=now + timedelta(days=1),
groupby=['project_id'],
filter_keys={'project_id': [self.project.id]},
) == {self.project.id: 1}
开发者ID:Kayle009,项目名称:sentry,代码行数:26,代码来源:test_snuba.py
示例18: get_group_tag_values_for_users
def get_group_tag_values_for_users(self, event_users, limit=100):
start, end = self.get_time_range()
filters = {
'project_id': [eu.project_id for eu in event_users]
}
or_conditions = [cond for cond in [
('user_id', 'IN', [eu.ident for eu in event_users if eu.ident]),
('email', 'IN', [eu.email for eu in event_users if eu.email]),
('username', 'IN', [eu.username for eu in event_users if eu.username]),
('ip_address', 'IN', [eu.ip_address for eu in event_users if eu.ip_address]),
] if cond[2] != []]
conditions = [or_conditions]
aggregations = [
['count()', '', 'count'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, ['user_id'], conditions, filters,
aggregations, orderby='-last_seen', limit=limit)
return [ObjectWrapper({
'times_seen': val['count'],
'first_seen': val['first_seen'],
'last_seen': val['last_seen'],
'key': 'sentry:user',
'value': name,
}) for name, val in six.iteritems(result)]
开发者ID:hosmelq,项目名称:sentry,代码行数:28,代码来源:backend.py
示例19: __get_tag_keys
def __get_tag_keys(self, project_id, group_id, environment_id, limit=1000):
start, end = self.get_time_range()
filters = {
'project_id': [project_id],
'environment': [environment_id],
}
if group_id is not None:
filters['issue'] = [group_id]
aggregations = [
['uniq', 'tags_value', 'values_seen'],
['count()', '', 'count']
]
# TODO should this be sorted by count() descending, rather than the
# number of unique values
result = snuba.query(start, end, ['tags_key'], [], filters,
aggregations, limit=limit, orderby='-values_seen',
referrer='tagstore.__get_tag_keys')
if group_id is None:
ctor = TagKey
else:
ctor = functools.partial(GroupTagKey, group_id=group_id)
return set([
ctor(
key=key,
values_seen=data['values_seen'],
count=data['count'],
) for key, data in six.iteritems(result) if data['values_seen']
])
开发者ID:alexandrul,项目名称:sentry,代码行数:31,代码来源:backend.py
示例20: get_top_group_tag_values
def get_top_group_tag_values(self, project_id, group_id, environment_id, key, limit=3):
start, end = self.get_time_range()
tag = 'tags[{}]'.format(key)
filters = {
'project_id': [project_id],
'environment': [environment_id],
'issue': [group_id],
}
conditions = [[tag, '!=', '']]
aggregations = [
['count()', '', 'times_seen'],
['min', SEEN_COLUMN, 'first_seen'],
['max', SEEN_COLUMN, 'last_seen'],
]
result = snuba.query(start, end, [tag], conditions, filters,
aggregations, limit=limit, orderby='-times_seen',
referrer='tagstore.get_top_group_tag_values')
return [
GroupTagValue(
group_id=group_id,
key=key,
value=value,
**fix_tag_value_data(data)
) for value, data in six.iteritems(result)
]
开发者ID:binlee1990,项目名称:sentry,代码行数:26,代码来源:backend.py
注:本文中的sentry.utils.snuba.query函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论