See: Description
Interface | Description |
---|---|
CheckedHandler<R,E extends Throwable> | |
CheckedProcedure<E extends Throwable> | |
Handler<R> | |
Procedure | |
TracedRequestHandler<I,O> |
Implement this interface instead of
RequestHandler to trace your function
Provide implementation of TracedRequestHandler.doHandleRequest(Object, Context) instead of
RequestHandler.handleRequest(Object, Context)
For example: |
TracedRequestStreamHandler |
Implement this interface instead of
RequestStreamHandler to trace your function
Provide implementation of doHandleRequest(InputStream, OutputStream, Context) instead of
RequestStreamHandler.handleRequest(InputStream, OutputStream, Context)
For example: |
Class | Description |
---|---|
HandlerInstrumentor |
Wrap the existing code logic with method
instrument or instrumentChecked |
There are 2 ways to enable our instrumentation:
com.amazonaws.services.lambda.runtime.RequestHandler
or com.amazonaws.services.lambda.runtime.RequestStreamHandler
TracedRequestHandler
/TracedRequestStreamHandler
instead of
com.amazonaws.services.lambda.runtime.RequestHandler/com.amazonaws.services.lambda.runtime.RequestStreamHandler
handleRequest
to doHandleRequest
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
//...
}
}
HandlerInstrumentor
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...
}
}
}
Copyright © 2020. All rights reserved.