Skip to content

Commit 6c4b510

Browse files
committed
Add documentation about cold startup with auto-instrumentation
Signed-off-by: Raphael Silva <[email protected]>
1 parent 2fbc80a commit 6c4b510

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/docs/getting-started/lambda/lambda-java-auto-instr.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ Tips:
4747
* By default, the layer is configured to export traces to AWS X-Ray. Make sure your Lambda role has the required AWS X-Ray permissions.
4848
For more on AWS X-Ray permissions for AWS Lambda, see the [AWS Lambda documentation](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html#services-xray-permissions).
4949

50+
* By default, the ADOT Java Agent in the Layer will try to auto-instrument all the code in your application. This can have a negative impact on the Lambda cold startup time.
51+
52+
We recommend that you only enable auto instrumentation for the libraries/frameworks that are used by your application.
53+
54+
To enable only specific instrumentation you can use the following environment variables:
55+
* `OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED` - When set to `false`, disables auto-instrumentation in the Layer, requiring each instrumentation to be enabled individually.
56+
* `OTEL_INSTRUMENTATION_[NAME]_ENABLED` - Set to `true` to enable auto-instrumentation for a specific library or framework. `[NAME]` should be replaced by the instrumentation that you want to enable. The full list of available instrumentation can be found in [this link](https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/#suppressing-specific-agent-instrumentation).
57+
58+
For example, to only enable auto-instrumentation for Lambda and the AWS SDK, you would have to set the following environment variables:
59+
```bash
60+
OTEL_INSTRUMENTATION_COMMON_DEFAULT_ENABLED=false
61+
OTEL_INSTRUMENTATION_AWS_LAMBDA_ENABLED=true
62+
OTEL_INSTRUMENTATION_AWS_SDK_ENABLED=true
63+
```
64+
5065
### Metric Instrumentation in your Lambda Function
5166

5267
Metric auto instrumentation is supported in OpenTelemetry. You would have to instrument your code in your Lambda application in order to generate application metrics. We will be using the [OpenTelemetry Java Metrics API](https://github.com/open-telemetry/opentelemetry-java/tree/main/api/metrics/src/main/java/io/opentelemetry/api/metrics) to define our metrics. You can define your metric types in a MetricGenerator.java file. To enable exporting metrics for use with backends like Amazon Managed Prometheus, set the environment variable `OTEL_METRICS_EXPORTER=otlp`.

0 commit comments

Comments
 (0)