• English日本語한국어
  • Log inStart now

application_settings (Python agent API)

Syntax

newrelic.agent.application_settings(name=None)

Returns an application settings object.

Description

This returns a reference to the application settings object. The global_settings object contains settings in the configuration file and environment variables; this application_settings object additionally includes configuration changes set server-side via the New Relic UI.

The returned settings are nested, hierarchical objects and the setting names match the names in the agent configuration file. The main reason to expose the application settings is if you want your instrumentation to reference the agent-specific local configuration and not what's set server-side.

If the name value is not set, the call uses the application name specified in the agent config file or via the NEW_RELIC_APP_NAME environment variable.

If the application hasn't been registered with the data collector when this call is made, it returns the value None. When a call is successfully made and returns values, it will reflect the values of any local configuration overlaid with the server-side configuration for that application obtained during registration.

Important

Do not make any changes to the application settings object. Do not cache the settings object because it will be invalidated and replaced if a server-side config change causes the agent to re-register the application with the data collector.

Parameters

Parameter

Description

name

string

Optional. The name of the application. If not set, the name matches the name set in the Python agent configuration for that application.

Return values

Returns an application settings object. The object itself does not present any public API; some other calls require it to be passed.

Examples

Using an IF statement

You might want to check the configuration settings to determine what custom instrumentation to implement. Here's an example of using an if statement with the app settings object:

settings = newrelic.agent.application_settings()
if settings and settings.error_collector.enabled:
...

Passing results into dict

If you are debugging or logging and require the global settings as a traditional Python dictionary object, you can pass the result into a dict. For example:

settings_dict = dict(newrelic.agent.application_settings())
for name, value in settings_dict.items():
print name, value

Each name will be the full dotted path for that setting.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.