class NewRelic::LocalEnvironment

This class is responsible for determining the ‘dispatcher’ in use by the current process. The dispatcher might be a recognized web server such as unicorn or passenger, a background job processor such as resque or sidekiq, or nil for unknown.

Dispatcher detection is best-effort, and serves two purposes:

  1. For some dispatchers, we need to apply specific workarounds in order for the agent to work correctly.

  2. When reading logs, since multiple processes on a given host might write into the same log, it’s useful to be able to identify what kind of process a given PID mapped to.

Overriding the dispatcher is possible via the NEW_RELIC_DISPATCHER environment variable, but this should not generally be necessary unless you’re on a dispatcher that falls into category 1 above, and our detection logic isn’t working correctly.

If the environment can’t be determined, it will be set to nil.

NewRelic::LocalEnvironment should be accessed through NewRelic::Control#local_env (via the NewRelic::Control singleton).