Skip navigation links

AppOptics Java AWS Lambda 1.0.0 API

Enables AppOptics instrumentation for java functions in AWS Lambda.

See: Description

Packages 
Package Description
com.appoptics.awslambda
Obtains the io.opentelemetry.trace.Tracer
com.appoptics.awslambda.handler
Enables AppOptics instrumentation for java functions in AWS Lambda.
com.appoptics.awslambda.wrapper.httpclient.apache
Enables AppOptics instrumentation for outbound http requests by Apache HTTP Client
Enables AppOptics instrumentation for java functions in AWS Lambda.

There are 2 ways to enable our instrumentation:

Use Request Handler interface

If your function has already implemented com.amazonaws.services.lambda.runtime.RequestHandler or com.amazonaws.services.lambda.runtime.RequestStreamHandler
  1. Add the dependency com.appoptics.agent.java:appoptics-aws-lambda to your project
  2. Implement TracedRequestHandler/TracedRequestStreamHandler instead of com.amazonaws.services.lambda.runtime.RequestHandler/com.amazonaws.services.lambda.runtime.RequestStreamHandler
  3. Rename the method handleRequest to doHandleRequest
  4. Redeploy the AWS Lambda function
For example:
    
import com.appoptics.awslambda.handler.TracedRequestHandler;
public class MyHandler implements TracedRequestHandler<APIGatewayV2ProxyRequestEvent, APIGatewayV2ProxyResponseEvent> { //replaced RequestHandler with TracedRequestHandler
    public APIGatewayV2ProxyResponseEvent doHandleRequest(APIGatewayV2ProxyRequestEvent input, Context context) { //renamed from handleRequest
        //...
    }
}
    

Use our Instrumentor

Wrap your existing code logic with our instrumentor method
  1. Add the dependency com.appoptics.agent.java:appoptics-aws-lambda to your project
  2. Wrap the existing code logic with method instrument or instrumentChecked of HandlerInstrumentor
  3. Redeploy the AWS Lambda function
For example:
    
import com.appoptics.awslambda.handler.HandlerInstrumentor;

public class MyHandler {
    public Output myMethod(Input input, Context context) throws IOException { //method signature unchanged
        return HandlerInstrumentor.instrumentChecked(input, context, getClass(), () -> {
            // original code logic that might throw IOException...
        }
    }
}

    
For configuration options, please refer to Java AWS Lambda configuration
Skip navigation links

Copyright © 2020. All rights reserved.