Search code examples
cloud-foundrybuildpackopen-telemetry-java

Cloud Foundry : Java Build Pack : Opentelemtry Javagent extension integration with jar from a repo


With the newly added ability on Java build pack to support monitoring using Opentelemetry javaagent is nice. We have written extensions to this javagent for monitoring our custom libraries - we can make aware of the javagent of these new extension by setting environment variable -Dotel.javagent.extensions refereing to a folder / or a jar locally.

Unfortunately this does not play well when we use Java Build pack (without explicitly having to include the extension as a dependency on your project). Considering we have a huge number of endstates that we want to add this instrumentation - is there a way to pull these extensions from an http instead of a local folder ? This mechansim am thinking of is very similiar to newrelic agent support which lets us to add extensions from http addresses by setting JBP_CONFIG_NEW_RELIC_AGENT property


Solution

  • is there a way to pull these extensions from an http instead of a local folder ?

    The support in the buildpack is only going to pull in the open telemetry JAR from here.

    If you just need to add a few additional class files, you could possibly repackage them within the Open Telemetry JAR itself. The buildpack will only download a single JAR, but you can tell it to pull the JAR from somewhere else.

    You'd need to host the modified JAR and the index.yml I linked to above somewhere else. Then you can use operator level config to override the location of that file for all apps. I believe the env variable to set would be JBP_CONFIG_OPEN_TELEMETRY_JAVAAGENT and you'd want to set it to {repository_root: "https://your-server.example.com/path/to/folder/with/index_yaml/"}. That should change the location from which it loads the JARs and it should load your modified JAR.

    This mechansim am thinking of is very similiar to newrelic agent support which lets us to add extensions from http addresses by setting JBP_CONFIG_NEW_RELIC_AGENT property

    The OpenTelemetry support in the CF Java buildpack does not support extensions like New Relic. It seems like a reasonable idea though, so feel free to open an issue and request it. https://github.com/cloudfoundry/java-buildpack/issues


    The other option would be to create a custom buildpack that installs your additional files and use multi-buildpack support to have that buildpack run first, then have the Java buildpack run. The Java buildpack has to run last though, that's a requirement of the CF JBP.

    https://docs.cloudfoundry.org/buildpacks/use-multiple-buildpacks.html

    I'm not sure this will totally solve your issue though because you still have to remember to have the buildpacks run in that order.