Skip to content

Commit 181626b

Browse files
authored
docs: Add set_attribute example to changelog (#5578)
### Description <!-- What changed and why? --> #### Issues <!-- * resolves: #1234 * resolves: LIN-1234 --> #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 4f16a9e commit 181626b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@
66

77
- Add `set_attribute`, `remove_attribute` to global API by @sentrivana in [#5555](https://github.com/getsentry/sentry-python/pull/5555)
88

9+
You can now set and unset attributes on logs and metrics via top-level API. Think of it as `sentry_sdk.set_tag()` for attribute-based telemetry. Other event types (transactions, spans, errors) will be unaffected.
10+
11+
```python
12+
import sentry_sdk
13+
14+
sentry_sdk.init(...)
15+
16+
sentry_sdk.set_attribute("my.attribute", "my value")
17+
18+
# This metric will have "my.attribute" set
19+
sentry_sdk.metrics.count("counter", 1)
20+
21+
# Remove the attribute
22+
sentry_sdk.remove_attribute("my.attribute")
23+
24+
# This log will not have "my.attribute" set
25+
sentry_sdk.logger.info("An info log")
26+
```
27+
928
### Bug Fixes 🐛
1029

1130
#### Openai

0 commit comments

Comments
 (0)