Supported Runtimes: Java 8, Java 11
Include lumigo java tracer dependency, for Maven projects, use:
<repositories>
<repository>
<id>lumigo</id>
<url>https://raw.githubusercontent.com/lumigo-io/java-tracer/master/local-repository/</url>
</repository>
</repositories><dependency>
<groupId>io.lumigo</groupId>
<artifactId>java-tracer</artifactId>
<version>1.0.39</version>
</dependency>
<dependency>
<groupId>io.lumigo</groupId>
<artifactId>lumigo-agent</artifactId>
<version>1.0.39</version>
</dependency>Find the latest version here (the format of the version will be n.n.n):
-
Wrap your lambda function by implementing a supplier which contains your code
class MyFunction implements RequestHandler<INPUT, OUTPUT> { @Override public OUTPUT handleRequest(INPUT event, Context context) { Supplier<OUTPUT> supplier = () -> { //Your lambda code //return <result of type OUTPUT>; }; return LumigoRequestExecutor.execute(event, context, supplier); } }
-
For handler return void use:
class MyFunction implements RequestHandler<INPUT, Void> { @Override public Void handleRequest(INPUT event, Context context) { Supplier<Void> supplier = () -> { //Your lambda code return null; }; return LumigoRequestExecutor.execute(event, context, supplier); } }
There are 2 way to pass configuration properties
Adding LUMIGO_TRACER_TOKEN environment variables
class MyFunction implements RequestHandler<String, String> {
static{
LumigoConfiguration.builder().token("xxx").build().init();
}
@Override
public String handleRequest(String event, Context context) {
Supplier<String> supplier = () -> {
//Your lambda code
return "";
};
return LumigoRequestExecutor.execute(event, context, supplier);
}
}Add the environment variable JAVA_TOOL_OPTIONS to your Lambda functions and set it to
-Djdk.attach.allowAttachSelf=true in addition to the manual code mentioned above.