Standardize tracing with AWS Lambda Powertools

Standardize your application tracing with Powertools.

Tracing provides an opinionated wrapper around the AWS X-Ray SDK for .NET.

Select language:

Using Powertools Tracing with .NET:

Install the library in your project:

dotnet add package AWS.Lambda.Powertools.Tracing --prerelease
                                                      


The Logging functionality requires an environment variables to be set; POWERTOOLS_SERVICE_NAME.

using Amazon.Lambda.Core;
using AWS.Lambda.Powertools.Tracing;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace Powertools.Trace
{
    public class Function
    {
        // Powertools Logger requires an environment variables against your function
        // POWERTOOLS_SERVICE_NAME

        [Tracing]
        public void Handler(object request, ILambdaContext context)
        {
            Tracing.AddAnnotation("annotation", "value");
            Tracing.AddMetadata("metadata", "sample");

            Tracing.WithSubsegment("loggingResponse", (subsegment) => {
                // Some business logic
            });
        }
    }
}
                                                      



Created by:

James Eastham

James Eastham

I am a Cloud Infrastructure Architect with AWS Professional Services.

Rahul Popat

Rahul Popat

Senior Specialist Solutions Architect at AWS

Follow on LinkedIn