Trace Your AWS Lambda Function In Node.js – Automatically

December 3, 2019

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”.

Select layers from configuration

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.

Select your configuration

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 for customers running Instana’s US unit or “” 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.

Configure environment keys

In the end, hit “Save” and your done.

Save the configuration

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.

Play with Instana’s APM Observability Sandbox

Developer, Product, Thought Leadership
In my last blog post, I talked about the history and rapid adoption of the OpenTelemetry project. Today we discuss the progress made in terms of end-to-end compatibility between distributed tracing with...
Announcement, Developer, Product, Thought Leadership
AWS Lambda supports development and deployment of functions in a variety of programming languages including Node.js, Go, Java, and Python. Instana has previously announced automated tracing of AWS Lambda Functions for Node.js and...
Announcement, Developer, Product, Thought Leadership
Instana has previously announced automated tracing of AWS Lambda applications in Node.js and Python. We are extending our best-in-class distributed tracing to include AWS Lambda functions written in Java and Go. The...

Start your FREE TRIAL today!

Instana, an IBM company, provides an Enterprise Observability Platform with automated application monitoring capabilities to businesses operating complex, modern, cloud-native applications no matter where they reside – on-premises or in public and private clouds, including mobile devices or IBM Z.

Control hybrid modern applications with Instana’s AI-powered discovery of deep contextual dependencies inside hybrid applications. Instana also gives visibility into development pipelines to help enable closed-loop DevOps automation.

This provides actionable feedback needed for clients as they to optimize application performance, enable innovation and mitigate risk, helping Dev+Ops add value and efficiency to software delivery pipelines while meeting their service and business level objectives.

For further information, please visit