本文整理汇总了Python中sentry.app.tsdb.incr函数的典型用法代码示例。如果您正苦于以下问题:Python incr函数的具体用法?Python incr怎么用?Python incr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了incr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_integration
def test_integration(self, has_feature):
Project.objects.all().delete()
now = datetime(2016, 9, 12, tzinfo=pytz.utc)
has_feature.side_effect = lambda name, *a, **k: {
'organizations:reports:deliver': True,
'organizations:reports:prepare': True,
}.get(name, False)
project = self.create_project(
organization=self.organization,
team=self.team,
)
tsdb.incr(
tsdb.models.project,
project.id,
now - timedelta(days=1),
)
member_set = set(project.team.member_set.all())
with self.tasks():
prepare_reports(timestamp=to_timestamp(now))
assert len(mail.outbox) == len(member_set) == 1
message = mail.outbox[0]
assert self.organization.name in message.subject
示例2: test_integration
def test_integration(self):
Project.objects.all().delete()
now = datetime(2016, 9, 12, tzinfo=pytz.utc)
project = self.create_project(
organization=self.organization,
team=self.team,
date_added=now - timedelta(days=90),
)
tsdb.incr(
tsdb.models.project,
project.id,
now - timedelta(days=1),
)
member_set = set(project.team.member_set.all())
with self.tasks():
prepare_reports(timestamp=to_timestamp(now))
assert len(mail.outbox) == len(member_set) == 1
message = mail.outbox[0]
assert self.organization.name in message.subject
示例3: test_simple
def test_simple(self):
self.login_as(user=self.user)
group1 = self.create_group()
group2 = self.create_group()
url = reverse('sentry-api-0-group-stats', kwargs={
'group_id': group1.id,
})
response = self.client.get(url, format='json')
assert response.status_code == 200, response.content
for point in response.data:
assert point[1] == 0
assert len(response.data) == 24
tsdb.incr(tsdb.models.group, group1.id, count=3)
tsdb.incr(tsdb.models.group, group2.id, count=5)
response = self.client.get(url, format='json')
assert response.status_code == 200, response.content
assert response.data[-1][1] == 3, response.data
for point in response.data[:-1]:
assert point[1] == 0
assert len(response.data) == 24
示例4: test_simple
def test_simple(self):
self.login_as(user=self.user)
project = self.create_project()
group1 = self.create_group(project=project)
group2 = self.create_group(project=project)
url = reverse('sentry-api-0-project-group-stats', kwargs={
'organization_slug': project.organization.slug,
'project_slug': project.slug,
})
response = self.client.get('%s?id=%s&id=%s' % (url, group1.id, group2.id),
format='json')
tsdb.incr(tsdb.models.group, group1.id, count=3)
response = self.client.get('%s?id=%s&id=%s' % (url, group1.id, group2.id),
format='json')
assert response.status_code == 200, response.content
assert len(response.data) == 2
assert str(group1.id) in response.data
assert str(group2.id) in response.data
group_data = response.data[str(group1.id)]
assert group_data[-1][1] == 3, response.data
for point in group_data[:-1]:
assert point[1] == 0
assert len(group_data) == 24
示例5: test_integration
def test_integration(self):
Project.objects.all().delete()
now = datetime(2016, 9, 12, tzinfo=pytz.utc)
project = self.create_project(
organization=self.organization,
team=self.team,
date_added=now - timedelta(days=90),
)
tsdb.incr(
tsdb.models.project,
project.id,
now - timedelta(days=1),
)
member_set = set(project.team.member_set.all())
with self.tasks(), \
mock.patch.object(tsdb, 'get_earliest_timestamp') as get_earliest_timestamp:
# Ensure ``get_earliest_timestamp`` is relative to the fixed
# "current" timestamp -- this prevents filtering out data points
# that would be considered expired relative to the *actual* current
# timestamp.
get_earliest_timestamp.return_value = to_timestamp(now - timedelta(days=60))
prepare_reports(timestamp=to_timestamp(now))
assert len(mail.outbox) == len(member_set) == 1
message = mail.outbox[0]
assert self.organization.name in message.subject
示例6: _incr_internal
def _incr_internal(key, amount):
from sentry.app import tsdb
sample_rate = settings.SENTRY_METRICS_SAMPLE_RATE
if _should_sample():
amount = _sampled_value(amount)
tsdb.incr(tsdb.models.internal, key, count=amount)
示例7: test_simple
def test_simple(self):
self.login_as(user=self.user)
project = self.create_project()
group1 = self.create_group(project=project)
group2 = self.create_group(project=project)
url = u'/api/0/projects/{}/{}/issues/stats/'.format(
project.organization.slug,
project.slug,
)
response = self.client.get('%s?id=%s&id=%s' % (url, group1.id, group2.id), format='json')
tsdb.incr(tsdb.models.group, group1.id, count=3)
response = self.client.get('%s?id=%s&id=%s' % (url, group1.id, group2.id), format='json')
assert response.status_code == 200, response.content
assert len(response.data) == 2
assert six.text_type(group1.id) in response.data
assert six.text_type(group2.id) in response.data
group_data = response.data[six.text_type(group1.id)]
assert group_data[-1][1] == 3, response.data
for point in group_data[:-1]:
assert point[1] == 0
assert len(group_data) == 24
示例8: _incr_internal
def _incr_internal(key, instance=None, tags=None, amount=1):
from sentry.app import tsdb
if _should_sample():
amount = _sampled_value(amount)
if instance:
full_key = '{}.{}'.format(key, instance)
else:
full_key = key
tsdb.incr(tsdb.models.internal, full_key, count=amount)
示例9: _incr_internal
def _incr_internal(key, instance=None, tags=None, amount=1):
from sentry.app import tsdb
sample_rate = settings.SENTRY_METRICS_SAMPLE_RATE
if _should_sample():
amount = _sampled_value(amount)
if instance:
full_key = '{}.{}'.format(key, instance)
else:
full_key = key
tsdb.incr(tsdb.models.internal, full_key, count=amount)
示例10: incr
def incr(key, amount=1):
from sentry.app import tsdb
sample_rate = settings.SENTRY_METRICS_SAMPLE_RATE
statsd.incr(_get_key(key), amount,
rate=sample_rate)
if sample_rate >= 1 or random() >= sample_rate:
if sample_rate < 1:
amount = int(amount * (1.0 / sample_rate))
tsdb.incr(tsdb.models.internal, key, count=amount)
示例11: test_more_than_zero
def test_more_than_zero(self):
event = self.get_event()
rule = self.get_rule({
'interval': Interval.ONE_MINUTE,
'value': '0',
})
self.assertDoesNotPass(rule, event)
rule.clear_cache(event)
tsdb.incr(tsdb.models.group, event.group_id, count=1)
self.assertPasses(rule, event)
示例12: _incr_internal
def _incr_internal(key, instance=None, tags=None, amount=1):
from sentry.app import tsdb
if _should_sample():
amount = _sampled_value(amount)
if instance:
full_key = '{}.{}'.format(key, instance)
else:
full_key = key
try:
tsdb.incr(tsdb.models.internal, full_key, count=amount)
except Exception:
logger = logging.getLogger('sentry.errors')
logger.exception('Unable to incr internal metric')
示例13: test_doesnt_send_consecutive
def test_doesnt_send_consecutive(self):
event = self.get_event()
value = 10
rule = self.get_rule({
'interval': Interval.ONE_HOUR,
'value': six.text_type(value),
})
self.assertDoesNotPass(rule, event)
rule.clear_cache(event)
tsdb.incr(tsdb.models.group, event.group_id, count=value + 1)
self.assertPasses(rule, event)
self.assertDoesNotPass(rule, event, rule_last_active=timezone.now())
示例14: test_simple
def test_simple(self):
self.login_as(user=self.user)
org = self.create_organization(owner=self.user, name='baz')
tsdb.incr(tsdb.models.organization_total_received, org.id, count=3)
url = reverse('sentry-api-0-organization-stats', args=[org.slug])
response = self.client.get(url, format='json')
assert response.status_code == 200, response.content
assert response.data[-1][1] == 3, response.data
for point in response.data[:-1]:
assert point[1] == 0
assert len(response.data) == 24
示例15: test_doesnt_send_consecutive
def test_doesnt_send_consecutive(self):
event = self.get_event()
rule = self.get_rule({
'interval': Interval.ONE_HOUR,
'value': '10',
})
tsdb.incr(tsdb.models.group, event.group_id, count=11)
rule = self.get_rule({
'interval': Interval.ONE_HOUR,
'value': '10',
})
self.assertPasses(rule, event)
self.assertDoesNotPass(rule, event, rule_last_active=timezone.now())