This package provides instrumentation for AWS Lambda functions writen in .NET for collection of distributed tracing and performence monitoring.
Using .NET CLI:
$ dotnet add package Epsagon.Dotnet.Lambda
Using PackageReference in a *.csproj
file:
Follow instructions here.
- Set the following environment variables:
EPSAGON_TOKEN
- Epsagon's token, can be found in the DashboardEPSAGON_APP_NAME
- Name for the application of this function (optional)
- Generate a new AWS Lambda Function project (For more info)
- Add
Epsagon.Dotnet.Lambda
package to your project
- Modify your Lambda Function Handler (usually found in
Function.cs
) like so:
// handling S3 invoked lambda
public class Function : LambdaHandler<S3Event, string> // LambdaHandler<TEvent, TRes>
{
public override string HandlerFunction(S3Event input, ILambdaContext context)
{
return "Hello from Epsagon!";
}
}
- Change the
function-handler
in your project'saws-lambda-tools-defaults.json
to beEpsagonEnabledHandler
(see demo for more info) - And that's it!
- Add a call to
EpsagonBootstrap.Bootstrap()
in the constructor of your lambda - Invoke
EpsagonHandler.Handle
to instrument your function like so:
public class FunctionClass {
public FunctionClass() {
EpsagonBootstrap.Bootstrap();
}
public string MyHandler(S3Event input, ILambdaContext context) {
return EpsagonHandler.Handle(input, context, () => {
// your code is here...
});
}
// Can be async as well
public Task<string> MyAsyncHandler(S3Event input, ILambdaContext context) {
return EpsagonHandler.Handle(input, context, async () => {
// your async code is here
});
}
}
- And that's it!
Provided under the MIT license. See LICENSE for details.
Copyright 2019, Epsagon