.NET

Instructions for installing the Lumigo tracer in a AWS Lambda function using a .NET runtime

Supported runtimes

  • .NET Core 2.1
  • .NET Core 3.1

Setup

Add the Lumigo Tracer to your application

Add the Lumigo tracer package via NuGet by running:

dotnet add package Lumigo.DotNET

Wrapping Your Lambda

Wrap your lambda function by implementing a supplier which contains your code:

sync handler:

using Lumigo.DotNET;
using Lumigo.DotNET.Instrumentation;
...
public class Function : LumigoRequestHandler
    {
        public Function()
        {
            LumigoBootstrap.Bootstrap();
        }

        public Response FunctionHandler(string input, ILambdaContext context)
        {
            return Handle(input, context, () =>
            {
                //Your lambda code
                //return <result>; - For void functions remove the return statements
            });
        }
    }

async handler:

using Lumigo.DotNET;
using Lumigo.DotNET.Instrumentation;
...
public class Function : LumigoRequestHandler
    {
        public Function()
        {
            LumigoBootstrap.Bootstrap();
        }

        public async Task<Response> FunctionHandler(string input, ILambdaContext context)
        {
            return await Handle(input, context, async () =>
            {
                //Your lambda code
                //return <result>; - For void functions remove the return statements
            });
        }
    }

Connect Your Lumigo Account

Set your Lumigo token as the LUMIGO_TRACER_TOKEN environment variable of your Lambda function; refer to the Using AWS Lambda environment variables documentation for more information. Your Lumigo token is available in Settings -> Tracing -> Manual tracing.

We advise you to use the most secure available to you to store secrets such as your LUMIGO_TRACER_TOKEN; additionally, AWS provides integrations for AWS Key Management Service that keep the values of your Lambda environment variables secure.

Track HTTP Requests

To track HTTP requests add UseLumigo to the HTTP client:

using Lumigo.DotNET.Utilities.Extensions;
...
    var httpClient = new HttpClient().UseLumigo();

Did this page help you?