---
title: Troubleshoot missing data for AWS Lambda with OpenTelemetry
source: https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/opentelemetry/lambda-opentelemetry-troubleshooting
---

## Problem: CloudWatch metrics or invocations not appearing [#missing-cloudwatch-metrics]

After instrumenting your AWS Lambda function with OpenTelemetry and invoking it, the **CloudWatch metrics** section or **Invocations** tab doesn't appear in the New Relic UI.

## Solution [#solution-cloudwatch]

New Relic requires the following OpenTelemetry resource attributes to correctly identify and display your Lambda function in the UI:

| Attribute   | Description                         | Example value                                                       |
| ----------- | ----------------------------------- | ------------------------------------------------------------------- |
| `faas.name` | The name of the Lambda function     | `my-lambda-function`                                                |
| `faas.id`   | The full ARN of the Lambda function | `arn:aws:lambda:us-east-1:123456789012:function:my-lambda-function` |

If these attributes are missing, set them using the `OTEL_RESOURCE_ATTRIBUTES` environment variable.

**SAM template:**

```yaml
yourFunctionHere:
  Type: AWS::Serverless::Function
  Properties:
    # ...
    Environment:
      Variables:
        OTEL_RESOURCE_ATTRIBUTES: "faas.name=my-lambda-function,faas.id=arn:aws:lambda:us-east-1:123456789012:function:my-lambda-function"
```

> #### ⚠️ IMPORTANT
>
> Replace `my-lambda-function` and the ARN with your actual function name and ARN. The ARN must match the value shown in the AWS Lambda console exactly.

**AWS Console:**

1.  Open your function in the [Lambda Console](https://console.aws.amazon.com/lambda).
2.  Choose **Configuration**, then **Environment variables**.
3.  Choose **Edit**, then **Add environment variable**.
4.  Set **Key** to `OTEL_RESOURCE_ATTRIBUTES` and **Value** to `faas.name=my-lambda-function,faas.id=arn:aws:lambda:us-east-1:123456789012:function:my-lambda-function`.
5.  Choose **Save**.

If you already have other resource attributes set, append the new values as comma-separated key-value pairs:

```
OTEL_RESOURCE_ATTRIBUTES=service.name=my-service,faas.name=my-lambda-function,faas.id=arn:aws:lambda:us-east-1:123456789012:function:my-lambda-function
```

## Problem: Request ID missing on traces [#missing-request-id]

Your Lambda function traces appear in New Relic, but the AWS request ID isn't visible on the root span, making it difficult to correlate traces with CloudWatch Logs entries.

## Solution [#solution-request-id]

Set the `faas.execution` attribute on the root span inside your handler. The OpenTelemetry semantic conventions define this attribute as the cloud provider's request or invocation ID.

**Python:**

```python
from opentelemetry import trace

def handler(event, context):
    span = trace.get_current_span()
    span.set_attribute("faas.execution", context.aws_request_id)

    # Your handler logic here
    return {"statusCode": 200, "body": "OK"}
```

**Node.js:**

```js
const { trace } = require('@opentelemetry/api');

exports.handler = async (event, context) => {
  const span = trace.getActiveSpan();
  if (span) {
    span.setAttribute('faas.execution', context.awsRequestId);
  }

  // Your handler logic here
  return { statusCode: 200, body: 'OK' };
};
```

**Java:**

```java
import io.opentelemetry.api.trace.Span;

public class Handler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
    @Override
    public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent event, Context context) {
        Span span = Span.current();
        span.setAttribute("faas.execution", context.getAwsRequestId());

        // Your handler logic here
        return new APIGatewayProxyResponseEvent().withStatusCode(200);
    }
}
```

> #### 💡 TIP
>
> New Relic surfaces `faas.execution` as **Request ID** in the trace details panel, making it easy to find the corresponding CloudWatch Logs entry for any invocation.

## More information [#more-info]

For more information, see the following:

-   [Trace your Java Lambda functions with OpenTelemetry](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/opentelemetry/lambda-opentelemetry-java)
-   [Trace your .NET Lambda functions with OpenTelemetry](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/opentelemetry/lambda-opentelemetry-dotnet)
-   [New Relic OpenTelemetry quick start](https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/opentelemetry-quick-start)
