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

feat(events tracking): add abstract class and logging implementation #80117

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

victoria-yining-huang
Copy link
Contributor

@victoria-yining-huang victoria-yining-huang commented Oct 31, 2024

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

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 31, 2024
snuba_topic_put
billing_topic_put
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded.

Copy link
Contributor Author

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"
Copy link
Contributor

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/

Copy link
Contributor Author

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


def __init__(self):
self.logger = logging.getLogger("EventTracker")
logging.basicConfig(level=logging.INFO)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

raise NotImplementedError


class EventTracker(EventTrackerBackend):
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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):
Copy link
Member

@lynnagara lynnagara Nov 1, 2024

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

Copy link
Contributor Author

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

Copy link
Member

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?

"""
Records how far an event has made it through the ingestion pipeline.
"""
self.logger.info(f"EventTracker recorded event {event_id} - {status.value}")
Copy link
Member

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

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All 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     

@victoria-yining-huang victoria-yining-huang requested a review from a team as a code owner November 4, 2024 22:06
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 4, 2024
Copy link
Contributor

github-actions bot commented Nov 4, 2024

🚨 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 #discuss-dev-infra channel.

Copy link

codecov bot commented Nov 4, 2024

Bundle Report

Changes will increase total bundle size by 20.69kB (0.06%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 31.89MB 20.69kB (0.06%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants