Trace support can be used by both Automated and Manual instrumentation, as mentioned in Python's Instrumentation documentation. With Thundra’s Trace Support, coupled with Instrumentation you can view how your Lambda functions send and receive data represented by spans.
Spans through Instrumentation
Without instrumentation, the Thundra console displays a single span depicting the running of the Lambda function.
Configuring Thundra’s Trace Support in the Python agent involves declaring a trace object at the start of your Lambda function. It must be noted that Trace Support is by default enabled when you wrap your function. However, if you would like to configure your Trace Support, along with performing manual instrumentation, then you must get a tracer instance with the command
To activate spans, you must then start a span from the trace instance, and ensure that the parts of the function that you do wish to monitor lie within the scope of the span. This can be done by the
start_active_span method from the tracer object. Moreover, the initialization parameter that should be defined is
operation_name, which indicates the name of the span relevant to the block of the Lambda function that you would like to monitor.
You can find a detailed list of initialization parameters here.
To use Trace Support with automated instrumentation you shall have to import
Traceable from Thundra’s trace plugin as below:
from thundra.plugins.trace.traceable import Traceable
Traceable simplifies the way you can use Trace Support in your Lambda functions as configuring Trace Support now simply involves using the
@Traceable decorator in the start of each function you would like to monitor. Three initialization parameters can be passed depending on what you would like to monitor within your Trace spans. These include: