-
-
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
feat(events tracking): add abstract class and logging implementation #80117
base: master
Are you sure you want to change the base?
Conversation
src/sentry/utils/event_tracker.py
Outdated
snuba_topic_put | ||
billing_topic_put |
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.
unneeded.
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.
updated the list
START = "start" | ||
END = "end" |
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.
Consider making the enum an integer. That would take a lot less memory in redis.
The galaxy brain version would be to create a bitmap. One bit per phase. Each event only needs 12 bits to encode all phases. https://redis.io/docs/latest/develop/data-types/bitmaps/
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.
not writing to redis with the logging implementation but i get the idea
src/sentry/utils/event_tracker.py
Outdated
|
||
def __init__(self): | ||
self.logger = logging.getLogger("EventTracker") | ||
logging.basicConfig(level=logging.INFO) |
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.
doesn't this modify the root logger for all of the application?
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.
removed
src/sentry/utils/event_tracker.py
Outdated
raise NotImplementedError | ||
|
||
|
||
class EventTracker(EventTrackerBackend): |
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.
Do you need the base class for any reason? Are you planning to provide a second implementation? I'd just remove it if not and make it a bit simpler
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.
Are you planning to provide a second implementation?
not anytime soon, for the purpose of tracking event stages logger based implementation should be sufficient. Maybe another metric based implementation can be used for refunding?
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.
im gonna delete for now
self.logger = logging.getLogger("EventTracker") | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
def record_event_stage_status(self, event_id: str, status: EventStageStatus): |
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.
can you please add sampling logic in here? we'll be in trouble if we log every event. i think it's safer to not require the caller to remember to do that and build sampling as a core concept into this class instead
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.
added, default is 0.01
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.
you don't want random though do you? don't you need consistent sampling so that the same events get sampled at every stage of the pipeline?
a147a53
to
c09a7c4
Compare
2ebf8d5
to
8b5234b
Compare
""" | ||
Records how far an event has made it through the ingestion pipeline. | ||
""" | ||
self.logger.info(f"EventTracker recorded event {event_id} - {status.value}") |
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.
if you are building log analysis tools on top of this structured logging might make life easier
9d4217c
to
3143ea2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #80117 +/- ##
========================================
Coverage 78.12% 78.12%
========================================
Files 7163 7166 +3
Lines 316700 316849 +149
Branches 43663 43685 +22
========================================
+ Hits 247414 247536 +122
- Misses 62944 62961 +17
- Partials 6342 6352 +10 |
🚨 Warning: This pull request contains Frontend and Backend changes! It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently. Have questions? Please ask in the |
Bundle ReportChanges will increase total bundle size by 20.69kB (0.06%) ⬆️. This is within the configured threshold ✅ Detailed changes
|
af42f0e
to
3143ea2
Compare
design doc
need to track the completion of each stage, to 1) compute events conversion rates 2) enable debugging visibility into where events are being dropped
the usage will be heavily sampled to not blow up traffic