Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fcb9cf6
added basic AwsConfig interface
deleonenriqueta Dec 4, 2025
5d8da89
added AwsConfigImpl to support fargate_metadata_endpoint_proxy_disable
deleonenriqueta Dec 4, 2025
eefec8a
wired AwsConfig and added the initAwsConfig method
deleonenriqueta Dec 4, 2025
9bcf59e
added a method to access the AwsConfig
deleonenriqueta Dec 4, 2025
4dfd190
made updates to respect the fargate_metadata_endpoint_proxy_diable
deleonenriqueta Dec 4, 2025
40e9e59
update to add AwsConfig and pass it to the AwsFargateMetadataFetcher
deleonenriqueta Dec 4, 2025
d7d15fb
inject AwsConfig into DockerData from the constructor
deleonenriqueta Dec 4, 2025
4943f2f
update to use AwsConfig
deleonenriqueta Dec 4, 2025
e968b4d
added AwsFargateMetadataFetcherTest class covering proxy disable config
deleonenriqueta Dec 4, 2025
aa120cf
clean up imports
deleonenriqueta Dec 4, 2025
d518b1b
add tests for AwsConfig proxy disable settings
deleonenriqueta Dec 4, 2025
af4ca0d
added copyright
deleonenriqueta Dec 4, 2025
483504d
clean up imports
deleonenriqueta Dec 4, 2025
dc45e08
update naming
deleonenriqueta Dec 9, 2025
305e773
adding logging to confirm enabled/disabled Aws Farget Config
deleonenriqueta Dec 9, 2025
7e14512
update logging location/message
deleonenriqueta Dec 9, 2025
0e4a3d5
update logic to correct prefix and access nested props
deleonenriqueta Dec 17, 2025
c815812
update tests
deleonenriqueta Dec 17, 2025
128d476
replace AwsConfig with CloudConfig
deleonenriqueta Jan 15, 2026
f3c93d6
replace AwsConfig with CloudConfig
deleonenriqueta Jan 15, 2026
5dee04d
create CloudConfig interface
deleonenriqueta Jan 15, 2026
fe078b4
create CloudConfigImpl
deleonenriqueta Jan 15, 2026
bcec247
add description and update config name
deleonenriqueta Jan 15, 2026
d9dcfff
clean logs and update config name
deleonenriqueta Jan 15, 2026
2225456
update config name and add debug level logging
deleonenriqueta Jan 15, 2026
00330cf
update config name and root
deleonenriqueta Jan 15, 2026
4d27eff
update config name in tests
deleonenriqueta Jan 15, 2026
7f5a626
add tests to cover new CloudConfigImpl logic
deleonenriqueta Jan 15, 2026
d75ac80
refactored config, generalized to cloud proxy bypass and refactored
deleonenriqueta Feb 11, 2026
5a4f3cb
include commented out section for proxy bypass config
deleonenriqueta Feb 11, 2026
3bddb5b
update config name
deleonenriqueta Mar 9, 2026
2285099
update yml with new config name
deleonenriqueta Mar 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ public interface AgentConfig extends com.newrelic.api.agent.Config, DataSenderCo
*/
AttributesConfig getAttributesConfig();

/**
* Get the cloud related configuration.
*/
CloudConfig getCloudConfig();

