Thundra APM
Search…
Deployment Integrations
Powered By GitBook
Tagging in Python SDK
With Thundra's Python agent, you can add custom tags to your invocations or applications, which will help you better filter the data. Invocation tags are added only to the Invocation data type; application tags are global and are automatically added to Invocation, Metric, Trace, Span, and Log data.

Adding Invocation Tags

You can add custom tags to your invocation with methods in the invocation_support module. The functions that can be used in the module are shown below:
InvocationSupport Methods
1
get_tag(key)
2
"""
3
Parameters
4
----------
5
key : string
6
7
Returns
8
-------
9
object
10
"""
11
12
get_tags(key)
13
"""
14
Parameters
15
----------
16
key : string
17
18
Returns
19
-------
20
object
21
"""
22
23
set_tag(key, value)
24
"""
25
Parameters
26
----------
27
key : string
28
value : object
29
"""
30
31
set_many(tags)
32
"""
33
Parameters
34
----------
35
tags : dict
36
"""
37
38
remove_tag(key)
39
"""
40
Parameters
41
----------
42
key : string
43
"""
44
45
set_error(err)
46
"""
47
Parameters
48
----------
49
err : object
50
"""
Copied!
The example below shows how to tag a Lambda invocation (e.g., Lambda Handler) :
Example Lambda Handler
1
from thundra.thundra_agent import Thundra
2
import thundra.plugins.invocation.invocation_support as invocation_support
3
4
thundra = Thundra()
5
6
@thundra
7
def handler(event, context):
8
invocation_support.set_tag("string", "thundra")
9
invocation_support.set_tag("number", 5)
10
invocation_support.set_tag("object", {"id": 5})
11
12
print(invocation_support.get_tags())
Copied!

Adding Application Tags

You can add application tags via environment variables. All application tags which start with thundra_agent_lambda_application_tag_ are parsed by Thundra's Python agent. The text after the thundra_agent_lambda_application_tag_ prefix is used as the key of the tag, and the value of the environment variable becomes the value of the tag. For example, thundra_agent_lambda_application_tag_floatField with the value 12.123 will add an application tag to all data with the key floatField and the value 12.123.
The example below shows how to add application tags with various data types to a Lambda invocation:
Last modified 1yr ago