Skip to content

Conversation

@saponifi3d
Copy link
Contributor

Description

Started the work to improve logging and discoverability in the stack for investigating issues. Created the WorkflowNotProcessable dataclass as a way to store / structure the result and have an improved consistent return value from the method. This way, we'll know that the processing stopped at one point, why, and all the information gathered so far about the evaluation.

Out of scope for now:

  • All the process_action stuff i left comments on; i'd like to make process_workflows to be side-effect free in the future; this is the first step in getting there and covers the requirements to debug the customer cases.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 11, 2025

# This dictionary stores the data for WorkflowNotProcessable
# and is eventually unpacked to pass into the frozen dataclass
# TODO -- should this be a workflow event context data 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.

Curious if anyone has any thoughts on this; should this extra_data dict just be the WorkflowEventContextData?

Copy link
Member

Choose a reason for hiding this comment

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

I think this is all evaluation context that makes sense for this method primarily, and arguably for all outcomes.
My inclination is to have a WorkflowEvaluationContext (..Result?) dataclass with the fields we want, populate that, and return it at the end.
Like the dict, just a bit clearer and more type-y.
To the extent we want a different return for firing and not-firing, I think we could do that with a variant within WER.. I don't think we currently have data differences between the two cases, so it may just be a bool to make "we actually triggered" explicit and not require knowledge of what action counts mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, i was more referring to the already existing data type WorkflowEventContextData -- but i don't think we're using that anywhere other than to set it. i'll go through and remove all that code in another PR, i'm hoping that this and a couple other changes will remove any need for it.

for this PR, i'll update this extra_data dict to be WorkflowEvaluationData or something along those lines so it's a little clearer what's up.

@saponifi3d saponifi3d marked this pull request as ready for review November 11, 2025 23:27
@saponifi3d saponifi3d requested a review from a team as a code owner November 11, 2025 23:27
TODO - further refactor the `process_actions` portion, to improve handling / logging.
"""
from sentry.workflow_engine.processors.workflow import process_workflows
Copy link
Member

Choose a reason for hiding this comment

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

this import is probably unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅 those pesky file refactors. thanks for the catch!


# This dictionary stores the data for WorkflowNotProcessable
# and is eventually unpacked to pass into the frozen dataclass
# TODO -- should this be a workflow event context data instead?
Copy link
Member

Choose a reason for hiding this comment

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

I think this is all evaluation context that makes sense for this method primarily, and arguably for all outcomes.
My inclination is to have a WorkflowEvaluationContext (..Result?) dataclass with the fields we want, populate that, and return it at the end.
Like the dict, just a bit clearer and more type-y.
To the extent we want a different return for firing and not-firing, I think we could do that with a variant within WER.. I don't think we currently have data differences between the two cases, so it may just be a bool to make "we actually triggered" explicit and not require knowledge of what action counts mean.

"""
from sentry.workflow_engine.processors.workflow import process_workflows

evaluation = process_workflows(batch_client, event_data, event_start_time, detector)
Copy link
Member

Choose a reason for hiding this comment

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

if we define a def log_to(logger: Logger, event: str) on the return type, this function can be replaced with a one-line addition to the task code.

@codecov
Copy link

codecov bot commented Nov 12, 2025

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   #103190      +/-   ##
===========================================
- Coverage   80.66%    80.66%   -0.01%     
===========================================
  Files        9241      9242       +1     
  Lines      393680    393855     +175     
  Branches    25055     25055              
===========================================
+ Hits       317578    317707     +129     
- Misses      75640     75686      +46     
  Partials      462       462              

workflow_env: Environment | None = None


@dataclass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 should we freeze these classes for safety / remake them or is it better for us to just modify during processing... (ui person in me tells me that mutating state is bad 🤣)

…ently being used, rather than optimistically will be used. and use the 'msg' field
@saponifi3d saponifi3d enabled auto-merge (squash) November 12, 2025 19:37
@saponifi3d saponifi3d merged commit 49b7c13 into master Nov 12, 2025
65 checks passed
@saponifi3d saponifi3d deleted the jcallender/aci/debugging-log branch November 12, 2025 19:58
saponifi3d added a commit that referenced this pull request Nov 12, 2025
@saponifi3d saponifi3d added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Nov 12, 2025
@getsentry-bot
Copy link
Contributor

PR reverted: 238b51a

getsentry-bot added a commit that referenced this pull request Nov 12, 2025
saponifi3d added a commit that referenced this pull request Nov 12, 2025
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 Trigger: Revert Add to a merged PR to revert it (skips CI)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants