Skip to content

ref(seer): add viewer_context_scope to post_process_group - #121545

Open
sehr-m wants to merge 1 commit into
masterfrom
sehr/viewer-context-post-process
Open

ref(seer): add viewer_context_scope to post_process_group#121545
sehr-m wants to merge 1 commit into
masterfrom
sehr/viewer-context-post-process

Conversation

@sehr-m

@sehr-m sehr-m commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Set viewer_context_scope in post_process_group after project/org resolution, covering all downstream Seer calls in the post-process pipeline (lightweight_rca_cluster, etc.)
  • Tasks dispatched from post_process_group (like trigger_lightweight_rca_cluster_task) will also get ViewerContext propagated via taskbroker's ViewerContextHook
  • This addresses the remaining seer.viewer_context_not_set warnings that persisted after ref(seer): add viewer_context_scope to ingest and explorer_index paths #121467 — all traced to lightweight_rca_cluster running in task-ingest-push-worker

Part of AIML-3206 (SeerViewerContext retirement Step 2).

Test plan

  • Lint and mypy pass
  • post_process tests require devservices (Snuba) — pre-existing, not related to this change
  • After deploy: seer.viewer_context_not_set warnings in GCP logs should drop
  • Datadog seer.viewer_context_resolution metric contextvar_missing should drop

Set ViewerContext after project/org resolution in post_process_group,
covering all downstream Seer calls in the post-process pipeline
(lightweight_rca_cluster, etc.) and any tasks dispatched from it via
ViewerContextHook propagation.

Part of AIML-3206 (SeerViewerContext retirement Step 2).
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

AIML-3206

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 7, 2026
@sehr-m
sehr-m marked this pull request as ready for review August 7, 2026 18:07
@sehr-m
sehr-m requested a review from a team as a code owner August 7, 2026 18:07
"is_regression": bool(is_regression),
"is_new_group_environment": is_new_group_environment,
}
with viewer_context_scope(

@cvxluo cvxluo Aug 7, 2026

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.

can we wrap only the post process jobs that need viewer context?

@sehr-m sehr-m Aug 7, 2026

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.

The thought process was that setting it at the entrypoint means any Seer call added to the post-process pipeline in the future automatically has ViewerContext. The current issue is that when the addition is needed at the call site it gets very fragmented and poorly maintained because people forget to add it, whereas setting a contextvar for the other pipeline steps is pretty much free. (Also this is mainly for seer though it has uses for security etc within sentry as well)

@cvxluo cvxluo Aug 7, 2026

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.

there was some discussion here about removing some of these Seer calls from the hot path here: #121462 (comment)

change looks ok as is. i'm a little concerned since this means that any changes to how ViewerContext works or any performance / latency problem there has a chance of breaking post process, so i'd like to see if we can avoid it.

"is_regression": bool(is_regression),
"is_new_group_environment": is_new_group_environment,
}
with viewer_context_scope(

@cvxluo cvxluo Aug 7, 2026

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.

there was some discussion here about removing some of these Seer calls from the hot path here: #121462 (comment)

change looks ok as is. i'm a little concerned since this means that any changes to how ViewerContext works or any performance / latency problem there has a chance of breaking post process, so i'd like to see if we can avoid it.

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