Configuring Traces for Python SDK
Instrumentation of Chalice applications is completed automatically, so all you need to do is initialize the Thundra agent. Just add the lines shown below to your code:
from thundra.thundra_agent import Thundra
# Pass configuration parameters here or add as environment variables
# to your chalice config.json
thundra = Thundra()
An example is shown below:
from chalice import Chalice
from thundra.thundra_agent import Thundra
# Pass configuration parameters here or add as environment variables
# to your chalice config.json
thundra = Thundra()
app = Chalice(app_name='test')
@app.route('/')
def index():
return {'hello': 'world'}
Chalice deployment is facilitated by setting Thundra’s environment variables in your .chalice/config.json file. Deploying your Chalice application will set these variables and allow Thundra to monitor your functions.
You can add environment variables either globally or for a specific stage, as shown below in your .chalice/config.json:
{
"version": "2.0",
"app_name": "test",
"environment_variables": {
"thundra_apiKey": <your api key here>
},
"stages": {
"dev": {
"environment_variables": {
"thundra_apiKey": <your api key here>
},
"api_gateway_stage": "api"
}
}
}
Tracing route handler functions created with Chalice is enabled by default, but it can also be disabled through configuration if needed. You just need to set the
thundra_agent_lambda_trace_integrations_chalice_disable
environment variable to true
.You can mask SQS messages sent on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_lambda_trace_integrations_aws_sqs_message_mask: true
You can mask SNS messages sent on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_lambda_trace_integrations_aws_sns_message_mask: true
You can mask DynamoDB statements sent on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_lambda_trace_integrations_aws_dynamodb_statement_mask: true
You can mask Lambda invocation payloads on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_lambda_trace_integrations_aws_lambda_payload_mask: true
You can mask a request body on the client’s side by setting the following environment variable:
thundra_agent_lambda_trace_integrations_http_body_mask: true
You can mask Athena statements on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_lambda_trace_integrations_aws_athena_statement_mask: true
Incoming Kinesis records at a triggered Lambda are not traced by default. You can enable sending Kinesis records in a request by setting the following environment variable:
thundra_agent_lambda_trace_kinesis_request_enable: true
Incoming Firehose records at a triggered Lambda are not traced by default. You can enable sending Firehose records in a request by setting the following environment variable:
thundra_agent_lambda_trace_kinesis_request_enable: true
Incoming CloudWatch logs at a triggered Lambda are not traced by default. You can enable sending CloudWatch logs in a request by setting the following environment variable:
thundra_agent_lambda_trace_cloudwatchlog_request_enable: true
Tracing AWS SDK calls is enabled by default, but can also be disabled through configuration if needed. You just need to set
thundra_agent_lambda_trace_integration_aws_disable
to true
.You can see distributed traces of step functions by setting the following environment variable:
thundra_agent_lambda_aws_stepfunctions: true
This variable enables step function trace link injection to the response. This configuration is disabled by default.
You can see distributed traces of appsync by setting the following environment variable:
thundra_agent_lambda_aws_appsync: true
This variable enables appsync trace link injection to the response. This configuration is disabled by default.
You can mask Redis calls by setting the following environment variable:
thundra_agent_lambda_trace_integrations_redis_command_mask: true
Tracing Redis calls is enabled by default, but can also be disabled through configuration if needed. You can disable your integrations via the Lambda environment variable. You just need to set
thundra_agent_lambda_trace_integration_redis_disable
to true
.You can mask an http request body on the client’s side by setting the following environment variable:
thundra_agent_lambda_trace_integrations_http_body_mask: true
Thundra traces HTTP calls by default. However, you may disable it using environment variables. You can set the
thundra_agent_lambda_trace_integrations_http_disable
environment variable to true
for this purpose.Tracing errors by status code on http/https response can be configured by setting
thundra_agent_trace_integrations_http_error_status_code_min
environment variable. Default value for this environment variable is 400, so the responses with 4xx and 5xx status codes are treated as erroneous and the error is traced by default.As an example, if you only want to see the 5xx errors and not 4xx the configuration can be like below:
thundra_agent_trace_integrations_http_error_status_code_min: 500
You can mask MySQL queries on the client’s side by setting the following environment variable:
thundra_agent_lambda_trace_integrations_rdb_statement_mask: true
Tracing MySQL queries is enabled by default, but can also be disabled if needed by setting the
thundra_agent_lambda_trace_integrations_rdb_disable
environment variable to true
.You can mask PostgreSQL queries on the client’s side by setting the following environment variable:
thundra_agent_lambda_trace_integrations_rdb_statement_mask: true
Tracing PostgreSQL queries is enabled by default, but can also be disabled if needed by setting the
thundra_agent_lambda_trace_integrations_rdb_disable
environment variable to true
.You can mask an Elasticsearch body on the client’s side by setting the following environment variable:
thundra_agent_lambda_trace_integrations_elasticsearch_body_mask: true
Tracing Elasticsearch responses is enabled by default, but can also be disabled through configuration if needed. You can disable your integrations via the Lambda environment variable. You just need to set
thundra_agent_lambda_trace_integrations_elasticsearch_disable
to true
.Tracing SQLAlchemy operations is enabled by default, but can also be disabled through configuration if needed. You can disable your integrations via the Lambda environment variable. You just need to set
thundra_agent_lambda_trace_integrations_sqlalchemy_disable
to true
.You can mask MongoDB commands on the client’s side by setting the following environment variable:
thundra_agent_lambda_trace_integrations_mongodb_command_mask: true
Tracing MongoDB operations is enabled by default, but can also be disabled through configuration if needed. You can disable your integrations via the Lambda environment variable. You just need to set
thundra_agent_lambda_trace_integrations_mongodb_disable
to true
.Requests and responses are traced by default, but can be disabled with environment variable configuration.
To disable tracing requests, set the
thundra_agent_lambda_trace_request_skip
environment variable to true
.Configuration via Environment Variable
thundra_agent_lambda_trace_request_skip: true
To disable tracing responses, set the
thundra_agent_lambda_trace_response_skip
environment variable to true
.Configuration via Environment Variable
thundra_agent_lambda_trace_response_skip: true
Programmatic Configuration
thundra = Thundra(api_key=’my_api_key’, disable_trace=True)
Configuration of Trace Plugin via Environment Variables
thundra_apiKey: ${self:custom.thundraApiKey}
thundra_agent_lambda_trace_disable: true
Last modified 1yr ago