Using OpenCensus Library with inspectIT Ocelot
If you plan to use the OpenCensus library in an application which will be instrumented later on with inspectIT Ocelot, some special rules do apply. Following these rules will make sure that there are no run-time problems in your application. Furthermore, a correct configuration will make it possible to combine metrics and traces that you manually collect using the OpenCensus instrumentation library with the ones collected by the inspectIT Ocelot agent.
Make sure you are using the same version of OpenCensus as inspectIT Ocelot.
The inspectIT Ocelot agent in version 2.5.3 internally uses OpenCensus in version 0.31.1. Please adapt any OpenCensus dependency in your application to this version to avoid run-time conflicts.
<dependency> <groupId>io.opencensus</groupId> <artifactId>opencensus-api</artifactId> <version>0.31.1</version> </dependency>
Set the JVM property
inspectit.publishOpenCensusToBootstrap
totrue
.-Dinspectit.publishOpenCensusToBootstrap=true
Setting the above property to
true
tells inspectIT Ocelot that you plan to use the OpenCensus library in combination with the agent. Note that this property must be specified with this exact name. The flexibility offered for all other config options does not apply here. The inspectIT Ocelot agent will make sure that all OpenCensus classes are then loaded by the bootstrap class loader. This ensures that OpenCensus implementation is shared between your manual instrumentation and the agent instrumentation, making the combination of data possible.Add the agent to the start of a JVM
In this scenario, it is required that you add the agent via the
javaagent
JVM argument. If the agent is successfully added to the JVM, it will log that the OpenCensus classes pushed to the bootstrap classloader will be used.It is important to state that the agent will not publish the OpenCensus classes to the bootstrap classloader if it is attached during runtime – even if the previously mentioned JVM argument is set! In this case, metrics and traces of manual OpenCensus instrumentations will not be collected by the inspectIT Ocelot agent.