private void serve ( HttpRequest request , HttpResponse response ) { String url = request . getUri ( ) ; System . out . println ( "[Server] serve " + url ) ; IncomingWebRequestTracer incomingWebrequestTracer = oneAgentSDK . traceIncomingWebRequest ( webAppInfo , url , request . getMethod ( ) ) ; // add request header, parameter and remote address before start: for ( Entry < String , List < String > > headerField : request . getHeaders ( ) . entrySet ( ) ) { for ( String value : headerField . getValue ( ) ) { incomingWebrequestTracer . addRequestHeader ( headerField . getKey ( ) , value ) ; } } for ( Entry < String , List < String > > parameter : request . getParameters ( ) . entrySet ( ) ) { for ( String value : parameter . getValue ( ) ) { incomingWebrequestTracer . addParameter ( parameter . getKey ( ) , value ) ; } } incomingWebrequestTracer . setRemoteAddress ( request . getRemoteIpAddress ( ) ) ; incomingWebrequestTracer . start ( ) ; try { response . setContent ( "Hello world!" . getBytes ( ) ) ; response . setStatusCode ( 200 ) ; incomingWebrequestTracer . setStatusCode ( 200 ) ; } catch ( Exception e ) { // we assume, container is sending http 500 in case of exception is thrown while serving an request: incomingWebrequestTracer . error ( e ) ; e . printStackTrace ( ) ; throw new RuntimeException ( e ) ; } finally { incomingWebrequestTracer . end ( ) ; } }
faked http request handling . shows usage of OneAgent SDK s incoming webrequest API