Skip to content

Instantly share code, notes, and snippets.

@jaycdave88
Created November 26, 2019 20:02
Show Gist options
  • Save jaycdave88/230df7f2ca0b07b242ff49079c06dbbb to your computer and use it in GitHub Desktop.
Save jaycdave88/230df7f2ca0b07b242ff49079c06dbbb to your computer and use it in GitHub Desktop.
Manual Java
@RequestMapping
public @ResponseBody String coffeeHouseIndex() {
if (GlobalTracer.get() != null && GlobalTracer.get().activeSpan() != null) {
try {
GlobalTracer.get().activeSpan();
if (setPriority.get() == null) {
setPriority.compareAndSet(null, GlobalTracer.get().activeSpan().getClass().getDeclaredMethod("setSamplingPriority", int.class));
}
setPriority.get().invoke(GlobalTracer.get().activeSpan(), 2 );
} catch(Exception e) {
throw new RuntimeException(e);
}
}
final long startTs = System.currentTimeMillis();
User user = getRandomUser();
final long dbTime = System.currentTimeMillis() - startTs;
// distributed tracing with other applications
if (nodeJSAppAvailable) {
getUsersAuth();
}
prepareBrewInfo(user);
return "Hello Java: " + System.currentTimeMillis()
+ "<br/>Fetched Random User: " + user + " in " + dbTime + "ms";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment