Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/datadog] Upgrade exporter.datadogexporter.UseLogsAgentExporter feature flag to beta #34420

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
27 changes: 27 additions & 0 deletions .chloggen/stanley.liu_logs-agent-beta.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: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Use Datadog Agent logs pipeline by default for exporting logs to Datadog. Upgrades `exporter.datadogexporter.UseLogsAgentExporter` feature flag to beta.

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

# (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: []
8 changes: 4 additions & 4 deletions exporter/datadogexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,20 @@ type LogsConfig struct {
confignet.TCPAddrConfig `mapstructure:",squash"`

// DumpPayloads report whether payloads should be dumped when logging level is debug.
// Note: this config option does not apply when enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is enabled (now enabled by default).
DumpPayloads bool `mapstructure:"dump_payloads"`

// UseCompression enables the logs agent to compress logs before sending them.
// Note: this config option does not apply unless enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
UseCompression bool `mapstructure:"use_compression"`

// CompressionLevel accepts values from 0 (no compression) to 9 (maximum compression but higher resource usage).
// Only takes effect if UseCompression is set to true.
// Note: this config option does not apply unless enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
CompressionLevel int `mapstructure:"compression_level"`

// BatchWait represents the maximum time the logs agent waits to fill each batch of logs before sending.
// Note: this config option does not apply unless enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
BatchWait int `mapstructure:"batch_wait"`
}

Expand Down
8 changes: 4 additions & 4 deletions exporter/datadogexporter/examples/collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,28 +457,28 @@ exporters:
## If set to true, payloads will be dumped when logging level is set to debug. Please note that
## This may result in an escaping loop if a filelog receiver is watching the collector log output.
## See: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16380
## Note: this config option does not apply when enabling `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
## Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is enabled (now enabled by default).
#
# dump_payloads: false

## @param use_compression - boolean - optional - default: true
## This parameter is available when sending logs with HTTPS. If enabled, the logs agent
## compresses logs before sending them.
## Note: this config option does not apply unless enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
## Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
#
# use_compression: true

## @param compression_level - integer - optional - default: 6
## The compression_level parameter accepts values from 0 (no compression)
## to 9 (maximum compression but higher resource usage). Only takes effect if
## `use_compression` is set to `true`.
## Note: this config option does not apply unless enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
## Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
#
# compression_level: 6

## @param batch_wait - integer - optional - default: 5
## The maximum time the logs agent waits to fill each batch of logs before sending.
## Note: this config option does not apply unless enabling the `exporter.datadogexporter.UseLogsAgentExporter` feature flag.
## Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
#
# batch_wait: 5

Expand Down
2 changes: 1 addition & 1 deletion exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

var logsAgentExporterFeatureGate = featuregate.GlobalRegistry().MustRegister(
"exporter.datadogexporter.UseLogsAgentExporter",
featuregate.StageAlpha,
featuregate.StageBeta,
featuregate.WithRegisterDescription("When enabled, datadogexporter uses the Datadog agent logs pipeline for exporting logs."),
featuregate.WithRegisterFromVersion("v0.100.0"),
)
Expand Down
69 changes: 8 additions & 61 deletions exporter/datadogexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,67 +123,6 @@ func TestCreateDefaultConfig(t *testing.T) {
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
}

// Test that the factory creates the default configuration
func TestCreateDefaultConfigLogsAgent(t *testing.T) {
songy23 marked this conversation as resolved.
Show resolved Hide resolved
err := featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", true)
assert.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

assert.Equal(t, &Config{
ClientConfig: defaultClientConfig(),
BackOffConfig: configretry.NewDefaultBackOffConfig(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),

API: APIConfig{
Site: "datadoghq.com",
},

Metrics: MetricsConfig{
TCPAddrConfig: confignet.TCPAddrConfig{
Endpoint: "https://api.datadoghq.com",
},
DeltaTTL: 3600,
HistConfig: HistogramConfig{
Mode: "distributions",
SendAggregations: false,
},
SumConfig: SumConfig{
CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta,
InitialCumulativeMonotonicMode: InitialValueModeAuto,
},
SummaryConfig: SummaryConfig{
Mode: SummaryModeGauges,
},
},

Traces: TracesConfig{
TCPAddrConfig: confignet.TCPAddrConfig{
Endpoint: "https://trace.agent.datadoghq.com",
},
IgnoreResources: []string{},
},
Logs: LogsConfig{
TCPAddrConfig: confignet.TCPAddrConfig{
Endpoint: "https://http-intake.logs.datadoghq.com",
},
UseCompression: true,
CompressionLevel: 6,
BatchWait: 5,
},

HostMetadata: HostMetadataConfig{
Enabled: true,
HostnameSource: HostnameSourceConfigOrSystem,
},
OnlyMetadata: false,
}, cfg, "failed to create default config")

assert.NoError(t, componenttest.CheckConfigStruct(cfg))
err = featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", false)
assert.NoError(t, err)
}

func TestLoadConfig(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -500,6 +439,8 @@ func TestCreateAPIMetricsExporter(t *testing.T) {
}

func TestCreateAPIExporterFailOnInvalidKey_Zorkian(t *testing.T) {
featuregateErr := featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", false)
assert.NoError(t, featuregateErr)
server := testutil.DatadogServerMock(testutil.ValidateAPIKeyEndpointInvalid)
defer server.Close()

Expand Down Expand Up @@ -577,9 +518,13 @@ func TestCreateAPIExporterFailOnInvalidKey_Zorkian(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, lexp)
})
featuregateErr = featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", true)
assert.NoError(t, featuregateErr)
}

func TestCreateAPIExporterFailOnInvalidKey(t *testing.T) {
featuregateErr := featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", false)
assert.NoError(t, featuregateErr)
server := testutil.DatadogServerMock(testutil.ValidateAPIKeyEndpointInvalid)
defer server.Close()

Expand Down Expand Up @@ -657,6 +602,8 @@ func TestCreateAPIExporterFailOnInvalidKey(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, lexp)
})
featuregateErr = featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", true)
assert.NoError(t, featuregateErr)
}

func TestCreateAPILogsExporter(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,6 @@ func TestIntegrationLogs(t *testing.T) {
t.Setenv("SERVER_URL", server.URL)

// 2. Start in-process collector
assert.NoError(t, featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", true))
defer func() {
assert.NoError(t, featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", false))
}()
factories := getIntegrationTestComponents(t)
app := getIntegrationTestCollector(t, "integration_test_logs_config.yaml", factories)
go func() {
Expand Down
6 changes: 4 additions & 2 deletions exporter/datadogexporter/logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func TestLogsExporter(t *testing.T) {
},
},
}
featuregateErr := featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", false)
assert.NoError(t, featuregateErr)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
server := testutil.DatadogLogServerMock()
Expand All @@ -238,6 +240,8 @@ func TestLogsExporter(t *testing.T) {
assert.Equal(t, tt.want, server.LogsData)
})
}
featuregateErr = featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", true)
assert.NoError(t, featuregateErr)
}

func TestLogsAgentExporter(t *testing.T) {
Expand Down Expand Up @@ -497,8 +501,6 @@ func TestLogsAgentExporter(t *testing.T) {
},
},
}
err := featuregate.GlobalRegistry().Set("exporter.datadogexporter.UseLogsAgentExporter", true)
assert.NoError(t, err)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
doneChannel := make(chan bool)
Expand Down