diff --git a/telemetry/client.go b/telemetry/client.go index 6a3eb9a2..e4a45529 100644 --- a/telemetry/client.go +++ b/telemetry/client.go @@ -9,6 +9,7 @@ import ( "log" "net" "net/http" + "net/url" "os" "strings" "time" @@ -52,6 +53,33 @@ func New(functionName string, licenseKey string, telemetryEndpointOverride strin Timeout: httpClientTimeout, } + 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 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 )