Skip to content

Commit c274bb5

Browse files
authored
Document python attributes kwarg for logs (#14072)
Documents based on feedback from getsentry/sentry-python#4220 (comment)
1 parent 5ae80bb commit c274bb5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

platform-includes/logs/usage/python.mdx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Once the feature is enabled on the SDK and the SDK is initialized, you can send
22

33
The `logger` namespace exposes six methods that you can use to log messages at different log levels: `trace`, `debug`, `info`, `warning`, `error`, and `fatal`.
44

5-
You can pass additional attributes directly to the logging functions. These properties will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
5+
You can send structured messages by using the `{attribute_name}` placeholder syntax. The properties of this message will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column.
66

77
```python
88
from sentry_sdk import logger as sentry_logger
@@ -14,3 +14,19 @@ sentry_logger.warning('Rate limit reached for endpoint {endpoint}', endpoint='/a
1414
sentry_logger.error('Failed to process payment. Order: {order_id}. Amount: {amount}', order_id="or_2342", amount=99.99)
1515
sentry_logger.fatal('Database {database} connection pool exhausted', database="users")
1616
```
17+
18+
You can also pass additional attributes directly to the logging functions via the `attributes` kwarg.
19+
20+
```python
21+
from sentry_sdk import logger as sentry_logger
22+
23+
sentry_logger.error(
24+
'Payment processing failed',
25+
attributes={
26+
'payment.provider': 'stripe',
27+
'payment.method': 'credit_card',
28+
'payment.currency': 'USD',
29+
'user.subscription_tier': 'premium'
30+
}
31+
)
32+
```

0 commit comments

Comments
 (0)