ObfuscateJvmPropsConfig getObfuscateJvmPropsConfig();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class AgentConfigImpl extends BaseConfig implements AgentConfig {

public static final String ADAPTIVE_SAMPLER_SAMPLING_TARGET = "adaptive_sampler_sampling_target";
public static final String ADAPTIVE_SAMPLER_SAMPLING_PERIOD = "adaptive_sampler_sampling_period";
public static final String CLOUD = "cloud";
public static final String CODE_LEVEL_METRICS = "code_level_metrics";
public static final String COMPRESSED_CONTENT_ENCODING_PROPERTY = "compressed_content_encoding";
public static final String CPU_SAMPLING_ENABLED = "cpu_sampling_enabled";
Expand Down Expand Up @@ -253,6 +254,7 @@ public class AgentConfigImpl extends BaseConfig implements AgentConfig {
// nested configs (alphabetized)
private final AttributesConfig attributesConfig;
private final AuditModeConfig auditModeConfig;
private final CloudConfig cloudConfig;
private final TransactionTracerConfigImpl backgroundTransactionTracerConfig;
private final BrowserMonitoringConfig browserMonitoringConfig;
private final ClassTransformerConfig classTransformerConfig;
Expand Down Expand Up @@ -359,6 +361,7 @@ private AgentConfigImpl(Map<String, Object> props) {
keyTransactionConfig = initKeyTransactionConfig(apdexTInMillis);
sqlTraceConfig = initSqlTraceConfig();
auditModeConfig = initAuditModeConfig();
cloudConfig = initCloudConfig();
browserMonitoringConfig = initBrowserMonitoringConfig();
classTransformerConfig = initClassTransformerConfig(litemode);
crossProcessConfig = initCrossProcessConfig();
Expand Down Expand Up @@ -800,6 +803,11 @@ private AuditModeConfig initAuditModeConfig() {
}
}

private CloudConfig initCloudConfig() {
Map<String, Object> cloudProps = nestedProps(CLOUD);
return new CloudConfigImpl(cloudProps);
}

private BrowserMonitoringConfig initBrowserMonitoringConfig() {
Map<String, Object> props = nestedProps(BROWSER_MONITORING);
return BrowserMonitoringConfigImpl.createBrowserMonitoringConfig(props);
Expand Down Expand Up @@ -1024,6 +1032,9 @@ public AuditModeConfig getAuditModeConfig() {
return auditModeConfig;
}

@Override
public CloudConfig getCloudConfig() { return cloudConfig; }

@Override
public boolean liteMode() {
return litemode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
*
* * Copyright 2025 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.newrelic.agent.config;

/**
* Interface for cloud configuration options.
*/

public interface CloudConfig extends Config {
boolean isCloudMetadataBypassProxyEnabled();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
*
* * Copyright 2025 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package com.newrelic.agent.config;

import java.util.Map;

public class CloudConfigImpl extends BaseConfig implements CloudConfig {

public static final String SYSTEM_PROPERTY_ROOT = "newrelic.config.cloud.";
public static final String METADATA_BYPASS_PROXY = "metadata_bypass_proxy";
public static final boolean DEFAULT_METADATA_BYPASS_PROXY = false;

public CloudConfigImpl(Map<String, Object> cloudProps) {
super(cloudProps, SYSTEM_PROPERTY_ROOT);
}

@Override
public boolean isCloudMetadataBypassProxyEnabled() {
return getProperty(METADATA_BYPASS_PROXY, DEFAULT_METADATA_BYPASS_PROXY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
*/
package com.newrelic.agent.utilization;

import com.newrelic.agent.Agent;
import com.newrelic.agent.config.CloudConfig;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;

Expand All @@ -17,13 +21,23 @@
*/
public class AwsFargateMetadataFetcher {
private final URL url;
private final CloudConfig cloudConfig;

public AwsFargateMetadataFetcher(String metadataUrl) throws MalformedURLException {
public AwsFargateMetadataFetcher(String metadataUrl, CloudConfig cloudConfig) throws MalformedURLException {
url = new URL(metadataUrl);
this.cloudConfig = cloudConfig;
}

public InputStream openStream() throws IOException {
URLConnection connection = url.openConnection();
URLConnection connection;

Agent.LOG.debug("Cloud Metadata Bypass Proxy enabled: " + cloudConfig.isCloudMetadataBypassProxyEnabled());

if (cloudConfig.isCloudMetadataBypassProxyEnabled()) {
connection = url.openConnection(Proxy.NO_PROXY);
} else {
connection = url.openConnection();
}
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import com.google.common.annotations.VisibleForTesting;
import com.newrelic.agent.Agent;
import com.newrelic.agent.config.internal.SystemEnvironmentFacade;
import com.newrelic.agent.config.CloudConfig;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
Expand Down Expand Up @@ -59,6 +59,12 @@ public class DockerData {
private static final Pattern DOCKER_CONTAINER_STRING_V1 = Pattern.compile("^.*[^0-9a-f]+([0-9a-f]{64,}).*");
private static final Pattern DOCKER_CONTAINER_STRING_V2 = Pattern.compile(".*/docker/containers/([0-9a-f]{64,}).*");

private final CloudConfig cloudConfig;

public DockerData(CloudConfig cloudConfig) {
this.cloudConfig = cloudConfig;
}

public String getDockerContainerIdForEcsFargate(boolean isLinux) {
if (isLinux) {
String result;
Expand All @@ -69,7 +75,7 @@ public String getDockerContainerIdForEcsFargate(boolean isLinux) {
fargateUrl = System.getenv(AWS_ECS_METADATA_V4_ENV_VAR);
if (fargateUrl != null) {
Agent.LOG.log(Level.INFO, "Attempting to fetch ECS Fargate container id from URL (v4): {0}", fargateUrl);
result = retrieveDockerIdFromFargateMetadata(new AwsFargateMetadataFetcher(fargateUrl));
result = retrieveDockerIdFromFargateMetadata(new AwsFargateMetadataFetcher(fargateUrl, cloudConfig));
if (result != null) {
Agent.LOG.log(Level.INFO, "Found container id: {0}", result);
return result;
Expand All @@ -79,7 +85,7 @@ public String getDockerContainerIdForEcsFargate(boolean isLinux) {
fargateUrl = System.getenv(AWS_ECS_METADATA_UNVERSIONED_ENV_VAR);
if (fargateUrl != null) {
Agent.LOG.log(Level.INFO, "Attempting to fetch ECS Fargate container id from URL (unversioned): {0}", fargateUrl);
result = retrieveDockerIdFromFargateMetadata(new AwsFargateMetadataFetcher(fargateUrl));
result = retrieveDockerIdFromFargateMetadata(new AwsFargateMetadataFetcher(fargateUrl, cloudConfig));
if (result != null) {
Agent.LOG.log(Level.INFO, "Found container id: {0}", result);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class UtilizationService extends AbstractService {
private final ExecutorService executor = Executors.newFixedThreadPool(2, new DefaultThreadFactory(THREAD_NAME, true));
private Future<UtilizationData> future = null;

private static final DockerData dockerData = new DockerData();

private static final String THREAD_NAME = "New Relic Utilization Service";

/**
Expand All @@ -71,6 +71,7 @@ public class UtilizationService extends AbstractService {
private final boolean detectGcp;
private final boolean detectAzure;
private final boolean detectKubernetes;
private final DockerData dockerData;

private static final CloudUtility cloudUtility = new CloudUtility();
private static final AWS aws = new AWS(cloudUtility);
Expand All @@ -89,6 +90,7 @@ public UtilizationService() {
detectGcp = agentConfig.getValue(DETECT_GOOGLE_CLOUD_PROVIDER_KEY, Boolean.TRUE);
detectAzure = agentConfig.getValue(DETECT_AZURE_KEY, Boolean.TRUE);
detectKubernetes = agentConfig.getValue(DETECT_KUBERNETES_KEY, Boolean.TRUE);
dockerData = new DockerData(agentConfig.getCloudConfig());

hostName = Hostname.getHostname(agentConfig);
fullHostName = Hostname.getFullHostname(agentConfig);
Expand Down
8 changes: 8 additions & 0 deletions newrelic-agent/src/main/resources/newrelic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ common: &default_settings
#proxy_password: password
#proxy_scheme: https

# Cloud environment settings for container metadata collection:
# When running in containerized environments (like AWS Fargate) with a proxy,
# metadata endpoints may need to bypass the proxy to be accessible.
#cloud:
# Set to true to bypass proxy for cloud metadata endpoint access.
# Default is false.
#metadata_bypass_proxy: false

# Limits the number of lines to capture for each stack trace.
# Default is 30
max_stack_trace_lines: 30
Expand Down
Loading
Loading