Skip to content

Commit 1c0c161

Browse files
authored
ref(codeowners): improve example for issue ownership (#15012)
We've seen some confusion in how issue ownership works, especially on how stack traces are used in ownership assignment (ex. https://sentry.slack.com/archives/C058J6Y4HQU/p1757596036812509). This emphasizes that we use _all_ stack trace frames when evaluating issue owners, and makes the example more comprehensive to illustrate this. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
1 parent de87d0b commit 1c0c161

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

docs/product/issues/ownership-rules/index.mdx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ description: "Learn how to set up ownership rules to automatically assign issues
66

77
<Include name="only-error-issues-note.mdx" />
88

9-
Sentry offers multiple ways to define the "ownership" of an issue. With ownership defined, we can automatically assign issues and send alerts to the owner. Sentry defines ownership with _code owners_ and _ownership rules_. Code owners functionality lets you import your [GitHub](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) or [GitLab](https://docs.gitlab.com/ee/user/project/code_owners.html) CODEOWNERS file, and then we assign issues according to those file paths. Ownership rules allow you to override the assignments based on code owners and provide advanced matcher types (for example, urls and tags). These rules can also match on the file paths of files in the stack trace, URL of the request, or event tags.
9+
Sentry offers multiple ways to define the "ownership" of an issue. With ownership defined, we can automatically assign issues and send alerts to the owner. Sentry defines ownership with _ownership rules_ and _code owners_. Ownership rules can assign issues based on the file paths in the event stack trace, URL of the request, or event tags, and also allow you to override rules in code owners. Code owners functionality lets you import your [GitHub](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) or [GitLab](https://docs.gitlab.com/ee/user/project/code_owners.html) CODEOWNERS file and assign issues based on the file paths in the event stack trace.
1010

1111
Once an issue has been assigned, whether manually by a user or automatically by Sentry, future auto-assignment will be turned off for that issue.
1212

13-
## Methods
14-
15-
Ownership rules and code owners are matched against individual events in an issue. This matching is relied upon in other areas of [sentry.io](https://sentry.io), as described in the following sections.
16-
1713
### Ownership Rules
1814

1915
You can set ownership by defining ownership rules per project. To configure ownership rules, navigate to **[Project] > Settings > Ownership Rules**, or click on the "Create Ownership Rule" button on an **Issue Details** page.
@@ -100,54 +96,58 @@ Create external team/user mappings for your GitHub/GitLab teams and users by nav
10096

10197
## Evaluation Flow
10298

103-
If you have both ownership rules and code owners, Sentry evaluates an event’s in-app frames against the rules in the following order:
99+
Ownership rules and code owners are matched against individual events in an issue. Sentry evaluates an event by checking if _any_ of its in-app stack trace frames match a rule from:
104100

105101
1. Code owners, top-to-bottom
106-
107-
a. If there are multiple owners in the rule, left-to-right
108-
109102
2. Ownership rules, top-to-bottom
110103

111-
a. If there are multiple owners in the rule, left-to-right
112-
113-
After evaluation, the last rule matching returns the assignment. The order of the event’s stack trace filepaths is irrelevant in determining the rule assignment.
104+
The _last_ rule that matches for an event is used for issue assignment. If there are multiple owners in a rule, we take the leftmost owner. The order of in-app stack trace frames in an event is not used in determining the rule assignment.
114105

115106
### Example
116107

108+
Sentry receives an event with the following stack trace:
109+
- `models/UserModel.py` (frame 1)
110+
- `backend/endpoints/auth/user.py` (frame 2)
111+
- `backend/api/base.py` (frame 3)
112+
117113
**Code Owners:**
118114

119-
```
120-
codeowners:*.js #ecosystem
115+
```bash
116+
# Frontend
117+
*.js @frontend-team
118+
*.tsx @frontend-team
119+
120+
# Backend
121+
backend/ @engineering-team
122+
models/ @models-team
123+
backend/api/ @api-team
121124
```
122125

123126
**Ownership Rules:**
124127

128+
```text
129+
path:backend/endpoints/* #api-team
130+
path:backend/endpoints/auth/* #auth-team #enterprise-team
125131
```
126-
path:*.js #ecosystem #frontend
127-
path:sentry/api/* #api
128-
url:*subscription* #billing
129-
path:dist/frontend/components/* #frontend
130-
```
131-
132-
When Sentry receives an event with a stack trace filepath: `dist/frontend/components/sidebar.js`, we:
133-
134-
1. Evaluate against the code owners top-to-bottom; we get one match with two owners in the rule.
135132

136-
a. Evaluate the rule left-to-right; we choose the first owner.
133+
For this event, we:
137134

135+
1. Evaluate against the code owners top-to-bottom; we get three matches.
138136
2. Evaluate against the ownership rules top-to-bottom; we get two matches.
139137

140138
The matches, in order, are:
141139

142140
```
143141
[
144-
"codeowners:*.js #ecosystem",
145-
"path:*.js #ecosystem",
146-
"path:dist/frontend/components/* #frontend"
142+
"codeowners:backend/ #engineering-team", # match on frame 2 and 3
143+
"codeowners:models/ #models-team", # match on frame 1
144+
"codeowners:backend/api/ #api-team", # match on frame 3
145+
"path:backend/endpoints/* #api-team", # match on frame 2
146+
"path:backend/endpoints/auth/* #auth-team #enterprise-team", # match on frame 2
147147
]
148148
```
149149

150-
Sentry will return the last matching rule, which in this case is `path:dist/frontend/components/* #frontend`
150+
Sentry will return the last matching rule, which in this case is `path:backend/endpoints/auth/* #auth-team #enterprise-team`. Although there are two owners in the last matching rule, Sentry will assign the issue to the first owner, `#auth-team`.
151151

152152
## Where It's Applied
153153

0 commit comments

Comments
 (0)