Created
April 8, 2016 21:12
-
-
Save adam-hert/ef58432d20327689305391af0d798390 to your computer and use it in GitHub Desktop.
Instrument a non-servlet java application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The HelloTrace class is an example of how to instrument a non-servlet java application | |
* simply traces "Hello World!" to standard output. | |
*/ | |
//import the tracelytics-api.jar (/usr/local/tracelytics/tracelytics-api.jar) | |
import com.tracelytics.api.ext.*; | |
class HelloTrace { | |
public static void main(String[] args) { | |
//Start a trace (In a servlet, we do this automatically at the start of the request) | |
TraceEvent event = Trace.startTrace("Hello Trace POJO"); | |
// Because TraceView's UI like web applications, we'll use HTTP server KV pairs to leverage the UI fully | |
// source: https://docs.appneta.com/extending-traceview-customizing | |
event.addInfo("HTTP-Host", "Localhost"); | |
event.addInfo("URL", "Hello_Trace/POJO"); // example for if there is a specific task type you'd like to segment on | |
event.report(); | |
//Do some normal java stuff | |
System.out.println("Hello Trace!"); // Display the string. | |
//End the Trace | |
Trace.endTrace("Hello Trace POJO"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment