AdotLayerVersion Class
An ADOT Lambda layer version that's specific to a lambda layer type and an architecture.
Note: These resolve to the legacy ADOT Lambda layers with an embedded collector. For the recommended optimized layers, use LayerVersion.fromLayerVersionArn() with an AWSOpenTelemetryDistro* layer ARN instead.
Example
ts
import {
AdotLambdaExecWrapper,
AdotLayerVersion,
AdotLambdaLayerJavaScriptSdkVersion,
} from 'aws-cdk-lib/aws-lambda';
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_LATEST,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
adotInstrumentation: {
layerVersion: AdotLayerVersion.fromJavaScriptSdkLayerVersion(AdotLambdaLayerJavaScriptSdkVersion.LATEST),
execWrapper: AdotLambdaExecWrapper.REGULAR_HANDLER,
},
});
python
from aws_cdk.aws_lambda import AdotLambdaExecWrapper, AdotLayerVersion, AdotLambdaLayerJavaScriptSdkVersion
fn = lambda_.Function(self, "MyFunction",
runtime=lambda_.Runtime.NODEJS_LATEST,
handler="index.handler",
code=lambda_.Code.from_inline("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }"),
adot_instrumentation=lambda.AdotInstrumentationConfig(
layer_version=AdotLayerVersion.from_java_script_sdk_layer_version(AdotLambdaLayerJavaScriptSdkVersion.LATEST),
exec_wrapper=AdotLambdaExecWrapper.REGULAR_HANDLER
)
)
java
import software.amazon.awscdk.services.lambda.AdotLambdaExecWrapper;
import software.amazon.awscdk.services.lambda.AdotLayerVersion;
import software.amazon.awscdk.services.lambda.AdotLambdaLayerJavaScriptSdkVersion;
Function fn = Function.Builder.create(this, "MyFunction")
.runtime(Runtime.NODEJS_LATEST)
.handler("index.handler")
.code(Code.fromInline("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }"))
.adotInstrumentation(AdotInstrumentationConfig.builder()
.layerVersion(AdotLayerVersion.fromJavaScriptSdkLayerVersion(AdotLambdaLayerJavaScriptSdkVersion.LATEST))
.execWrapper(AdotLambdaExecWrapper.REGULAR_HANDLER)
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;
var fn = new Function(this, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromInline("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }"),
AdotInstrumentation = new AdotInstrumentationConfig {
LayerVersion = AdotLayerVersion.FromJavaScriptSdkLayerVersion(AdotLambdaLayerJavaScriptSdkVersion.LATEST),
ExecWrapper = AdotLambdaExecWrapper.REGULAR_HANDLER
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
fn := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
Runtime: lambda.Runtime_NODEJS_LATEST(),
Handler: jsii.String("index.handler"),
Code: lambda.Code_FromInline(jsii.String("exports.handler = function(event, ctx, cb) { return cb(null, \"hi\"); }")),
AdotInstrumentation: &AdotInstrumentationConfig{
LayerVersion: awscdk.AdotLayerVersion_FromJavaScriptSdkLayerVersion(awscdk.AdotLambdaLayerJavaScriptSdkVersion_LATEST()),
ExecWrapper: awscdk.AdotLambdaExecWrapper_REGULAR_HANDLER,
},
})
Initializer
ts
new AdotLayerVersion()
python
AdotLayerVersion()
java
new AdotLayerVersion()
csharp
new AdotLayerVersion()
go
NewAdotLayerVersion()
Methods
fromGenericLayerVersion(version: AdotLambdaLayerGenericVersion): AdotLayerVersion // chainable@staticmethod def from_generic_layer_version(version: AdotLambdaLayerGenericVersion) -> AdotLayerVersionpublic static AdotLayerVersion fromGenericLayerVersion(AdotLambdaLayerGenericVersion version)public static AdotLayerVersion FromGenericLayerVersion(AdotLambdaLayerGenericVersion version)func FromGenericLayerVersion(Version AdotLambdaLayerGenericVersion) AdotLayerVersionstatic#The ADOT Lambda layer for generic use cases.
1 parameter
Parameters
versionversionversionversionVersion— The version of the Lambda layer to use.
fromJavaAutoInstrumentationLayerVersion(version: AdotLambdaLayerJavaAutoInstrumentationVersion): AdotLayerVersion // chainable@staticmethod def from_java_auto_instrumentation_layer_version(version: AdotLambdaLayerJavaAutoInstrumentationVersion) -> AdotLayerVersionpublic static AdotLayerVersion fromJavaAutoInstrumentationLayerVersion(AdotLambdaLayerJavaAutoInstrumentationVersion version)public static AdotLayerVersion FromJavaAutoInstrumentationLayerVersion(AdotLambdaLayerJavaAutoInstrumentationVersion version)func FromJavaAutoInstrumentationLayerVersion(Version AdotLambdaLayerJavaAutoInstrumentationVersion) AdotLayerVersionstatic#The ADOT Lambda layer for Java auto instrumentation.
1 parameter
Parameters
versionversionversionversionVersion— The version of the Lambda layer to use.
fromJavaScriptSdkLayerVersion(version: AdotLambdaLayerJavaScriptSdkVersion): AdotLayerVersion // chainable@staticmethod def from_java_script_sdk_layer_version(version: AdotLambdaLayerJavaScriptSdkVersion) -> AdotLayerVersionpublic static AdotLayerVersion fromJavaScriptSdkLayerVersion(AdotLambdaLayerJavaScriptSdkVersion version)public static AdotLayerVersion FromJavaScriptSdkLayerVersion(AdotLambdaLayerJavaScriptSdkVersion version)func FromJavaScriptSdkLayerVersion(Version AdotLambdaLayerJavaScriptSdkVersion) AdotLayerVersionstatic#The ADOT Lambda layer for JavaScript SDK.
1 parameter
Parameters
versionversionversionversionVersion— The version of the Lambda layer to use.
fromJavaSdkLayerVersion(version: AdotLambdaLayerJavaSdkVersion): AdotLayerVersion // chainable@staticmethod def from_java_sdk_layer_version(version: AdotLambdaLayerJavaSdkVersion) -> AdotLayerVersionpublic static AdotLayerVersion fromJavaSdkLayerVersion(AdotLambdaLayerJavaSdkVersion version)public static AdotLayerVersion FromJavaSdkLayerVersion(AdotLambdaLayerJavaSdkVersion version)func FromJavaSdkLayerVersion(Version AdotLambdaLayerJavaSdkVersion) AdotLayerVersionstatic#The ADOT Lambda layer for Java SDK.
1 parameter
Parameters
versionversionversionversionVersion— The version of the Lambda layer to use.
fromPythonSdkLayerVersion(version: AdotLambdaLayerPythonSdkVersion): AdotLayerVersion // chainable@staticmethod def from_python_sdk_layer_version(version: AdotLambdaLayerPythonSdkVersion) -> AdotLayerVersionpublic static AdotLayerVersion fromPythonSdkLayerVersion(AdotLambdaLayerPythonSdkVersion version)public static AdotLayerVersion FromPythonSdkLayerVersion(AdotLambdaLayerPythonSdkVersion version)func FromPythonSdkLayerVersion(Version AdotLambdaLayerPythonSdkVersion) AdotLayerVersionstatic#The ADOT Lambda layer for Python SDK.
1 parameter
Parameters
versionversionversionversionVersion— The version of the Lambda layer to use.