You only need to add the Node.js Lambda layer — no separate collector layer is required. Trace0 handles ingestion directly.

1. Add the OpenTelemetry Lambda Layer

Find the latest layer-nodejs ARN for your AWS region from the opentelemetry-lambda releases page. Add the layer ARN to your function.

2. Set Environment Variables

VariableValue
AWS_LAMBDA_EXEC_WRAPPER/opt/otel-handler
OTEL_EXPORTER_OTLP_ENDPOINThttps://app.trace0hq.com/api
OTEL_EXPORTER_OTLP_HEADERSX-API-KEY=YOUR_TRACE0_ENV_API_KEY

3. Set HTTP request spans

For lambdas triggered via API Gateway, the HTTP request and response attributes are not set automatically on the lambda invocation span by the OTel Lambda auto-instrumentation. Therefore, they need to be set manually in your lambda code handler.
import { trace, SpanStatusCode } from '@opentelemetry/api';

export const handler = async (
  event: APIGatewayProxyEvent,
  context: Context
): Promise<APIGatewayProxyResult> => {
  const { httpMethod, path, requestContext } = event;

  //Set the http request method and route on the parent span.
  const span = trace.getActiveSpan();
  span?.setAttributes({
    'http.request.method': event.httpMethod,
    'http.route': event.path
  });

  const result = await processEvent(event)

  // Set the HTTP response code and mark the span as failed for 4xx/5xx responses.
  span?.setAttributes({ 'http.response.status_code': result.statusCode });
  span?.setStatus({ code: result.statusCode < 400 ? SpanStatusCode.OK : SpanStatusCode.ERROR });

  return result;
}

4. Add Trace0 logger

To correlate logs with traces in Trace0, the @trace0/lambda-otel-logger library must be installed in your Lambda function. This is necessary because the OpenTelemetry JavaScript library does not yet automatically bridge console output into the OTel Logs pipeline. First, install the library:
"dependencies": {
    "@opentelemetry/api": "^1.9.1",
    "@trace0/lambda-otel-logger": "^1.0.3"
}
Then add as the first import in your Lambda handler entry point, and call flush() at the end of every invocation:
import '@trace0/lambda-otel-logger';
import { flush } from '@trace0/lambda-otel-logger';

export const handler = async (event: APIGatewayProxyEvent, context: Context) => {
  try {
    console.log(`Processing request with requestId: ${context.awsRequestId}`);
    return await processEvent(event, context);
  } finally {
    await flush(); // always flush before Lambda freezes
  }
};
The library will now automatically capture all logging output, inject OTel trace context (traceId, spanId), and export the logs to the Trace0 ingest endpoint.

5. Deploy service

Deploy your service and watch traces, metrics, and logs appear in the Trace0 dashboard within seconds.

Example service

See our Node.js Lambda example app for a working service you can deploy to your AWS account.