Official Sentry SDK for various serverless solutions including AWS Lambda and Google Cloud Functions
—
Automatic tracking and tracing of AWS SDK service requests with detailed operation context, performance monitoring, and error capture for AWS service calls within serverless functions.
Automatically instrument AWS SDK calls to provide visibility into service requests made from your serverless functions.
/**
* Integration for tracking AWS service requests
* @param options - Configuration options for the integration
* @returns Integration instance for AWS services monitoring
*/
function awsServicesIntegration(options?: { optional?: boolean }): Integration;
/**
* @deprecated Use awsServicesIntegration() instead
* AWS Service Request Tracking integration class
*/
class AWSServices implements Integration {
static id: string;
name: string;
setupOnce(): void;
setup(client: Client): void;
}Usage Examples:
import { AWSLambda, awsServicesIntegration } from "@sentry/serverless";
// Automatic inclusion (default behavior)
AWSLambda.init({
dsn: "your-dsn-here",
// AWS services integration is included by default
});
// Manual integration setup
AWSLambda.init({
dsn: "your-dsn-here",
integrations: [
awsServicesIntegration({ optional: true }),
// other integrations...
]
});
// Optional integration (won't fail if AWS SDK is missing)
AWSLambda.init({
dsn: "your-dsn-here",
integrations: [
awsServicesIntegration({ optional: true })
]
});The AWS services integration automatically instruments AWS SDK requests to create spans for service calls:
The integration provides enhanced descriptions for specific AWS services:
For each AWS service request, the integration creates:
aws.{service}.{operation} {parameters}http.client// S3 Operations
await s3.getObject({ Bucket: 'my-bucket', Key: 'file.txt' }).promise();
// Creates span: "aws.s3.getObject my-bucket"
await s3.putObject({ Bucket: 'uploads', Key: 'new-file.txt', Body: data }).promise();
// Creates span: "aws.s3.putObject uploads"
// Lambda Operations
await lambda.invoke({ FunctionName: 'my-function', Payload: JSON.stringify(payload) }).promise();
// Creates span: "aws.lambda.invoke my-function"
// DynamoDB Operations
await dynamodb.query({ TableName: 'Users', KeyConditionExpression: 'id = :id' }).promise();
// Creates span: "aws.dynamodb.query"
// SQS Operations
await sqs.sendMessage({ QueueUrl: queueUrl, MessageBody: message }).promise();
// Creates span: "aws.sqs.sendMessage"The integration hooks into the AWS SDK's request lifecycle:
The integration provides detailed performance insights:
// Mark as optional to prevent failures if AWS SDK is not available
awsServicesIntegration({ optional: true })When marked as optional:
import { AWSLambda } from "@sentry/serverless";
// Exclude AWS services integration
AWSLambda.init({
dsn: "your-dsn-here",
integrations: [] // Empty array excludes default integrations
});
// Include only specific integrations
AWSLambda.init({
dsn: "your-dsn-here",
integrations: [
// Include other integrations but exclude AWS services
// awsServicesIntegration(), // Commented out to disable
]
});import { AWSLambda } from "@sentry/serverless";
import AWS from "aws-sdk";
// Initialize with AWS services integration (included by default)
AWSLambda.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1.0,
});
const s3 = new AWS.S3();
const lambda = new AWS.Lambda();
exports.handler = AWSLambda.wrapHandler(async (event, context) => {
// These operations will be automatically traced
try {
// S3 operation - creates span "aws.s3.getObject my-data-bucket"
const s3Object = await s3.getObject({
Bucket: 'my-data-bucket',
Key: event.key
}).promise();
// Lambda invocation - creates span "aws.lambda.invoke data-processor"
const result = await lambda.invoke({
FunctionName: 'data-processor',
Payload: JSON.stringify({ data: s3Object.Body })
}).promise();
return {
statusCode: 200,
body: JSON.stringify({ success: true, result: result.Payload })
};
} catch (error) {
// Error context includes AWS operation details
throw error;
}
});AWS service spans are automatically connected to the parent Lambda function span:
Lambda Function Span (aws.lambda.invoke)
├── S3 GetObject Span (aws.s3.getObject my-bucket)
├── DynamoDB Query Span (aws.dynamodb.query)
└── Lambda Invoke Span (aws.lambda.invoke processor-function)This provides complete visibility into the service dependency chain within your serverless functions.
The AWS services integration provides comprehensive observability for AWS service usage within your serverless applications, enabling you to identify performance bottlenecks, track service dependencies, and monitor the health of your cloud infrastructure interactions.
Install with Tessl CLI
npx tessl i tessl/npm-sentry--serverless