Don't Forget Chicago

Don’t forget Chicago

We are nearly done, one more location to go… Chicago.

Since we have been having so many issues related to “location” and we have added that custom attribute via Opentelemetry Manual Instrumentation, lets go to the Splunk Observability UI and look at an APM metric set around that tag that I created for us.

9-chicago-1-metricset 9-chicago-1-metricset

  • Open a browser and navigate to http://[EC2-Address]:8010
    • Replace [EC2-Address] with the ip address of your host
  • Select a few locations and hit the Login button.
    • Make sure to also select the Chicago Location and hit the Login button.

9-chicago-2-app 9-chicago-2-app

Uh oh! We received a 500 error, something is wrong there as well.

9-chicago-3-map 9-chicago-3-map

  • Return to the Splunk Observability UI and lets look once again at our Service Map
  • Select the Instruments Service
  • Click the Breakdowns dropdown on the right and select location

9-chicago-4-map-breakdown 9-chicago-4-map-breakdown

We see there was an un-handled exception thrown in the Instruments service, and some latency from our database that is related to the Chicago location!

  • Click on Traces on the right
  • Click Errors Only
  • Click one of the traces

9-chicago-5-trace 9-chicago-5-trace

We can see the exception was thrown by Hibernate, however it was thrown in our method instruments: InstrumentRepository.findInstruments

9-chicago-6-span 9-chicago-6-span

Let’s play developer again

  • Edit the file instruments: InstrumentRepository.findInstruments using nano:
nano instruments/src/main/java/com/shabushabu/javashop/instruments/repositories/FindInstrumentRepositoryImpl.java
  • Find the method: findInstruments
    • You know how to do this now, right?

9-chicago-7-code 9-chicago-7-code

We can see the developer accidently added the Instruments database with the Chicago Instruments database!

Let’s change the query and fix this, remove instruments_for_sale from our query.

  • Change this:
public Object findInstruments() {
  LOGGER.info("findInstruments Called (All)");
  Object obj = entityManager.createNativeQuery( "SELECT * FROM instruments_for_sale, instruments_for_sale_chicago").getResultList(); 
  return obj;
}
  • to this:
public Object findInstruments() {
  LOGGER.info("findInstruments Called (All)");
  Object obj = entityManager.createNativeQuery( "SELECT * FROM instruments_for_sale_chicago").getResultList(); 
  return obj;
}
  • Save the changes: [CTRL]-o [Enter]

  • Exit: [CTRL]-x

  • Build and Deploy Application

./BuildAndDeploy.sh

Now let’s test the Chicago location once again

We now see the 500 error is gone!

  • Let’s confirm a clean Service Map:

9-chicago-8-map-clean 9-chicago-8-map-clean

If you see a clean service map, free of errors and Latency you have successfully completed the Java Instrumentation Workshop!

Congratulations!!!