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

1. Add the OpenTelemetry Lambda Layer

Find the latest layer-javaagent ARN for your AWS region from the opentelemetry-lambda releases page. Add the JavaAgent layer ARN to your function — do not add the Collector layer.

2. Set Environment Variables

Add the following environment variables to your Lambda function. Replace YOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.
VariableValue
OTEL_EXPORTER_OTLP_ENDPOINThttps://app.trace0hq.com/api
OTEL_EXPORTER_OTLP_HEADERSX-API-KEY=YOUR_TRACE0_ENV_API_KEY
OTEL_EXPORTER_OTLP_PROTOCOLhttp/protobuf
AWS_LAMBDA_EXEC_WRAPPER/opt/otel-handler

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. First, add the opentelemetry-api dependency to your project:
dependencies {
    implementation("io.opentelemetry:opentelemetry-api:1.61.0")
}
Then add the HTTP request and response attributes to the Lambda invocation span in your handler:
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.StatusCode;

public class Handler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {

    @Override
    public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent event, Context context) {
        String httpMethod = event.getHttpMethod();
        String path = event.getPath();

        // Set the http request method and route on the parent span.
        Span span = Span.current();
        span.setAttribute("http.request.method", httpMethod);
        span.setAttribute("http.route", path);

        APIGatewayProxyResponseEvent result = processRequest(event)

        // Set the HTTP response code and mark the span as failed for 4xx/5xx responses.
        span.setAttribute("http.response.status_code", result.getStatusCode());
        span.setStatus(result.getStatusCode() < 400 ? StatusCode.OK : StatusCode.ERROR);
        
        return result;
    }
}

4. Deploy service

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

Example service

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