Configuring Traces for Node.js SDK
To disable an integration, you can use the
thundra_agent_trace_integrations_disable
environment variable. Set this environment variable's value to a string that includes a comma (,) in order to separate integration names.For example, to disable
redis
and the http
integration, you need to use the following environment variable and value: thundra_agent_trace_integrations_disable: redis,http
You can mask sent SQS messages on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_trace_integrations_aws_sqs_message_mask: true
You can mask sent SNS messages on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_trace_integrations_aws_sns_message_mask: true
You can mask sent DynamoDB statements on the client’s side, which calls AWS SDK by setting the following environment variable:
thundra_agent_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_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_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_trace_integrations_aws_athena_statement_mask: true
Tracing AWS SDK calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
aws
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here: thundra_agent_trace_integrations_disable: aws
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_trace_integrations_redis_command_mask: true
Tracing Redis calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
redis
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: redis
You can mask IORedis calls by setting the following environment variable:
thundra_agent_trace_integrations_redis_command_mask: true
Tracing IORedis calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
ioredis
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: ioredis
You can mask the http request body on the client’s side by setting the following environment variable:
thundra_agent_trace_integrations_http_body_mask: true
Tracing HTTP/HTTPS calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
http
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: http
Tracing 4XX/5XX errors on http/https response is enabled by default, but also be disabled through configuration by adding following environment variables.
thundra_agent_trace_integrations_http_error_on4xx_disable: true #for 4XX errors
thundra_agent_trace_integrations_http_error_on5xx_disable: true #for 5XX errors
You can mask MySQL/MySQL2 queries on the client’s side by setting the following environment variable:
thundra_agent_trace_integrations_rdb_statement_mask: true
Tracing MySQL/MySQL2 calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the mysql or
mysql2
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: mysql,mysql2
You can mask PostgreSQL queries on the client’s side by setting the following environment variable:
thundra_agent_trace_integrations_rdb_statement_mask: true
Tracing PostgreSQL calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
pg
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: pg
You can mask the Elasticsearch body on the client’s side by setting the following environment variable:
thundra_agent_trace_integrations_elasticsearch_body_mask: true
Tracing Elasticsearch calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
es
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: es
You can mask MongoDB commands on the client’s side by setting the following environment variable:
thundra_agent_trace_integrations_mongodb_command_mask: true
Tracing MongoDB calls is enabled by default, but can also be disabled through configuration if needed. You just need to add the
mongodb
value to the array string for the thundra_agent_trace_integrations_disable
environment variable as shown here:thundra_agent_trace_integrations_disable: mongodb
Requests can be masked by setting the maskRequest function into traceConfig.
const thundra = require("@thundra/core");
const config = {
traceConfig: {
maskRequest: (event) => {
// Mask the event
event.password = "???";
return event;
}
}
};
exports.handler = thundra(config)((event, context, callback) => {
callback(null, {
msg: 'hello world'
});
});
Responses can be masked by setting the maskResponse function into traceConfig.
const thundra = require("@thundra/core");
const config = {
traceConfig: {
maskResponse: (response) => {
// Mask the response
response.msg = "???";
return response;
}
}
};
exports.handler = thundra(config)((event, context, callback) => {
callback(null, {
msg: 'hello world'
});
});
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 response set the
thundra_agent_lambda_trace_response_skip
environment variable to true
Configuration via Environment Variable
thundra_agent_lambda_trace_response_skip: true
Disabling trace plugin programatically
const thundra = require("@thundra/core")({
traceConfig: {
enabled: false,
},
});
Configuration of Trace Plugin via Environment Variables
thundra_agent_trace_disable: true
const { PubSub } = require('@google-cloud/pubsub');
const projectId = 'your_google_cloud_project_id';
const topicName = 'your_google_cloud_pubsub_topic';
const pubsub = new PubSub({ projectId });
/*
* if topic allready exists
* const topic = await pubsub.topic(topicName)
**/
const topic = await pubsub.createTopic(topicName);
const date = new Date().toString();
const dataBuffer = Buffer.from(JSON.stringify({date}));
const result = await topic.publishMessage({ data: dataBuffer });
Subscription
Asynchronous Pull
const thundra = require("@thundra/core");
thundra.init();
const { PubSub, Subscription } = require('@google-cloud/pubsub');
const projectId = 'your_google_cloud_project_id';
const topicName = 'your_google_cloud_pubsub_topic';
const subscriptionName = 'your_google_cloud_pubsup_subscription_name';
const pubsub = new PubSub({ projectId });
(async() => {
/*
* if subscription allready exists
* const subscription = pubsub.subscription(subscriptionName);
**/
const [subscription] = await pubsub.topic(topicName).createSubscription(subscriptionName);
const messageHandler = message => {
try {
...
message.ack();
} catch (err) {
...
message.nack();
}
};
subscription.on(`message`, messageHandler);
})().catch(error => console.log(error));
Synchronous Pull
const { v1 } = require('@google-cloud/pubsub');
const subClient = new v1.SubscriberClient();
const projectId = 'your_google_cloud_project_id';
const subscriptionName = 'your_google_cloud_pubsup_subscription_name';
const formattedSubscription = subClient.subscriptionPath(
projectId,
subscriptionName
);
const request = {
subscription: formattedSubscription,
maxMessages: 10,
};
...
const result = await subClient.pull(request);
const [response] = result;
const ackIds = [];
for (const message of response.receivedMessages) {
...
ackIds.push(message.ackId);
}
if (ackIds.length !== 0) {
const ackRequest = {
subscription: formattedSubscription,
ackIds: ackIds,
};
await subClient.acknowledge(ackRequest);
}
...
Last modified 1yr ago