---
title: Lambda Web Adapter
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > Serverless > Serverless Monitoring for AWS Lambda > Lambda Web Adapter
---

# Lambda Web Adapter

{% callout %}
##### Join the Preview!

Lambda Web Adapter is in Preview.
{% /callout %}

## Overview{% #overview %}

The AWS [Lambda Web Adapter](https://github.com/awslabs/aws-lambda-web-adapter) is a framework that allows developers to run web applications on AWS Lambda.

Datadog supports Lambda Web Adapter for Node.js and Python runtimes, therefore providing you a solution to monitoring your web applications running on AWS Lambda.

## How to integrate Datadog{% #how-to-integrate-datadog %}

The Lambda Web Adapter can run Lambda functions that are packaged as docker images or as Zip files. The following steps are required for instrumenting the Lambda Web Adapter with Datadog for both formats:

1. Add the Lambda Web Adapter and Datadog extension
1. Set the required Datadog environment variables
1. Ignore tracing for the readiness endpoint (*\*required only when using Datadog tracing*)

#### 1. Add the Lambda Web Adapter and Datadog extension

{% tab title="Container deployment" %}
This configuration requires Datadog Lambda extension `v77+` and Lambda Web Adapter `v0.9.1+`. See a sample of the container deployment configuration on [Github](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/datadog).

```Dockerfile
COPY --from=public.ecr.aws/datadog/lambda-extension:77 /opt/. /opt/
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.9.1 /lambda-adapter /opt/extensions/lambda-adapter
```

{% /tab %}

{% tab title="Zip deployment" %}
This requires Datadog Lambda extension `v77+` and `v25+` or later for Lambda Web Adapter. See a sample of the Zip deployment configuration on [Github](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/datadog).

**for x86**

```shell
arn:aws:lambda:${AWS::Region}:464622532012:layer:Datadog-Extension:77
arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:25
```

**for ARM**

```shell
arn:aws:lambda:${AWS::Region}:464622532012:layer:Datadog-Extension-ARM:77
arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerArm64:25
```

{% /tab %}

#### 2. Set the required Datadog environment variables

{% tab title="Container deployment" %}
Since there is no explicit shutdown system for Lambda, traces must be flushed as soon as possible so they are not lost when the Lambda runtime environment is "frozen".

The transparent tracing requires the Datadog extension to also proxy requests before the Lambda Web Adapter, so the `AWS_LWA_LAMBDA_RUNTIME_API_PROXY` must be set to allow that. The port can be set with any available port.

```bash
DD_TRACE_PARTIAL_FLUSH_MIN_SPANS=1
DD_TRACE_PARTIAL_FLUSH_ENABLED=false

AWS_LWA_LAMBDA_RUNTIME_API_PROXY=127.0.0.1:9002

DD_API_KEY=$YOUR_API_KEY
DD_SERVICE=$YOUR_SERVICE_NAME
```

{% /tab %}

{% tab title="Zip deployment" %}
Since there is no explicit shutdown system for Lambda, traces must be flushed as soon as possible so they are not lost when the Lambda runtime environment is "frozen".

The transparent tracing requires the Datadog extension to also proxy requests before the Lambda Web Adapter, so the `AWS_LWA_LAMBDA_RUNTIME_API_PROXY` must be set to allow that. The port can be set with any available port.

```bash
DD_TRACE_PARTIAL_FLUSH_MIN_SPANS=1
DD_TRACE_PARTIAL_FLUSH_ENABLED=false

AWS_LWA_LAMBDA_RUNTIME_API_PROXY=127.0.0.1:9002

AWS_LAMBDA_EXEC_WRAPPER=/opt/bootstrap

DD_API_KEY=$YOUR_API_KEY
DD_SERVICE=$YOUR_SERVICE_NAME
```

{% /tab %}

#### 3. Ignore tracing for the readiness endpoint

\**This step is required only when using Datadog tracing*.

{% tab title="Container deployment" %}
Since the Lambda Web Adapter sends readiness check requests once it is loaded, the Datadog extension must not link them to the request that triggered the Lambda function.

The configuration differs depending on the runtime. Assuming the readiness endpoint is the default (`GET` at `/`):

**Node.js**

```js
const tracer = require('dd-trace').init();
tracer.use('http', {
    blocklist: ['/']
});
```

**Python**

```python
import ddtrace

ddtrace.patch_all()
from ddtrace.trace import tracer, TraceFilter
...
class IgnoreEndpointFilter(TraceFilter):
    def __init__(self, pattern, method):
        self.pattern = re.compile(pattern)
        self.method = method

    def process_trace(self, trace):
        for span in trace:
            url = span.get_tag("http.url")
            if (
                url is not None
                and self.pattern.match(url)
                and self.method == span.get_tag("http.method")
            ):
                return None
        return trace


tracer.configure(
    trace_processors=[IgnoreEndpointFilter(r"http://127.0.0.1:8080/", "GET")]
)
```

{% /tab %}

{% tab title="Zip deployment" %}
Since the Lambda Web Adapter sends readiness check requests once it is loaded, the Datadog extension must not link them to the request that triggered the Lambda function.

The configuration differs depending on the runtime. Assuming the readiness endpoint is the default (`GET` at `/`):

**NodeJs**

```js
const tracer = require('dd-trace').init();
tracer.use('http', {
    blocklist: ['/']
});
```

**Python**

```python
import ddtrace

ddtrace.patch_all()
from ddtrace.trace import tracer, TraceFilter
...
class IgnoreEndpointFilter(TraceFilter):
    def __init__(self, pattern, method):
        self.pattern = re.compile(pattern)
        self.method = method

    def process_trace(self, trace):
        for span in trace:
            url = span.get_tag("http.url")
            if (
                url is not None
                and self.pattern.match(url)
                and self.method == span.get_tag("http.method")
            ):
                return None
        return trace


tracer.configure(
    trace_processors=[IgnoreEndpointFilter(r"http://127.0.0.1:8080/", "GET")]
)
```

{% /tab %}



## Further Reading{% #further-reading %}

- [Configure Serverless Monitoring](https://docs.datadoghq.com/serverless/configuration/)
- [AWS Lambda Integration](https://docs.datadoghq.com/integrations/amazon_lambda/)
