Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def overload(x: "T") -> "T":
"last_event_id",
"new_scope",
"push_scope",
"remove_attribute",
"set_attribute",
"set_context",
"set_extra",
"set_level",
Expand Down Expand Up @@ -287,6 +289,28 @@ def push_scope( # noqa: F811
return _ScopeManager()


@scopemethod
def set_attribute(key: str, value: "Any") -> None:
"""
Set an attribute.

Any attributes-based telemetry (logs, metrics) captured in this scope will
include this attribute.
"""
return get_isolation_scope().set_attribute(key, value)


@scopemethod
def remove_attribute(key: str) -> None:
"""
Remove an attribute.

If the attribute doesn't exist, this function will not have any effect and
it will also not raise an exception.
"""
return get_isolation_scope().remove_attribute(key)


@scopemethod
def set_tag(key: str, value: "Any") -> None:
return get_isolation_scope().set_tag(key, value)
Expand Down
Loading