public static void main ( String [ ] args ) throws InterruptedException { configureAlwaysSample ( ) ; // Always sample for demo purpose. DO NOT use in production. registerAllViews ( ) ; LongGauge gauge = registerGauge ( ) ; String endPoint = getStringOrDefaultFromArgs ( args , 0 , DEFAULT_ENDPOINT ) ; registerAgentExporters ( endPoint ) ; try ( Scope scope = tracer . spanBuilder ( "root" ) . startScopedSpan ( ) ) { int iteration = 1 ; while ( true ) { doWork ( iteration , random . nextInt ( 10 ) , gauge ) ; iteration ++ ; Thread . sleep ( 5000 ) ; } } catch ( InterruptedException e ) { logger . info ( "Thread interrupted, exiting in 5 seconds." ) ; Thread . sleep ( 5000 ) ; // Wait 5s so that last batch will be exported. } }
Main launcher of the example .