Java Tracer Save

Lumigo's JVM Distributed Tracing and Performance Agent

Project README

Java Tracer

CircleCI Version codecov

Supported Runtimes: Java 8, Java 11

Building With Lumigo

Maven

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.40</version>
</dependency>

<dependency>
  <groupId>io.lumigo</groupId>
  <artifactId>lumigo-agent</artifactId>
  <version>1.0.40</version>
</dependency>

Find the latest version here (the format of the version will be n.n.n):

Wrapping your Lambda

  • 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);
            }
        }
    

Configuration

There are 2 way to pass configuration properties

Environment variables

Adding LUMIGO_TRACER_TOKEN environment variables

Static code initiation

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);
        }
    }

Java 11 Support

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.

Open Source Agenda is not affiliated with "Java Tracer" Project. README Source: lumigo-io/java-tracer
Stars
36
Open Issues
4
Last Commit
3 months ago
License

Open Source Agenda Badge

Open Source Agenda Rating