Skip to content

Commit 6a74cf3

Browse files
authored
feat(python): Add custom_repr docs (#11059)
1 parent 584839e commit 6a74cf3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

docs/platforms/python/configuration/options.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ When set to `False`, no auto-enabling integrations will be enabled by default, e
219219

220220
Configures whether [default integrations](/platforms/python/integrations/default-integrations/) should be enabled. The default is `True`.
221221

222-
Setting `default_integrations` to `False` disables all default integrations **as well as all auto-enabling integrations**, unless they are specifically added in the `integrations` option, described above.
222+
Setting `default_integrations` to `False` disables all default integrations **as well as all auto-enabling integrations**, unless they are specifically added in the `integrations` option, described above.
223223

224224

225225
## Hooks
@@ -386,3 +386,23 @@ The threshold in milliseconds for adding the source location to database queries
386386
Default is `100` ms.
387387

388388
</ConfigKey>
389+
390+
<ConfigKey name="custom-repr">
391+
392+
A custom [repr](https://docs.python.org/3/library/functions.html#repr) function to run while serializing an object. Use this to control how your custom objects and classes are visible in Sentry.
393+
394+
Return a string for that repr value to be used or `None` to continue serializing how Sentry would have done it anyway.
395+
396+
```python
397+
def custom_repr(obj):
398+
if isinstance(obj, MyCustomClass):
399+
return "<MyCustomClass>"
400+
else
401+
return None
402+
403+
sentry_sdk.init(custom_repr=custom_repr)
404+
```
405+
406+
Default is `None`.
407+
408+
</ConfigKey>

0 commit comments

Comments
 (0)