Skip to content

Commit 3d72330

Browse files
authored
DatadogExporter: Add supports for HTTP_PROXY, HTTPS_PROXY and NO_PROXY for logs. (#38076)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Add supports for `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` for logs in `datadogexporter`. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue #36292 Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing - Setup a local proxy - Set `HTTP_PROXY` to the local proxy address - Check proxy didn't receive any payloads when sending logs without the changes from this PR - Check proxy receive a logs payload with the change from this PR <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 9f50349 commit 3d72330

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: datadogexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add supports for HTTP_PROXY, HTTPS_PROXY and NO_PROXY for logs
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [36292]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

exporter/datadogexporter/agent_components.go

+18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
pkgconfigmodel "github.com/DataDog/datadog-agent/pkg/config/model"
1313
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
1414
"go.opentelemetry.io/collector/component"
15+
"golang.org/x/net/http/httpproxy"
1516

1617
pkgdatadog "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog"
1718
)
@@ -52,5 +53,22 @@ func newConfigComponent(set component.TelemetrySettings, cfg *Config) coreconfig
5253
// add logs config pipelines config value, see https://github.com/DataDog/datadog-agent/pull/31190
5354
logsPipelines := min(4, runtime.GOMAXPROCS(0))
5455
pkgconfig.Set("logs_config.pipelines", logsPipelines, pkgconfigmodel.SourceDefault)
56+
setProxyFromEnv(pkgconfig)
57+
5558
return pkgconfig
5659
}
60+
61+
func setProxyFromEnv(config pkgconfigmodel.Config) {
62+
proxyConfig := httpproxy.FromEnvironment()
63+
config.Set("proxy.http", proxyConfig.HTTPProxy, pkgconfigmodel.SourceEnvVar)
64+
config.Set("proxy.https", proxyConfig.HTTPSProxy, pkgconfigmodel.SourceEnvVar)
65+
66+
// If this is set to an empty []string, viper will have a type conflict when merging
67+
// this config during secrets resolution. It unmarshals empty yaml lists to type
68+
// []interface{}, which will then conflict with type []string and fail to merge.
69+
var noProxy []any
70+
for _, v := range strings.Split(proxyConfig.NoProxy, ",") {
71+
noProxy = append(noProxy, v)
72+
}
73+
config.Set("proxy.no_proxy", noProxy, pkgconfigmodel.SourceEnvVar)
74+
}

exporter/datadogexporter/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ require (
9595
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog v0.120.1
9696
go.opentelemetry.io/collector/component/componenttest v0.120.1-0.20250224010654-18e18b21da7a
9797
go.opentelemetry.io/collector/exporter/exportertest v0.120.1-0.20250224010654-18e18b21da7a
98+
golang.org/x/net v0.35.0
9899
)
99100

100101
require (
@@ -411,7 +412,6 @@ require (
411412
golang.org/x/crypto v0.33.0 // indirect
412413
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
413414
golang.org/x/mod v0.23.0 // indirect
414-
golang.org/x/net v0.35.0 // indirect
415415
golang.org/x/oauth2 v0.26.0 // indirect
416416
golang.org/x/sync v0.11.0 // indirect
417417
golang.org/x/sys v0.30.0 // indirect

0 commit comments

Comments
 (0)