-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
chore(replay): add a log sampling filter and sample replay ingest logs #79879
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,13 +56,18 @@ | |
from sentry_kafka_schemas.schema_types.ingest_replay_recordings_v1 import ReplayRecording | ||
|
||
from sentry.conf.types.kafka_definition import Topic, get_topic_codec | ||
from sentry.logging.handlers import SamplingFilter | ||
from sentry.models.project import Project | ||
from sentry.replays.lib.storage import ( | ||
RecordingSegmentStorageMeta, | ||
make_recording_filename, | ||
storage_kv, | ||
) | ||
from sentry.replays.usecases.ingest import process_headers, track_initial_segment_event | ||
from sentry.replays.usecases.ingest import ( | ||
MOBILE_EVENT_SAMPLE_RATE, | ||
process_headers, | ||
track_initial_segment_event, | ||
) | ||
from sentry.replays.usecases.ingest.dom_index import ( | ||
ReplayActionsEvent, | ||
emit_replay_actions, | ||
|
@@ -72,6 +77,13 @@ | |
from sentry.utils import json, metrics | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.addFilter( | ||
SamplingFilter( | ||
{ | ||
"mobile_event": MOBILE_EVENT_SAMPLE_RATE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this different from the other consumer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you suggesting we add rrweb_event_count here too? It's not currently logged in this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No just asking the question. If we're not logging it we don't need to include it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're only logging mobile_event in this one |
||
} | ||
) | ||
) | ||
|
||
RECORDINGS_CODEC: Codec[ReplayRecording] = get_topic_codec(Topic.INGEST_REPLAYS_RECORDINGS) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from sentry_sdk.tracing import Span | ||
|
||
from sentry.constants import DataCategory | ||
from sentry.logging.handlers import SamplingFilter | ||
from sentry.models.project import Project | ||
from sentry.replays.lib.storage import ( | ||
RecordingSegmentStorageMeta, | ||
|
@@ -24,7 +25,18 @@ | |
from sentry.utils import json, metrics | ||
from sentry.utils.outcomes import Outcome, track_outcome | ||
|
||
MOBILE_EVENT_SAMPLE_RATE = 0.5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sample rates defined here, can make them options if we want. Values right now are placeholders There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this an option. |
||
RRWEB_EVENT_COUNT_SAMPLE_RATE = 0.5 | ||
|
||
logger = logging.getLogger("sentry.replays") | ||
logger.addFilter( | ||
SamplingFilter( | ||
{ | ||
"mobile_event": MOBILE_EVENT_SAMPLE_RATE, | ||
"rrweb_event_count": RRWEB_EVENT_COUNT_SAMPLE_RATE, | ||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are either of these log messages emitted in our consumer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean a different file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does "mobile_event" represent? The log message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realized I was looking at the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want different rates for these, or could we sample all slow click logs at the same rate for now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same rate is fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you access the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can. The filter will become specific to our usecase though, so I'd move it into the init file |
||
} | ||
) | ||
) | ||
|
||
CACHE_TIMEOUT = 3600 | ||
COMMIT_FREQUENCY_SEC = 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't abbreviate.
probability_map
orprobability_mapping
.