Skip to content

Commit

Permalink
fix auto multi-line integration config (#17447)
Browse files Browse the repository at this point in the history
* fix auto multi-line integration config

* reno

* update tests
  • Loading branch information
gh123man authored Jun 4, 2023
1 parent 3723c72 commit 2ecf2ae
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
34 changes: 20 additions & 14 deletions pkg/logs/internal/launchers/container/tailerfactory/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ func (tf *factory) makeDockerFileSource(source *sources.LogSource) (*sources.Log

// New file source that inherits most of its parent's properties
fileSource := sources.NewLogSource(source.Name, &config.LogsConfig{
Type: config.FileType,
Identifier: containerID,
Path: path,
Service: serviceName,
Source: sourceName,
Tags: source.Config.Tags,
ProcessingRules: source.Config.ProcessingRules,
Type: config.FileType,
Identifier: containerID,
Path: path,
Service: serviceName,
Source: sourceName,
Tags: source.Config.Tags,
ProcessingRules: source.Config.ProcessingRules,
AutoMultiLine: source.Config.AutoMultiLine,
AutoMultiLineSampleSize: source.Config.AutoMultiLineSampleSize,
AutoMultiLineMatchThreshold: source.Config.AutoMultiLineMatchThreshold,
})

// inform the file launcher that it should expect docker-formatted content
Expand Down Expand Up @@ -203,13 +206,16 @@ func (tf *factory) makeK8sFileSource(source *sources.LogSource) (*sources.LogSou
fileSource := sources.NewLogSource(
fmt.Sprintf("%s/%s/%s", pod.Namespace, pod.Name, container.Name),
&config.LogsConfig{
Type: config.FileType,
Identifier: containerID,
Path: path,
Service: serviceName,
Source: sourceName,
Tags: source.Config.Tags,
ProcessingRules: source.Config.ProcessingRules,
Type: config.FileType,
Identifier: containerID,
Path: path,
Service: serviceName,
Source: sourceName,
Tags: source.Config.Tags,
ProcessingRules: source.Config.ProcessingRules,
AutoMultiLine: source.Config.AutoMultiLine,
AutoMultiLineSampleSize: source.Config.AutoMultiLineSampleSize,
AutoMultiLineMatchThreshold: source.Config.AutoMultiLineMatchThreshold,
})

switch source.Config.Type {
Expand Down
33 changes: 23 additions & 10 deletions pkg/logs/internal/launchers/container/tailerfactory/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
"github.com/DataDog/datadog-agent/pkg/logs/sources"
dockerutilPkg "github.com/DataDog/datadog-agent/pkg/util/docker"
"github.com/DataDog/datadog-agent/pkg/util/pointer"
"github.com/DataDog/datadog-agent/pkg/workloadmeta"
)

Expand Down Expand Up @@ -85,11 +86,14 @@ func TestMakeFileSource_docker_success(t *testing.T) {
cop: containersorpods.NewDecidedChooser(containersorpods.LogContainers),
}
source := sources.NewLogSource("test", &config.LogsConfig{
Type: "docker",
Identifier: "abc",
Source: "src",
Service: "svc",
Tags: []string{"tag!"},
Type: "docker",
Identifier: "abc",
Source: "src",
Service: "svc",
Tags: []string{"tag!"},
AutoMultiLine: pointer.Ptr(true),
AutoMultiLineSampleSize: 123,
AutoMultiLineMatchThreshold: 0.123,
})
child, err := tf.makeFileSource(source)
require.NoError(t, err)
Expand All @@ -101,6 +105,9 @@ func TestMakeFileSource_docker_success(t *testing.T) {
require.Equal(t, source.Config.Service, child.Config.Service)
require.Equal(t, source.Config.Tags, child.Config.Tags)
require.Equal(t, sources.DockerSourceType, child.GetSourceType())
require.Equal(t, *source.Config.AutoMultiLine, true)
require.Equal(t, source.Config.AutoMultiLineSampleSize, 123)
require.Equal(t, source.Config.AutoMultiLineMatchThreshold, 0.123)
}

func TestMakeFileSource_docker_no_file(t *testing.T) {
Expand Down Expand Up @@ -179,11 +186,14 @@ func TestMakeK8sSource(t *testing.T) {
for _, sourceConfigType := range []string{"docker", "containerd"} {
t.Run("source.Config.Type="+sourceConfigType, func(t *testing.T) {
source := sources.NewLogSource("test", &config.LogsConfig{
Type: sourceConfigType,
Identifier: "abc",
Source: "src",
Service: "svc",
Tags: []string{"tag!"},
Type: sourceConfigType,
Identifier: "abc",
Source: "src",
Service: "svc",
Tags: []string{"tag!"},
AutoMultiLine: pointer.Ptr(true),
AutoMultiLineSampleSize: 123,
AutoMultiLineMatchThreshold: 0.123,
})
child, err := tf.makeK8sFileSource(source)
require.NoError(t, err)
Expand All @@ -194,6 +204,9 @@ func TestMakeK8sSource(t *testing.T) {
require.Equal(t, "src", child.Config.Source)
require.Equal(t, "svc", child.Config.Service)
require.Equal(t, []string{"tag!"}, child.Config.Tags)
require.Equal(t, *child.Config.AutoMultiLine, true)
require.Equal(t, child.Config.AutoMultiLineSampleSize, 123)
require.Equal(t, child.Config.AutoMultiLineMatchThreshold, 0.123)
switch sourceConfigType {
case "docker":
require.Equal(t, sources.DockerSourceType, child.GetSourceType())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
fixes:
- |
Fix an issue where ``auto_multi_line_detection``, ``auto_multi_line_sample_size``,
and ``auto_multi_line_match_threshold`` were not working when set though a pod
annotation or container label.

0 comments on commit 2ecf2ae

Please sign in to comment.