Building services and functions in AWS Lambda is a fun experience and provides us with quick results, especially during, but not limited to, prototyping.
But combining applications from multiple AWS Lambda services means, we need to trace requests through the different functions, working together to respond.
The generally accepted and AWS way would be to use X-Ray. This, however, comes at an additional cost, as X-Ray is paid per traced call. Depending on the amount of traffic being pushed through the functions, a non-trivial cost-factor. Especially since functions are supposed to be small and fast, so you probably end up having rather more than less.
On the other hand, AWS X-Ray is limited to tracing of services being provided by or in AWS. That said, mixed environments are not supported. Neither way. X-Ray keeps you in the walled garden of AWS.
Tracing, The Cool Way; Automatic
The important point to Distributed Tracing is twofold. It has to support multiple services, frameworks, and environments to trace through all of your systems. End to end.
But there’s another important bit, it needs to be automatic. Imagine a world where you’re moving towards Serverless to get rid of all the infrastructure you’d have to care about, but add monitoring aspects to your codebase. Just take something out, just to put something else in, doesn’t sound too meaningful.
Instana AutoTrace and AWS Lambda
That said, we’re happy to announce that Instana’s AutoTrace™ technology now supports tracing AWS Lambda functions. This includes Node.js version 10.x and later, as well as all the supported Node.js libraries and frameworks from our Node.js collector, as well as the fully automatic instrumentation of your service / function. No code changes required.
Use Instana with all your services, applications and databases, no matter where and how they run. Trace your requests into AWS Lambda functions and out into services running on-prem, into our cloud providers or other SaaS offerings. Instana seamlessly captures all the necessary tracing information and delivers the correlated call information the way we love; simple, automatic and with such a low delay, that you even forget it exists.
Getting Started with Instana AutoTrace for AWS Lambda
To support AWS Lambda Functions, Instana uses a Lambda Layer. The layer provides all the parts of Instana to run your Function, instrument it on-the-fly and deliver your traces to the Instana backend.
To add the Instana layer, open up the configuration page of your function and click on “Add a layer”.
In the popup that opens, select “Provide a layer version ARN” and provide the ARN corresponding to your AWS region. For example the EU-Central-1 region is: arn:aws:lambda:eu-central-1:410797082306:layer:instana:15. A full list of all ARNs is available in the documentation.
If your Function’s handler is different from the default index.handler, you should note it down, as you’ll need it in the next configuration step. Otherwise replace the handler’s value with instana-aws-lambda-auto-wrap.handler to enable the automatic instrumentation and tracing.
In the last step you set up some environment variables.
The first two are required to make sure, the AWS Lambda integration can talk to the backend.
Set INSTANA_AGENT_KEY to the agent key you find in your Instana dashboard. Afterwards set INSTANA_ENDPOINT_URL to either https://serverless-us-west-2.instana.io/ for customers running Instana’s US unit or “https://serverless-eu-west-1.instana.io/” for customers in the EU unit.
In case you noted down an non-default handler name before, also set the LAMBDA_HANDLER environment variable to the name of your handler.
In the end, hit “Save” and your done.
Further methods to update your AWS Lambda Functions, like using the CLI are described in the documentation.
Test Instana Now
If you still miss your Instana account, you’ll be happy to hear that you can sign up for a 14 days trial right away. Your account and your Agent Key will be ready in seconds.
With your account you can directly start monitoring AWS Lambda Functions, but you’re not limited to that. Instana already supports more than 100 technologies and counting.