The Epsagon agents allow you to collect and monitor your functions for metrics, traces, calls, and correlation to logs.
Auto-tracing for Node.js and Python functions
Using the Epsagon dashboard you can easily enable tracing for Node.js and Python functions.
AWS Lambda Auto-Tracing
This feature changes the functions' configuration by adding a layer and setting a new handler.
We recommend getting started with a few functions in development.
To enable auto-tracing, go to the functions screen, checkmark the desired functions on the left side, and under actions, click enable auto-tracing
:


To disable, follow the same instructions, but under actions select disable auto-tracing
:


Calling the SDK
You can manually call the Epsagon SDK library inside your Lambda functions.
Install our library according to your runtime:
npm install epsagon
pip install --upgrade epsagon
<!--Add the epsagon dependecy to your pom.xml-->
<dependency>
<groupId>com.epsagon</groupId>
<artifactId>epsagon</artifactId>
<version>{Epsagon version}</version>
</dependency>
dotnet add package Epsagon.Dotnet.Lambda
# Using go get
go get github.com/epsagon/epsagon-go
# Using dep
dep ensure -add github.com/epsagon/epsagon-go
Inside your function handler (where you get the event
and context
) add the following snippet, and wrap the handler:
const epsagon = require('epsagon');
epsagon.init({
token: '<epsagon-token>',
appName: '<app-name-stage>',
metadataOnly: false,
});
// Wrap your entry point
module.exports.handler = epsagon.lambdaWrapper((event, context, callback) => {
// Your code is here
});
// Async functions supported
module.exports.handler = epsagon.lambdaWrapper(async (event) => {
// Your code is here
});
import epsagon
epsagon.init(
token='<epsagon-token>',
app_name='<app-name-stage>',
metadata_only=False,
)
# Wrap your entry point
@epsagon.lambda_wrapper
def handle(event, context):
# Your code is here
import com.epsagon.EpsagonRequestHandler;
// Make sure class extends com.epsagon.EpsagonRequestHandler
public class EpsagonWrapper extends EpsagonRequestHandler {
static {
try {
init("com.yourcompany.YourHandler::yourHandlerMethod")
.setToken("<epsagon-token>")
.setAppName("<app-name-stage>");
} catch (Exception e) {
System.out.println(e);
}
}
}
// either a) inherit from Epsagon's LambdaHander base class
// or b) pass handler through EpsagonHandler's callback
// inheriting from Epsagon's base LambdaHandler
public class Function : LambdaHandler<S3Event, string>
{
// handler function
public override string HandlerFunction(S3Event input, ILambdaContext context)
{
// your lambda handler here ...
}
}
// passing handler through EpsagonHandler callback
using Epsagon.Dotnet.Lambda;
public class FunctionClass {
public FunctionClass() {
// initialize Epsagon agent
EpsagonBootstrap.Bootstrap();
}
// handler function
public string MyHandler(S3Event input, ILambdaContext context) {
// wrap entire function with EpsagonHandler.Handle()
return EpsagonHandler.Handle<TEvent, TRes>(input, context, () => {
// your lambda handler here ...
});
}
}
package main
import (
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/epsagon/epsagon-go/epsagon"
"log"
)
func myHandler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
log.Println("In myHandler, received body: ", request.Body)
return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
}
func main() {
log.Println("enter main")
lambda.Start(epsagon.WrapLambdaHandler(
epsagon.NewTracerConfig("app-name-stage","epsagon-token"),
myHandler))
}
Updated 6 months ago