Skip to content

Commit

Permalink
Add NEW_RELIC_K8S_OPERATOR_ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
hmstepanek committed Apr 17, 2024
1 parent 3b46fad commit 01bd62a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion newrelic/bootstrap/sitecustomize.py
Expand Up @@ -121,8 +121,9 @@ def log_message(text, *args, **kwargs):

log_message("python_prefix_matches = %r", python_prefix_matches)
log_message("python_version_matches = %r", python_version_matches)
k8s_operator_enabled = os.environ.get("NEW_RELIC_K8S_OPERATOR_ENABLED", False)

if python_prefix_matches and python_version_matches:
if k8s_operator_enabled or (python_prefix_matches and python_version_matches):
# We also need to skip agent initialisation if neither the license
# key or config file environment variables are set. We do this as
# some people like to use a common startup script which always uses
Expand Down
1 change: 1 addition & 0 deletions newrelic/config.py
Expand Up @@ -564,6 +564,7 @@ def _process_configuration(section):
_process_setting(section, "ai_monitoring.enabled", "getboolean", None)
_process_setting(section, "ai_monitoring.record_content.enabled", "getboolean", None)
_process_setting(section, "ai_monitoring.streaming.enabled", "getboolean", None)
_process_setting(section, "k8s_operator.enabled", "getboolean", None)
_process_setting(section, "package_reporting.enabled", "getboolean", None)


Expand Down
10 changes: 9 additions & 1 deletion newrelic/core/config.py
Expand Up @@ -162,6 +162,10 @@ class AIMonitoringRecordContentSettings(Settings):
pass


class K8sOperatorSettings(Settings):
pass


class PackageReportingSettings(Settings):
pass

Expand Down Expand Up @@ -430,6 +434,7 @@ class EventHarvestConfigHarvestLimitSettings(Settings):
_settings.ai_monitoring = AIMonitoringSettings()
_settings.ai_monitoring.streaming = AIMonitoringStreamingSettings()
_settings.ai_monitoring.record_content = AIMonitoringRecordContentSettings()
_settings.k8s_operator = K8sOperatorSettings()
_settings.package_reporting = PackageReportingSettings()
_settings.attributes = AttributesSettings()
_settings.browser_monitoring = BrowserMonitorSettings()
Expand Down Expand Up @@ -745,7 +750,9 @@ def default_otlp_host(host):
_settings.gc_runtime_metrics.enabled = False
_settings.gc_runtime_metrics.top_object_count_limit = 5

_settings.memory_runtime_pid_metrics.enabled = _environ_as_bool("NEW_RELIC_MEMORY_RUNTIME_METRICS_ENABLED", default=True)
_settings.memory_runtime_pid_metrics.enabled = _environ_as_bool(
"NEW_RELIC_MEMORY_RUNTIME_METRICS_ENABLED", default=True
)

_settings.transaction_events.enabled = True
_settings.transaction_events.attributes.enabled = True
Expand Down Expand Up @@ -953,6 +960,7 @@ def default_otlp_host(host):
"NEW_RELIC_AI_MONITORING_RECORD_CONTENT_ENABLED", default=True
)
_settings.ai_monitoring._llm_token_count_callback = None
_settings.k8s_operator.enabled = _environ_as_bool("NEW_RELIC_K8S_OPERATOR_ENABLED", default=False)
_settings.package_reporting.enabled = _environ_as_bool("NEW_RELIC_PACKAGE_REPORTING_ENABLED", default=True)
_settings.ml_insights_events.enabled = _environ_as_bool("NEW_RELIC_ML_INSIGHTS_EVENTS_ENABLED", default=False)

Expand Down

0 comments on commit 01bd62a

Please sign in to comment.