Skip to content

tsibelman/epsagon-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Epsagon Instrumentation for .NET

This package provides instrumentation for AWS Lambda functions writen in .NET for collection of distributed tracing and performence monitoring.

How to install

Using .NET CLI:

$ dotnet add package Epsagon.Dotnet.Lambda

Using PackageReference in a *.csproj file:

Follow instructions here.

Getting Started

  • Set the following environment variables:
    • EPSAGON_TOKEN - Epsagon's token, can be found in the Dashboard
    • EPSAGON_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

Inherit from Epsagon's LambdaHandler Base Class

  • 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's aws-lambda-tools-defaults.json to be EpsagonEnabledHandler (see demo for more info)
  • And that's it!

Passing a callback

  • 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!

Copyright

Provided under the MIT license. See LICENSE for details.

Copyright 2019, Epsagon

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 97.1%
  • Python 2.0%
  • Shell 0.9%