Question

I am deploying java apps to Cloud Foundry v1 as a war files. Cloud Foundry takes my WAR, adds it to tomcat during staging and run this tomcat with my app somewhere on DEA host.
And instead of packing newrelic.jar and newrelic.yml to war file, I would prefer them to be already in Cloud Foundry's tomcat. But in such a case all deployments will have same newrelic.yml, and thus I need some way to specify correct application name dynamically instead of statically set in newrelic.yml. Is there any option for this?
I have possibility to set environment variables during deployment, if they can be used in some way. Or maybe there is an option to modify newrelic.jar to add dependency on Cloud Foundry runtime to get app name? Could you please suggest some way?

Was it helpful?

Solution

The New Relic Java Agent can be passed environment variables at run/deploy time.

If you want to set the app name with an environment variable you can do so with:

export NEW_RELIC_APP_NAME="Your App Name Here"

You can also pass the app name at runtime with a Java system property like so:

-Dnewrelic.config.app_name="Your App Name Here"

Also, the order of precedence is environment variable, system property and then config file. The environment variable overrides all other settings and the system property will override the config file but not the environment variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top