AWS Lambda
AWS Lambda requires that you wrap your handler function with iudex.iudexAwsLambda.withTracing
.
Install the IUDEX package
npm i iudex
Create a write-only API key 🔑
Click settings in the top left corner of the IUDEX dashboard and create a write-only API key.
Add IUDEX to your code 🚀
- Add this code snippet to the top of your handler file.
import { instrument, iudexAwsLambda } from 'iudex';
const { withTracing } = iudexAwsLambda;
instrument({
serviceName: 'YOUR_SERVICE_NAME', // Highly encouraged
publicWriteOnlyIudexApiKey: 'YOUR_PUBLIC_WRITE_ONLY_KEY', // Only ever commit your WRITE ONLY key
githubUrl: 'GITHUB_URL_TO_YOUR_REPO', // Optional, this sets up code linking
env: 'production', // Optional, development, local, etc
});
// ^ place this as high as possible in your code
- Wrap all lambda functions you want traced with
withTracing
.
export const handler = withTracing(
// Your handler function goes here
);
With API Gateway
If you use AWS API Gateway along with lambdas, instead import iudexAwsApiGateway
and wrap your lambda functions the same way using withTracing
.
import { instrument, iudexAwsApiGateway } from 'iudex';
const { withTracing } = iudexAwsApiGateway;
instrument({
serviceName: 'YOUR_SERVICE_NAME', // Highly encouraged
publicWriteOnlyIudexApiKey: 'YOUR_PUBLIC_WRITE_ONLY_KEY', // Only ever commit your WRITE ONLY key
githubUrl: 'GITHUB_URL_TO_YOUR_REPO', // Optional, this sets up code linking
env: 'production', // Optional, development, local, etc
});
// ^ place this as high as possible in your code
Set up Slack alerts 📣
Click the Slack logo in the top right of the dashboard and follow the prompts.
Note: you must have admin permissions to add apps to your workspace.
Create a log 🪵
Add code to emit a log.
export const handler = withTracing(() => {
// Add this
console.log('Hello IUDEX!', { ctx: { 'iudex.slack_channel_id': 'YOUR_SLACK_CHANNEL_ID' } });
});
Then run your lambda function to emit the log.
Verify 🧐
You should see the log in Slack and in your IUDEX dashboard log view.
Go in-depth 👉
Check out more in-depth guides on how to get the most out of IUDEX for your stack.