Below we shall see the steps for AWS Java Serverless Auto-Instrumentation Monitoring in Atatus using OTel Lambda Layer.
To incorporate the OpenTelemetry Lambda layer into your Java functions, include the following layers in your functions.
arn:aws:lambda:<region>:184161586896:layer:opentelemetry-javaagent-<version> arn:aws:lambda:<region>:184161586896:layer:opentelemetry-collector-<amd64|arm64>-<version> # example layer config # arn:aws:lambda:us-east-1:184161586896:layer:opentelemetry-javaagent-0_5_0:1 # arn:aws:lambda:us-east-1:184161586896:layer:opentelemetry-collector-amd64-0_6_0:1
region - set your region version - use version from latest Otel OTel Lambda release amd64|arm64 - choose architecture
Setup collector using the below steps
Establish an environment variable named
OPENTELEMETRY_COLLECTOR_CONFIG_FILE=/var/task/atatus-collector.yaml
within your Lambda function. This action instructs the extension on the location of the collector configuration.You can optionally set the tags
(env, service, and version - Optional)
in the processors resource attributes. This helps with organizing all functions within a unified service, making filtering easier.Please create a configuration file named as
atatus-collector.yaml
below:a. Place
atatus-collector.yaml
in thesrc/main/resources
directory.copyreceivers: otlp: protocols: http: processors: resource: attributes: - key: env value: "<YOUR_ENV>" action: upsert - key: service value: "<YOUR_SERVICE_NAME>" action: upsert - key: version value: "<YOUR_VERSION>" action: upsert exporters: otlphttp: endpoint: "https://otel-rx.atatus.com:443" headers: api-key: "YOUR_ATATUS_API_KEY" service: pipelines: traces: receivers: [otlp] processors: [resource] exporters: [otlphttp] metrics: receivers: [otlp] processors: [resource] exporters: [otlphttp]
b. Configure the lambda function by setting the environment variables in the corresponding Serverless Environment.
copyAWS_LAMBDA_EXEC_WRAPPER: /opt/otel-handler OPENTELEMETRY_COLLECTOR_CONFIG_FILE: /var/task/atatus_collector.yaml OTEL_PROPAGATORS: tracecontext OTEL_TRACES_SAMPLER: always_on OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED: false OTEL_INSTRUMENTATION_AWS_LAMBDA_ENABLED: true OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
3. In Atatus Dashboard navigate to Settings tab, then click on Account Settings. From there, go to API Keys. You can either generate a new API key or copy an existing one. After obtaining the API key, you'll need to set it in the atatus-collector.yaml
file under the exporter otlphttp
header.
4. Add resource configuration in pom.xml
file
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>atatus_collector.yaml</include>
</includes>
</resource>
</resources>
</build>
5. Build your java application and then deploy your Lambda function.