Follow the steps mentioned below to connect a custom New Relic instance (not from PWS marketplace) to a sample rails app:
Obtain a New Relic instance credentials from the vendor.
Fork the following application from Github:
https://github.com/cloudfoundry-samples/rails_sample_app.
This is an example. You can substitute the actual Rails application here instead.
Modify the following file:
https://github.com/cloudfoundry-samples/rails_sample_app/blob/newrelic/config/newrelic.yml#L19
and supply appropriate New Relic instance credentials.
Use the New Relic and other service offerings from PWS marketplace as they provide auto-binding without the need to manually supply the credentials.
Be careful when injecting your service credentials directly into a configuration file that is part of your application. You do not want the service credentials to be checked into source code as this could leak the configuration values.