Skip to content

Commit 31cc621

Browse files
review feedback
1 parent 70baeb0 commit 31cc621

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

CONTRIBUTING.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ What's the concrete advice when writing a new integration?
120120

121121
### Requirements
122122

123-
1. Are you supporting a product feature? Then ensure that product expectations are clearly documented in https://develop.sentry.dev/sdk/telemetry/traces/modules/.
123+
1. Are you supporting a product feature? Then ensure that product expectations are clearly documented in the [develop docs](https://develop.sentry.dev/sdk/). Requirements for a given Insight Module must be available under https://develop.sentry.dev/sdk/telemetry/traces/modules/.
124124

125125
2. Confirm that all span, breadcrumb, log or metric attributes are defined in https://github.com/getsentry/sentry-conventions.
126126

@@ -151,28 +151,30 @@ What's the concrete advice when writing a new integration?
151151
- If the shared SDK logic will diverge for two patches, just don't force them through a common path in the first place.
152152
- If your shared code path has a bunch of conditionals today or will have a ton of conditionals in the future, that's the sign to not stick to DRY.
153153

154-
6. Be explicit
154+
6. Be explicit.
155155
- You're developing against a library, and that library uses specific types.
156156
- If you use `hasattr()` or `getattr()` to gate logic, you must verify the code path for all types that have this attribute (and Python has duck typing).
157157
- If you use `type().__name__` to gate logic, you must verify the behavior for all types with a given name (and Python has duck typing).
158158
- So just use `isinstance()`.
159159

160160
7. Heuristics will bite you later.
161-
- If something you write is best-effort, make sure there are no alternatives.
161+
- If something you write is best-effort, make sure there are no better alternatives.
162162

163163
8. Obsess about the unhappy path.
164-
- Users are interested in seeing what went wrong when something doesn't work. If the code in the `catch` block is garbage, that's a problem.
164+
- Users are interested in seeing what went wrong when something doesn't work. The code in the `except` block should not be an afterthought.
165165
- Let exceptions bubble-up as far as possible when reporting unhandled exceptions.
166-
- Preserve the user's original exception. Python chains exceptions when code in a `catch` block throws, so if a `catch` block in the SDK throws, the SDK exception takes the foreground ([#5188](https://github.com/getsentry/sentry-python/issues/5188)).
166+
- Preserve the user's original exception. Python chains exceptions when code in a `except` block throws, so if a `except` block in the SDK throws, the SDK exception takes the foreground ([#5188](https://github.com/getsentry/sentry-python/issues/5188)).
167167
- Please don't report exceptions that are caught further up in the library's call chain as unhandled.
168168

169169
9. Make sure your changes don't break end user contracts. The SDK should never alter the expected behavior of the underlying library or framework from the user's perspective and it shouldn't have any side effects.
170+
- For example, it shouldn't open new connections or evaluate lazy queries early.
170171

171172
10. Be defensive, but don't add dead code.
172173
- Don't assume the code you're patching will stay the same forever, especially if it's an internal function. Allow for future variability whenever it makes sense.
173174
- Dead code adds cognitive overhead when reasoning about code, so don't account for impossible scenarios.
174175

175176
11. Write tests, but don't write mocks.
177+
- Aim for end-to-end tests, not unit tests.
176178
- Don't call private SDK stuff directly, just use the patched library in a way that triggers the patch.
177179
- Mocks are _very expensive_ to maintain, particularly when testing patches for fast-moving libraries.
178180
- Consider the minimum versions supported, and document in `_MIN_VERSIONS` in `integrations/__init__.py`.
@@ -181,11 +183,11 @@ What's the concrete advice when writing a new integration?
181183

182184
12. Be careful patching decorators
183185
- Does the library's decorator apply to sync or async functions?
184-
- Some decorators can be applied to classes and functions, and both with and without arguments. Make sure you handle all applicable cases.
186+
- Some decorators can be applied to classes and functions, and both with and without arguments. Make sure you handle and test all applicable cases.
185187

186188
13. Avoid registering a new client or the like. The user drives the client, and the client owns integrations.
187189

188-
14. Allow the user to turn off the integration by changing the client. Check `sentry_sdk.get_client().get_integration(MyIntegration)` from within your signal handlers to see if your integration is still active before you do anything impactful (such as sending an event).
190+
14. Allow the user to turn off the integration by changing the client. Check `sentry_sdk.get_client().get_integration(MyIntegration)` from within your signal handlers or patches to see if your integration is still active before you do anything impactful (such as sending an event). If it's not active, the patch my be no-op.
189191

190192
### Document
191193

0 commit comments

Comments
 (0)