You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/python.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@ import taskbadger
20
20
taskbadger.init(
21
21
organization_slug="my-org",
22
22
project_slug="my-project",
23
-
token="***"
23
+
token="***",
24
+
tags={"environment": "production"},
24
25
)
25
26
```
26
27
@@ -29,6 +30,9 @@ Details about these configuration parameters can be found [here](basics.md#organ
29
30
If you attempt to use the SDK without configuring it you will get an error. To avoid this you can use the
30
31
[safe functions](#safe-functions) which will log any errors to the `taskbadger` logger.
31
32
33
+
!!! tip
34
+
[Tags](data_model.md#tags) provided here will be applied to all tasks created using the SDK. If you need to add tags to individual tasks you can do so using the create and update methods or the `task.add_tag` method. Tags added manually will override the global tags.
35
+
32
36
## Usage
33
37
34
38
The SDK provides a [Task](#taskbadger.Task) class which offers a convenient interface to the API.
@@ -49,7 +53,8 @@ task = Task.create(
49
53
trigger="*/10%,success,error",
50
54
integration=EmailIntegration(to="me@example.com")
51
55
)
52
-
]
56
+
],
57
+
tags={"tenant": "acme"}
53
58
)
54
59
```
55
60
@@ -82,16 +87,15 @@ session management is handled automatically within the body of the function or C
82
87
83
88
### Scope
84
89
85
-
The SDK provides the `taskbadger.current_scope` context manager which can be used to set custom data
86
-
for the duration of the context. The content of the scope will be merged with any custom task data
87
-
passed directly to any of the other API methods.
90
+
The SDK provides the `taskbadger.current_scope` context manager which can be used to set custom data and modify tags for the duration of the context. The content of the scope will be merged with any custom task data passed directly to any of the other API methods.
88
91
89
92
```python
90
93
import socket
91
94
import taskbadger
92
95
93
96
with taskbadger.current_scope() as scope:
94
97
scope["hostname"] = socket.gethostname()
98
+
scope.tag({"tenant": "acme"})
95
99
```
96
100
97
101
A common use case for this is to add request scoped context in frameworks like Django or Flask using a custom
0 commit comments