Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion comp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Package orchestratorinterface defines the interface for the orchestrator forward

*Datadog Team*: agent-log-pipelines


Package logs provides the logs component bundle

### [comp/logs/adscheduler](https://pkg.go.dev/github.com/DataDog/datadog-agent/comp/logs/adscheduler)

Expand Down
2 changes: 1 addition & 1 deletion comp/logs/agent/config/channel_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package config provides log configuration structures and utilities
package config

import "time"
Expand Down
3 changes: 1 addition & 2 deletions comp/logs/agent/config/integration_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ type LogsConfig struct {
ExcludePaths StringSliceField `mapstructure:"exclude_paths" json:"exclude_paths" yaml:"exclude_paths"` // File
TailingMode string `mapstructure:"start_position" json:"start_position" yaml:"start_position"` // File

//nolint:revive // TODO(AML) Fix revive linter
ConfigId string `mapstructure:"config_id" json:"config_id" yaml:"config_id"` // Journald
ConfigID string `mapstructure:"config_id" json:"config_id" yaml:"config_id"` // Journald
IncludeSystemUnits StringSliceField `mapstructure:"include_units" json:"include_units" yaml:"include_units"` // Journald
ExcludeSystemUnits StringSliceField `mapstructure:"exclude_units" json:"exclude_units" yaml:"exclude_units"` // Journald
IncludeUserUnits StringSliceField `mapstructure:"include_user_units" json:"include_user_units" yaml:"include_user_units"` // Journald
Expand Down
2 changes: 1 addition & 1 deletion comp/logs/agent/config/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ logs:
assert.Equal(t, "utf-8", config.Encoding)
require.Equal(t, len(config.ExcludePaths), 2)
assert.Equal(t, "beginning", config.TailingMode)
assert.Equal(t, "test_config_id", config.ConfigId)
assert.Equal(t, "test_config_id", config.ConfigID)
require.Equal(t, len(config.IncludeSystemUnits), 1)
require.Equal(t, len(config.ExcludeSystemUnits), 3)
require.Equal(t, len(config.IncludeUserUnits), 1)
Expand Down
6 changes: 4 additions & 2 deletions comp/logs/agent/flare/flare_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive
// Package flare provides log flare collection functionality for diagnostics
package flare

import (
Expand All @@ -17,6 +17,8 @@ import (

// FlareController is a type that contains information needed to insert into a
// flare from the logs agent.
//
//nolint:revive // exported: ignore package name struct conflict
type FlareController struct {
mu sync.Mutex
allFiles []string
Expand Down Expand Up @@ -77,7 +79,7 @@ func (fc *FlareController) SetAllFiles(files []string) {
fc.allFiles = files
}

// SetAllJournalFiles assigns the journalFiles parameter of FlareController
// AddToJournalFiles assigns the journalFiles parameter of FlareController
func (fc *FlareController) AddToJournalFiles(files []string) {
fc.mu.Lock()
defer fc.mu.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion comp/logs/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package logs //nolint:revive // TODO(AML) Fix revive linter
// Package logs provides the logs component bundle
package logs

import (
"github.com/DataDog/datadog-agent/comp/logs/agent/agentimpl"
Expand Down
3 changes: 2 additions & 1 deletion comp/logs/bundle_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

//go:build test

package logs //nolint:revive // TODO(AML) Fix revive linter
// Package logs provides the logs component bundle with mock implementations
package logs

import (
"github.com/DataDog/datadog-agent/comp/logs/agent/agentimpl"
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/client/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package client provides log destination client functionality
package client

import (
Expand Down
41 changes: 18 additions & 23 deletions pkg/logs/client/http/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
package http

import (
Expand Down Expand Up @@ -58,10 +57,8 @@ var (
expVarInUseMsMapKey = "inUseMs"
)

// emptyJsonPayload is an empty payload used to check HTTP connectivity without sending logs.
//
//nolint:revive // TODO(AML) Fix revive linter
var emptyJsonPayload = message.Payload{MessageMetas: []*message.MessageMetadata{}, Encoded: []byte("{}")}
// emptyJSONPayload is an empty payload used to check HTTP connectivity without sending logs.
var emptyJSONPayload = message.Payload{MessageMetas: []*message.MessageMetadata{}, Encoded: []byte("{}")}

type destinationResult struct {
latency time.Duration
Expand Down Expand Up @@ -185,11 +182,11 @@ func newDestination(endpoint config.Endpoint,
func errorToTag(err error) string {
if err == nil {
return "none"
} else if _, ok := err.(*client.RetryableError); ok {
}
if _, ok := err.(*client.RetryableError); ok {
return "retryable"
} else {
return "non-retryable"
}
return "non-retryable"
}

// IsMRF indicates that this destination is a Multi-Region Failover destination.
Expand Down Expand Up @@ -378,8 +375,8 @@ func (d *Destination) unconditionalSend(payload *message.Payload) (err error) {
}
log.Tracef("Log payload sent to %s. Response resolved with protocol %s in %d ms", d.url, resp.Proto, latency)

metrics.DestinationHttpRespByStatusAndUrl.Add(strconv.Itoa(resp.StatusCode), 1)
metrics.TlmDestinationHttpRespByStatusAndUrl.Inc(strconv.Itoa(resp.StatusCode), d.url)
metrics.DestinationHTTPRespByStatusAndURL.Add(strconv.Itoa(resp.StatusCode), 1)
metrics.TlmDestinationHTTPRespByStatusAndURL.Inc(strconv.Itoa(resp.StatusCode), d.url)

if resp.StatusCode >= http.StatusBadRequest {
log.Warnf("failed to post http payload. code=%d, url=%s, EvP track type=%s, content type=%s, EvP category=%s, origin=%s, response=%s", resp.StatusCode, d.url, d.endpoint.TrackType, d.contentType, d.destMeta.EvpCategory(), d.origin, string(response))
Expand All @@ -396,10 +393,9 @@ func (d *Destination) unconditionalSend(payload *message.Payload) (err error) {
// the server could not serve the request, most likely because of an
// internal error. We should retry these requests.
return client.NewRetryableError(errServer)
} else {
d.pipelineMonitor.ReportComponentEgress(payload, d.destMeta.MonitorTag(), d.instanceID)
return nil
}
d.pipelineMonitor.ReportComponentEgress(payload, d.destMeta.MonitorTag(), d.instanceID)
return nil
}

func (d *Destination) updateRetryState(err error, isRetrying chan bool) bool {
Expand All @@ -414,15 +410,14 @@ func (d *Destination) updateRetryState(err error, isRetrying chan bool) bool {
d.lastRetryError = err

return true
} else { //nolint:revive // TODO(AML) Fix revive linter
d.nbErrors = d.backoff.DecError(d.nbErrors)
if isRetrying != nil && d.lastRetryError != nil {
isRetrying <- false
}
d.lastRetryError = nil

return false
}
d.nbErrors = d.backoff.DecError(d.nbErrors)
if isRetrying != nil && d.lastRetryError != nil {
isRetrying <- false
}
d.lastRetryError = nil

return false
}

func httpClientFactory(cfg pkgconfigmodel.Reader, timeoutOverride time.Duration) func() *http.Client {
Expand Down Expand Up @@ -505,7 +500,7 @@ func prepareCheckConnectivity(endpoint config.Endpoint, cfg pkgconfigmodel.Reade
func completeCheckConnectivity(ctx *client.DestinationsContext, destination *Destination) error {
ctx.Start()
defer ctx.Stop()
return destination.unconditionalSend(&emptyJsonPayload)
return destination.unconditionalSend(&emptyJSONPayload)
}

// CheckConnectivity check if sending logs through HTTP works
Expand All @@ -522,7 +517,7 @@ func CheckConnectivity(endpoint config.Endpoint, cfg pkgconfigmodel.Reader) conf
return err == nil
}

//nolint:revive // TODO(AML) Fix revive linter
// CheckConnectivityDiagnose checks HTTP connectivity to an endpoint and returns the URL and any errors for diagnostic purposes
func CheckConnectivityDiagnose(endpoint config.Endpoint, cfg pkgconfigmodel.Reader) (url string, err error) {
ctx, destination := prepareCheckConnectivity(endpoint, cfg)
return destination.url, completeCheckConnectivity(ctx, destination)
Expand Down
2 changes: 0 additions & 2 deletions pkg/logs/client/http/destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func TestBuildURLPathPrefixV1(t *testing.T) {
assert.Equal(t, "https://foo:8080/prefix/url/v1/input", url)
}

//nolint:revive // TODO(AML) Fix revive linter
func TestDestinationSend200(t *testing.T) {
cfg := configmock.New(t)
server := NewTestServer(200, cfg)
Expand Down Expand Up @@ -105,7 +104,6 @@ func TestNoRetries(t *testing.T) {
testNoRetry(t, 413)
}

//nolint:revive // TODO(AML) Fix revive linter
func testNoRetry(t *testing.T, statusCode int) {
cfg := configmock.New(t)
server := NewTestServer(statusCode, cfg)
Expand Down
1 change: 0 additions & 1 deletion pkg/logs/client/http/sync_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
package http

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/client/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package mock provides mock utilities for testing log clients
package mock

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/client/tcp/connection_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package tcp provides TCP connection management for log clients
package tcp

import (
Expand Down
1 change: 0 additions & 1 deletion pkg/logs/diagnostic/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type logFormatter struct {
hostname hostnameinterface.Component
}

//nolint:revive // TODO(AML) Fix revive linter
func (l *logFormatter) Format(m *message.Message, _ string, redactedMsg []byte) string {
hname, err := l.hostname.Get(context.TODO())
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/logs/internal/decoder/auto_multiline_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

// Package decoder provides log line decoding and parsing functionality
package decoder

import (
Expand Down
1 change: 0 additions & 1 deletion pkg/logs/internal/decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/DataDog/datadog-agent/comp/logs/agent/config"
//nolint:revive // TODO(AML) Fix revive linter
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"github.com/DataDog/datadog-agent/pkg/logs/internal/framer"
"github.com/DataDog/datadog-agent/pkg/logs/internal/parsers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
package decoder

import (
Expand Down
8 changes: 4 additions & 4 deletions pkg/logs/internal/framer/framer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"strings"
"testing"

"github.com/DataDog/datadog-agent/pkg/logs/message"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/DataDog/datadog-agent/pkg/logs/message"
)

const contentLenLimit = 256000
Expand All @@ -39,10 +40,9 @@ func chunk(input []byte, size int) [][]byte {
if size <= len(iter) {
rv = append(rv, iter)
break
} else { //nolint:revive // TODO(AML) Fix revive linter
rv = append(rv, iter[:size])
iter = iter[size:]
}
rv = append(rv, iter[:size])
iter = iter[size:]
}
return rv
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/logs/internal/framer/no_framing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ package framer
type noFramingMatcher struct{}

// FindFrame considers the given bytes buffer as one full frame.
//
//nolint:revive // TODO(AML) Fix revive linter
func (m *noFramingMatcher) FindFrame(buf []byte, _ int) ([]byte, int) {
return buf, len(buf)
}
2 changes: 1 addition & 1 deletion pkg/logs/internal/parsers/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package kubernetes provides Kubernetes log format parsing
package kubernetes

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/internal/tag/local_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package tag provides tags for log sources
package tag

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/internal/util/adlistener/ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package adlistener provides autodiscovery event listener utilities
package adlistener

import (
Expand Down
1 change: 0 additions & 1 deletion pkg/logs/internal/util/adlistener/ad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
)

//nolint:revive // TODO(AML) Fix revive linter
func TestListenersGetScheduleCalls(t *testing.T) {
adsched := scheduler.NewControllerAndStart()
ac := fxutil.Test[autodiscovery.Mock](t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package containersorpods provides logic to choose between logging containers or pods
package containersorpods

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/internal/util/moving_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package util provides internal utility functions for logs
package util

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logs/launchers/channel/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
// Package channel provides channel-based log launchers
package channel

import (
Expand Down
Loading