![]() |
VOOZH | about |
dotnet add package OpenTelemetry.Instrumentation.AWSLambda --version 1.15.1
NuGet\Install-Package OpenTelemetry.Instrumentation.AWSLambda -Version 1.15.1
<PackageReference Include="OpenTelemetry.Instrumentation.AWSLambda" Version="1.15.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AWSLambda" Version="1.15.1" />Directory.Packages.props
<PackageReference Include="OpenTelemetry.Instrumentation.AWSLambda" />Project file
paket add OpenTelemetry.Instrumentation.AWSLambda --version 1.15.1
#r "nuget: OpenTelemetry.Instrumentation.AWSLambda, 1.15.1"
#:package OpenTelemetry.Instrumentation.AWSLambda@1.15.1
#addin nuget:?package=OpenTelemetry.Instrumentation.AWSLambda&version=1.15.1Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.Instrumentation.AWSLambda&version=1.15.1Install as a Cake Tool
| Status | |
|---|---|
| Stability | Stable |
| Code Owners | @rypdal, @Oberon00, @normj |
👁 NuGet version badge
👁 NuGet download count badge
👁 codecov.io
This repo contains SDK to instrument Lambda handler to create incoming span.
dotnet add package OpenTelemetry.Instrumentation.AWSLambda
Add AddAWSLambdaConfigurations() to TracerProvider.
TracerProvider tracerProvider = Sdk.CreateTracerProviderBuilder()
// add other instrumentations
.AddAWSLambdaConfigurations(options => options.DisableAwsXRayContextExtraction = true)
.Build();
AWSLambdaInstrumentationOptions contains various properties to configure
AWS lambda instrumentation:
AWSLambdaWrapper contains tracing methods covering different types of
function handler method signatures. AWSLambdaWrapper.Trace() and
AWSLambdaWrapper.TraceAsync() are used for wrapping synchronous
and asynchronous function handlers respectively. The ActivityContext parentContext
parameter is optional and used to pass a custom parent context. If the parent
is not passed explicitly then it's either extracted from the
input parameter or uses AWS X-Ray headers if AWS X-Ray context extraction is
enabled (see configuration property DisableAwsXRayContextExtraction).
If tracing is required when AWS X-Ray is disabled,
the DisableAwsXRayContextExtraction property needs to be set to true.
This will instruct the instrumentation to ignore the "not sampled"
trace header automatically sent when AWS X-Ray is disabled.
The sequence of the parent extraction:
explicit parent → parent from input parameter → AWS X-Ray headers → default
The parent extraction is supported for the input types listed in the table below:
| Type | Parent extraction source |
|---|---|
APIGatewayProxyRequest, APIGatewayHttpApiV2ProxyRequest, ApplicationLoadBalancerRequest |
HTTP headers of the request |
SQSEvent |
Attributes of the last SQSMessage (if SetParentFromMessageBatch is true) |
SNSEvent |
Attributes of the last SNSRecord |
Create a wrapper function with the same signature as the original Lambda
function but an added ILambdaContext parameter if it was not already present.
Call AWSLambdaWrapper.Trace() or AWSLambdaWrapper.TraceAsync() API and pass
TracerProvider, original Lambda function and its parameters.
Set the wrapper function as the Lambda handler input.
// new Lambda function handler passed in
public string TracingFunctionHandler(JObject input, ILambdaContext context)
=> AWSLambdaWrapper.Trace(tracerProvider, OriginalFunctionHandler, input, context);
public string OriginalFunctionHandler(JObject input, ILambdaContext context)
{
var S3Client = new AmazonS3Client();
var httpClient = new HttpClient();
_ = S3Client.ListBucketsAsync().Result;
_ = httpClient.GetAsync("https://aws.amazon.com").Result;
return input?.ToString();
}
For using base classes from package Amazon.Lambda.AspNetCoreServer,
override the FunctionHandlerAsync function in LambdaEntryPoint.cs file. Call
AWSLambdaWrapper.TraceAsync() API and pass TracerProvider, original Lambda function
and its inputs as parameters. Below is an example if using APIGatewayProxyFunction
as base class.
public override async Task<APIGatewayProxyResponse> FunctionHandlerAsync(
APIGatewayProxyRequest request, ILambdaContext lambdaContext)
=> await AWSLambdaWrapper.TraceAsync(tracerProvider, base.FunctionHandlerAsync,
request, lambdaContext);
A more detailed Lambda function example that takes a JObject and ILambdaContext as inputs.
public class Function
{
public static TracerProvider tracerProvider;
static Function()
{
tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation()
.AddAWSInstrumentation()
.AddOtlpExporter()
.AddAWSLambdaConfigurations(options => options.DisableAwsXRayContextExtraction = true)
.Build();
}
public string TracingFunctionHandler(JObject input, ILambdaContext context)
=> AWSLambdaWrapper.Trace(tracerProvider, FunctionHandler, input, context);
/// <summary>
/// A simple function that takes a JObject input and sends downstream http
/// request to aws.amazon.com and aws request to S3.
/// </summary>
public string FunctionHandler(JObject input, ILambdaContext context)
{
var S3Client = new AmazonS3Client();
var httpClient = new HttpClient();
_ = S3Client.ListBucketsAsync().Result;
_ = httpClient.GetAsync("https://aws.amazon.com").Result;
return input?.ToString();
}
}
For an overview on Semantic Conventions, see Open Telemetry - Semantic Conventions.
While this library is intended for production use, it relies on several Semantic Conventions that are still considered Experimental, meaning they may undergo additional changes before becoming Stable. This can impact the aggregation and analysis of telemetry signals in environments with multiple applications or microservices.
For example, a microservice using an older version of the Semantic Conventions
for Http Attributes may emit "http.method" with a value of GET, while a
different microservice, using a new version of Semantic Convention may instead
emit the GET as "http.request.method".
Future versions of OpenTelemetry.Instrumentation.AWSLambda library will include updates to the Semantic Convention, which may break compatibility with a previous version.
The default will remain as V1_28_0 until the next major version bump.
To opt in to automatic upgrades, you can use SemanticConventionVersion.Latest
or you can specify a specific version:
using (var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAWSLambdaConfigurations(opt =>
{
// pin to a specific Semantic Convention version
opt.SemanticConventionVersion = SemanticConventionVersion.V1_29_0;
})
.Build()!);
NOTE: Once a Semantic Convention becomes Stable, OpenTelemetry.Instrumentation.AWSLambda will remain on that version until the next major version bump.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on OpenTelemetry.Instrumentation.AWSLambda:
| Package | Downloads |
|---|---|
|
Grafana.OpenTelemetry
Full Grafana distribution of OpenTelemetry .NET |
|
|
Siemens.AspNet.MinimalApi.Sdk
A library which contains following functions: - Siemens.AspNet.MinimalApi.Sdk |
|
|
Siemens.AspNet.DbProvider
A library which contains following functions: - Siemens.AspNet.DbProvider |
|
|
AWS.Distro.OpenTelemetry.AutoInstrumentation
Package Description |
|
|
APF.Core.Clean.OpenTelemetry
This client library enables OpenTelemetry implementation in the APF services. |
Showing the top 1 popular GitHub repositories that depend on OpenTelemetry.Instrumentation.AWSLambda:
| Repository | Stars |
|---|---|
|
aws/integrations-on-dotnet-aspire-for-aws
This repositry contains the integrations with .NET Aspire for AWS.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.15.1 | 262,968 | 4/21/2026 |
| 1.15.0 | 372,815 | 1/21/2026 |
| 1.14.2 | 35,134 | 1/14/2026 |
| 1.14.1 | 53,120 | 12/19/2025 |
| 1.14.0 | 172,091 | 11/13/2025 |
| 1.13.0 | 57,752 | 10/29/2025 |
| 1.12.1 | 217,995 | 9/3/2025 |
| 1.12.0 | 943,074 | 5/6/2025 |
| 1.11.3 | 75,581 | 5/1/2025 |
| 1.11.2 | 541,445 | 3/18/2025 |
| 1.11.1 | 52,359 | 3/6/2025 |
| 1.11.0 | 157,365 | 1/29/2025 |
| 1.10.0-rc.2 | 17,495 | 1/15/2025 |
| 1.10.0-rc.1 | 5,712 | 1/6/2025 |
| 1.10.0-beta.3 | 5,256 | 12/20/2024 |
| 1.10.0-beta.2 | 2,788 | 12/12/2024 |
| 1.10.0-beta.1 | 503,784 | 11/23/2024 |
| 1.3.0-beta.1 | 1,444,490 | 1/26/2024 |
| 1.2.0-beta.1 | 600,762 | 8/7/2023 |
| 1.1.0-beta.3 | 82,755 | 6/13/2023 |