Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Remove sampling option, remove trimming from renormalization #13563

Merged
merged 4 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/sentry/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from semaphore.processing import StoreNormalizer

from sentry import eventtypes
from sentry import eventtypes, options
from sentry.constants import EVENT_ORDERING_KEY
from sentry.db.models import (
BoundedBigIntegerField,
Expand All @@ -41,6 +41,17 @@
from sentry.utils.strings import truncatechars


def _should_disable_trim(event_id):
if not event_id:
return False

sample_rate = options.get('store.disable-trim-in-renormalization')
if sample_rate == 0:
return False

return int(md5(event_id).hexdigest(), 16) % (10 ** 8) <= (sample_rate * (10 ** 8))


class EventDict(CanonicalKeyDict):
"""
Creating an instance of this dictionary will send the event through basic
Expand All @@ -58,7 +69,10 @@ def __init__(self, data, skip_renormalization=False, **kwargs):
)

if not skip_renormalization and not is_renormalized:
normalizer = StoreNormalizer(is_renormalize=True)
normalizer = StoreNormalizer(
is_renormalize=True,
enable_trimming=not _should_disable_trim(data.get('event_id'))
)
data = normalizer.normalize_event(dict(data))

CanonicalKeyDict.__init__(self, data, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/options/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,5 @@


# Normalization after processors
register('store.normalize-after-processing', default=0.0)
register('store.normalize-after-processing', default=0.0) # unused
register('store.disable-trim-in-renormalization', default=0.0)
29 changes: 11 additions & 18 deletions src/sentry/tasks/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import logging
from datetime import datetime
import random
import six

from time import time
Expand All @@ -19,7 +18,7 @@

from semaphore.processing import StoreNormalizer

from sentry import features, reprocessing, options
from sentry import features, reprocessing
from sentry.constants import DEFAULT_STORE_NORMALIZER_ARGS
from sentry.attachments import attachment_cache
from sentry.cache import default_cache
Expand All @@ -44,11 +43,6 @@
CRASH_REPORT_TYPES = ('event.minidump', )


def _should_normalize_after_processing():
value = options.get('store.normalize-after-processing')
return value and random.random() < value


class RetryProcessing(Exception):
pass

Expand Down Expand Up @@ -273,17 +267,16 @@ def _do_process_event(cache_key, start_time, event_id, process_task,
data = dict(data.items())

if has_changed:
if _should_normalize_after_processing():
# Run some of normalization again such that we don't:
# - persist e.g. incredibly large stacktraces from minidumps
# - store event timestamps that are older than our retention window
# (also happening with minidumps)
normalizer = StoreNormalizer(
remove_other=False,
is_renormalize=True,
**DEFAULT_STORE_NORMALIZER_ARGS
)
data = normalizer.normalize_event(dict(data))
# Run some of normalization again such that we don't:
# - persist e.g. incredibly large stacktraces from minidumps
# - store event timestamps that are older than our retention window
# (also happening with minidumps)
normalizer = StoreNormalizer(
remove_other=False,
is_renormalize=True,
**DEFAULT_STORE_NORMALIZER_ARGS
)
data = normalizer.normalize_event(dict(data))

issues = data.get('processing_issues')

Expand Down
6 changes: 6 additions & 0 deletions src/sentry/utils/pytest/sentry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

import pytest
import mock
import os

Expand Down Expand Up @@ -252,3 +253,8 @@ def pytest_runtest_teardown(item):
model.objects.clear_local_cache()

Hub.main.bind_client(None)


@pytest.fixture(autouse=True)
def _disable_renormalization_trim(monkeypatch):
monkeypatch.setattr('sentry.models.event._should_disable_trim', lambda _: True)