Skip to content

feat(action-log): Instrument the activity read path - #123846

Open
shashjar wants to merge 3 commits into
masterfrom
shashjar/instrument-the-activity-read-path
Open

feat(action-log): Instrument the activity read path#123846
shashjar wants to merge 3 commits into
masterfrom
shashjar/instrument-the-activity-read-path

Conversation

@shashjar

@shashjar shashjar commented Sep 8, 2026

Copy link
Copy Markdown
Member

Resolves https://linear.app/getsentry/issue/ISWF-3415/instrument-the-gale-activity-read-path.

Adds issues.action_log.activity_read, tagged with endpoint / result / reason. One metric is recorded per read/attempted read. endpoint is the route's url_name.

get_serialized_activity_items is implemented and used for group_details, group_activities, and group_index.update.prepare_response.

Behavior changes:

  • group_details.groupactionlogentry.not_found and its two counterparts were consolidated into one issues.action_log.activity_read.not_found log with endpoint in extra
  • group_index.update.prepare_response now falls back to an empty log instead of omitting the activity key, matching the other two endpoints

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 8, 2026
@linear-code

linear-code Bot commented Sep 8, 2026

Copy link
Copy Markdown

ISWF-3415

@shashjar

shashjar commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 428ecb1. Configure here.

@shashjar
shashjar requested review from cvxluo and kcons September 8, 2026 21:46
@shashjar
shashjar marked this pull request as ready for review September 8, 2026 21:46
@shashjar
shashjar requested review from a team as code owners September 8, 2026 21:46
@shashjar
shashjar removed request for a team September 8, 2026 21:46

@kcons kcons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems mostly OK, I'm just grasping for ways to make the logging trivial to do correctly without doing much reading and without too much overhead.
In our ideal world, I think "give me activity feed data, ready for serialization" would be a single call that does the relevant logging and backend choice, but I guess for notes stuff it's not quite that simple.

Comment thread src/sentry/issues/derived/gate.py Outdated
*,
endpoint: ActivityReadEndpoint,
) -> bool:
"""Whether the action log can back this project's Activity-shaped responses."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems worth documenting that when it returns false, it calls record_activity_read, and when True, the caller is expected to.



def record_activity_read(
endpoint: ActivityReadEndpoint,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

might make sense to use url_name (request.resolver_match.url_name if request.resolver_match else "unknown") here. More standard, and doesn't require a new enum.

tags = {"endpoint": endpoint.value, "result": result.value}
if reason is not None:
tags["reason"] = reason.value
metrics.incr(ACTIVITY_READ_METRIC, sample_rate=1.0, tags=tags)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this allow us to count those without a reason directly using 'N/A' or something? I can't recall.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, i think missing tags are countable

Retrieve all the Activities for a Group
"""
if should_serve_action_log_activity(group.project, request.user):
if should_serve_action_log_activity(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

might seem a little silly, but I think it's probably worth a "get_serialized_activity_items" or something, so we decouple where we get the data and how we report it from the use.
I think the value is mostly in if you can use that in two or more endpoints. It looks like maybe but if not, feel free to ignore.

This all just feels a little more brittle than we'd like, so if there's a way to abstract it nicely, seems worth it.

Alternately, a vairable for read_result, result_result, and possibly endpoint that get mutated as we go and used at log sites would (somewhat paradoxically) make things simpler, just because of the shared dependency relationship. Or even a mutable ActivityReadRecord with a .report() method and a set_fallback_reason, as then it'd be "we call report on this, and if it's not GALE we update it", though that'd probbaly have get_actions_for_group (or some wrapper) returning a tuple.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah makes sense, i'll try to figure out an abstraction like that

@shashjar
shashjar requested a review from a team as a code owner September 9, 2026 18:59
@shashjar
shashjar requested a review from kcons September 9, 2026 19:16
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants