From 7b87ce3dff799d9e31132d2a67d563ea8e456a2b Mon Sep 17 00:00:00 2001 From: Saket Chaudhary Date: Fri, 18 Jul 2025 13:23:07 +0530 Subject: [PATCH 1/3] add proxy for transport --- telemetry/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telemetry/client.go b/telemetry/client.go index 6a3eb9a2..7fc76c43 100644 --- a/telemetry/client.go +++ b/telemetry/client.go @@ -50,6 +50,9 @@ type Client struct { func New(functionName string, licenseKey string, telemetryEndpointOverride string, logEndpointOverride string, batch *Batch, collectTraceID bool, clientTimeout time.Duration) *Client { httpClient := &http.Client{ Timeout: httpClientTimeout, + Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, + }, } // Create random seed for timeout to avoid instances created at the same time From 4347b4143a3b9251602c23c4322d730747af882c Mon Sep 17 00:00:00 2001 From: Saket Chaudhary Date: Fri, 18 Jul 2025 14:02:38 +0530 Subject: [PATCH 2/3] update extension version --- util/extension.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/extension.go b/util/extension.go index 5dc1cb6e..19825a9b 100644 --- a/util/extension.go +++ b/util/extension.go @@ -2,6 +2,6 @@ package util const ( Name = "newrelic-lambda-extension" - Version = "2.3.23" + Version = "2.3.24" Id = Name + ":" + Version ) From a140647d6962854b62ab1065742e0259613dc4e0 Mon Sep 17 00:00:00 2001 From: Saket Chaudhary Date: Fri, 8 Aug 2025 01:22:04 +0530 Subject: [PATCH 3/3] update proxy --- telemetry/client.go | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/telemetry/client.go b/telemetry/client.go index 7fc76c43..e4a45529 100644 --- a/telemetry/client.go +++ b/telemetry/client.go @@ -9,6 +9,7 @@ import ( "log" "net" "net/http" + "net/url" "os" "strings" "time" @@ -50,11 +51,35 @@ type Client struct { func New(functionName string, licenseKey string, telemetryEndpointOverride string, logEndpointOverride string, batch *Batch, collectTraceID bool, clientTimeout time.Duration) *Client { httpClient := &http.Client{ Timeout: httpClientTimeout, - Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, - }, } + proxyUser := os.Getenv("NEW_RELIC_PROXY_USER") + proxyPass := os.Getenv("NEW_RELIC_PROXY_PASS") + authProxyHost := os.Getenv("NEW_RELIC_PROXY_HOST") + authProxyPort := os.Getenv("NEW_RELIC_PROXY_PORT") + if authProxyHost == "" { + authProxyHost = os.Getenv("HTTPS_PROXY") + } + if authProxyHost != "" { + util.Debugf("Proxy host found: %s. Configuring Extension to use proxy.\n", authProxyHost) + proxyAddress := authProxyHost + if authProxyPort != "" { + proxyAddress = fmt.Sprintf("%s:%s", authProxyHost, authProxyPort) + } + var authProxyStr string + if proxyUser != "" { + authProxyStr = fmt.Sprintf("http://%s:%s@%s", proxyUser, proxyPass, proxyAddress) + } else { + authProxyStr = fmt.Sprintf("http://%s", proxyAddress) + } + authProxyURL, err := url.Parse(authProxyStr) + if err != nil { + log.Fatalf("Failed to parse authenticated proxy URL from env: %v", err) + } + httpClient.Transport = &http.Transport{ + Proxy: http.ProxyURL(authProxyURL), + } + } // Create random seed for timeout to avoid instances created at the same time // from creating a wall of retry requests to the collector var b [8]byte