Skip to content

Commit

Permalink
[exporter/datadog] Use correct hostname for logs in logs agent pipeli…
Browse files Browse the repository at this point in the history
…ne (#35058)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Includes bug fix from
DataDog/datadog-agent#28870. In gateway
deployments using the logs agent feature gate, some logs may be
associated with the hostname of the gateway collector instead of the
host sending the logs. This fixes this issue by explicitly assigning the
mapped log hostname.

**Link to tracking Issue:** <Issue number if applicable>

**Testing:** <Describe what testing was performed and which tests were
added.>

Performed manual tests and added unit test.

**Documentation:** <Describe the documentation added.>
  • Loading branch information
liustanley authored Sep 9, 2024
1 parent 248b8ec commit 0ceefaa
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 24 deletions.
27 changes: 27 additions & 0 deletions .chloggen/stanley.liu_fix-logs-hostname.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datadogexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Use correct hostname for logs when using Datadog Agent logs pipeline with a gateway deployment.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [35058]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
4 changes: 2 additions & 2 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ require (
github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline/logsagentpipelineimpl v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.58.0-devel.0.20240905201012-b02662b2ba27 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/statsprocessor v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/def v0.56.2 // indirect
Expand Down Expand Up @@ -830,7 +830,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions connector/datadogconnector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline/logsagentpipelineimpl v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.58.0-devel.0.20240905201012-b02662b2ba27 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/def v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.2 // indirect
Expand Down Expand Up @@ -271,7 +271,7 @@ require (
go.uber.org/dig v1.17.1 // indirect
go.uber.org/fx v1.18.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.24.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions connector/datadogconnector/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions exporter/datadogexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline/logsagentpipelineimpl v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.58.0-devel.0.20240905201012-b02662b2ba27
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient v0.56.2
github.com/DataDog/datadog-agent/comp/otelcol/otlp/testutil v0.57.0-devel.0.20240718200853-81bf3b2e412d
github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.56.2
Expand Down Expand Up @@ -362,7 +362,7 @@ require (
go.uber.org/fx v1.18.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions exporter/datadogexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions exporter/datadogexporter/integrationtest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/DataDog/datadog-agent/comp/logs/agent/config v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline/logsagentpipelineimpl v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.58.0-devel.0.20240905201012-b02662b2ba27 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/statsprocessor v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/def v0.56.2 // indirect
Expand Down Expand Up @@ -338,7 +338,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions exporter/datadogexporter/integrationtest/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions exporter/datadogexporter/logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ func TestLogsAgentExporter(t *testing.T) {
ldd := lrr.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0)
ldd.Attributes().PutStr("attr", "hello")
ldd.Attributes().PutStr("service.name", "service")
ldd.Attributes().PutStr("host.name", "test-host")
return lrr
}(),
retry: false,
Expand All @@ -318,6 +319,8 @@ func TestLogsAgentExporter(t *testing.T) {
"attr": "hello",
"service": "service",
"service.name": "service",
"host.name": "test-host",
"hostname": "test-host",
},
"ddsource": "otlp_log_ingestion",
"ddtags": "otel_source:datadog_exporter",
Expand Down

0 comments on commit 0ceefaa

Please sign in to comment.