Skip to content

Commit

Permalink
Revive linter placeholders for APM
Browse files Browse the repository at this point in the history
  • Loading branch information
KSerrania authored and dd-mergequeue[bot] committed Dec 5, 2023
1 parent 29e28ca commit 324b029
Show file tree
Hide file tree
Showing 56 changed files with 132 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmd/trace-agent/command/command.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.

//nolint:revive // TODO(APM) Fix revive linter
package command

import (
Expand Down
7 changes: 4 additions & 3 deletions cmd/trace-agent/command/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (
// - display warnings when deprecated flags are encountered
func FixDeprecatedFlags(args []string, w io.Writer) []string {
var (
replacePid = cli.ReplaceFlagExact("--pidfile")
replaceInfo = cli.ReplaceFlagExact("info")
replaceVersion = cli.ReplaceFlagExact("version")
replacePid = cli.ReplaceFlagExact("--pidfile")
replaceInfo = cli.ReplaceFlagExact("info")
replaceVersion = cli.ReplaceFlagExact("version")
//nolint:revive // TODO(APM) Fix revive linter
replaceCpuProfile = cli.ReplaceFlagExact("--cpu-profile")
replaceMemProfile = cli.ReplaceFlagExact("--mem-profile")
)
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/config/remote/config.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.

//nolint:revive // TODO(APM) Fix revive linter
package remote

import (
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/internal/flags/flags_z.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.

//nolint:revive // TODO(APM) Fix revive linter
package flags

// Win holds a set of flags which will be populated only during the Windows build.
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/internal/osutil/osutil.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.

//nolint:revive // TODO(APM) Fix revive linter
package osutil

import (
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/main.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.

//nolint:revive // TODO(APM) Fix revive linter
package main

import (
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/subcommands/info/command.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.

//nolint:revive // TODO(APM) Fix revive linter
package info

import (
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/subcommands/params.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.

//nolint:revive // TODO(APM) Fix revive linter
package subcommands

// GlobalParams contains the values of agent-global Cobra flags.
Expand Down
2 changes: 2 additions & 0 deletions cmd/trace-agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
//
//nolint:revive // TODO(APM) Fix revive linter
package run

import (
Expand Down
2 changes: 2 additions & 0 deletions cmd/trace-agent/subcommands/run/command_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/DataDog/datadog-agent/cmd/trace-agent/subcommands"
)

//nolint:revive // TODO(APM) Fix revive linter
type RunParams struct {
*subcommands.GlobalParams

Expand All @@ -26,6 +27,7 @@ type RunParams struct {
MemProfile string
}

//nolint:revive // TODO(APM) Fix revive linter
func setOSSpecificParamFlags(cmd *cobra.Command, cliParams *RunParams) {}

func runTraceAgent(cliParams *RunParams, defaultConfPath string) error {
Expand Down
1 change: 1 addition & 0 deletions cmd/trace-agent/subcommands/run/command_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/spf13/cobra"
)

//nolint:revive // TODO(APM) Fix revive linter
type RunParams struct {
*subcommands.GlobalParams

Expand Down
4 changes: 2 additions & 2 deletions cmd/trace-agent/windows/controlsvc/controlsvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ func StopService() error {
var err error
if err = winutil.StopService(config.ServiceName); err != nil {
return fmt.Errorf("error stopping service %v", err)
} else {
} else { //nolint:revive // TODO(APM) Fix revive linter
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err = winutil.WaitForState(ctx, config.ServiceName, svc.Stopped); err != nil {
if errors.Is(err, context.DeadlineExceeded) {
return fmt.Errorf("timed out waiting for %s service to stop", config.ServiceName)
} else {
} else { //nolint:revive // TODO(APM) Fix revive linter
return fmt.Errorf("error stopping service %v", err)
}
}
Expand Down
1 change: 1 addition & 0 deletions comp/trace/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
corecomp "github.com/DataDog/datadog-agent/comp/core/config"
coreconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/trace/config"
//nolint:revive // TODO(APM) Fix revive linter
traceconfig "github.com/DataDog/datadog-agent/pkg/trace/config"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
"github.com/DataDog/datadog-agent/pkg/util/log"
Expand Down
3 changes: 3 additions & 0 deletions comp/trace/config/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/config/remote"
"github.com/DataDog/datadog-agent/pkg/config/remote/data"
"github.com/DataDog/datadog-agent/pkg/config/utils"
//nolint:revive // TODO(APM) Fix revive linter
configUtils "github.com/DataDog/datadog-agent/pkg/config/utils"
pbgo "github.com/DataDog/datadog-agent/pkg/proto/pbgo/core"
"github.com/DataDog/datadog-agent/pkg/tagger"
Expand Down Expand Up @@ -55,6 +56,7 @@ const (
rcClientPollInterval = time.Second * 1
)

//nolint:revive // TODO(APM) Fix revive linter
func setupConfigCommon(deps dependencies, apikey string) (*config.AgentConfig, error) {
confFilePath := deps.Config.ConfigFileUsed()

Expand Down Expand Up @@ -93,6 +95,7 @@ func prepareConfig(c corecompcfg.Component) (*config.AgentConfig, error) {
// TODO: do not interface directly with pkg/config anywhere
coreConfigObject := c.Object()
if coreConfigObject == nil {
//nolint:revive // TODO(APM) Fix revive linter
return nil, fmt.Errorf("No core config found! Bailing out.")
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/collector/corechecks/embed/apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

//go:build apm && !windows && !linux

//nolint:revive // TODO(APM) Fix revive linter
package embed

import (
Expand Down Expand Up @@ -145,6 +146,8 @@ func (c *APMCheck) run() error {
}

// Configure the APMCheck
//
//nolint:revive // TODO(APM) Fix revive linter
func (c *APMCheck) Configure(senderManager sender.SenderManager, integrationConfigDigest uint64, data integration.Data, initConfig integration.Data, source string) error {
var checkConf apmCheckConf
if err := yaml.Unmarshal(data, &checkConf); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/obfuscate/json_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ func stateNul(s *scanner, c byte) int {

// stateError is the state after reaching a syntax error,
// such as after reading `[1}` or `5.1.2`.
//
//nolint:revive // TODO(APM) Fix revive linter
func stateError(s *scanner, c byte) int {
return scanError
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/obfuscate/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ func obfuscateRedisCmd(out *strings.Builder, cmd string, args ...string) {

// removeAllRedisArgs will take in a command and obfuscate all arguments following
// the command, regardless of if the command is valid Redis or not
//
//nolint:revive // TODO(APM) Fix revive linter
func (*Obfuscator) RemoveAllRedisArgs(rediscmd string) string {
fullCmd := strings.Fields(rediscmd)
if len(fullCmd) == 0 {
Expand Down
1 change: 1 addition & 0 deletions pkg/obfuscate/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,7 @@ func TestCassQuantizer(t *testing.T) {
}
}

//nolint:revive // TODO(APM) Fix revive linter
func TestUnicodeDigit(t *testing.T) {
hangStr := "٩"
o := NewObfuscator(Config{})
Expand Down
5 changes: 5 additions & 0 deletions pkg/obfuscate/sql_tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func (tkn *SQLTokenizer) scanIdentifier() (TokenKind, []byte) {
return ID, t
}

//nolint:revive // TODO(APM) Fix revive linter
func (tkn *SQLTokenizer) scanVariableIdentifier(prefix rune) (TokenKind, []byte) {
for tkn.advance(); tkn.lastChar != ')' && tkn.lastChar != EndChar; tkn.advance() {
}
Expand All @@ -622,6 +623,7 @@ func (tkn *SQLTokenizer) scanVariableIdentifier(prefix rune) (TokenKind, []byte)
return Variable, tkn.bytes()
}

//nolint:revive // TODO(APM) Fix revive linter
func (tkn *SQLTokenizer) scanFormatParameter(prefix rune) (TokenKind, []byte) {
tkn.advance()
return Variable, tkn.bytes()
Expand Down Expand Up @@ -675,6 +677,7 @@ func (tkn *SQLTokenizer) scanDollarQuotedString() (TokenKind, []byte) {
return DollarQuotedString, buf.Bytes()
}

//nolint:revive // TODO(APM) Fix revive linter
func (tkn *SQLTokenizer) scanPreparedStatement(prefix rune) (TokenKind, []byte) {
// a prepared statement expect a digit identifier like $1
if !isDigit(tkn.lastChar) {
Expand All @@ -692,6 +695,7 @@ func (tkn *SQLTokenizer) scanPreparedStatement(prefix rune) (TokenKind, []byte)
return PreparedStatement, buff
}

//nolint:revive // TODO(APM) Fix revive linter
func (tkn *SQLTokenizer) scanEscapeSequence(braces rune) (TokenKind, []byte) {
for tkn.lastChar != '}' && tkn.lastChar != EndChar {
tkn.advance()
Expand Down Expand Up @@ -821,6 +825,7 @@ func (tkn *SQLTokenizer) scanString(delim rune, kind TokenKind) (TokenKind, []by
return kind, buf.Bytes()
}

//nolint:revive // TODO(APM) Fix revive linter
func (tkn *SQLTokenizer) scanCommentType1(prefix string) (TokenKind, []byte) {
for tkn.lastChar != EndChar {
if tkn.lastChar == '\n' {
Expand Down
2 changes: 1 addition & 1 deletion pkg/proto/pbgo/trace/span_gen.go

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

1 change: 1 addition & 0 deletions pkg/proto/pbgo/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (p *TracerPayload) Cut(i int) *TracerPayload {
if i > len(p.Chunks) {
i = len(p.Chunks)
}
//nolint:revive // TODO(APM) Fix revive linter
new := TracerPayload{
ContainerID: p.GetContainerID(),
LanguageName: p.GetLanguageName(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/trace/agent/agent.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.

//nolint:revive // TODO(APM) Fix revive linter
package agent

import (
Expand Down Expand Up @@ -413,6 +414,7 @@ func processedTrace(p *api.Payload, chunk *pb.TraceChunk, root *pb.Span) *traceu
// The underlying array behind TracePayload.Chunks points to unsampled chunks
// preventing them from being collected by the GC.
func newChunksArray(chunks []*pb.TraceChunk) []*pb.TraceChunk {
//nolint:revive // TODO(APM) Fix revive linter
new := make([]*pb.TraceChunk, len(chunks))
copy(new, chunks)
return new
Expand Down
3 changes: 3 additions & 0 deletions pkg/trace/api/api.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.

//nolint:revive // TODO(APM) Fix revive linter
package api

import (
Expand Down Expand Up @@ -575,6 +576,8 @@ func droppedTracesFromHeader(h http.Header, ts *info.TagStats) int64 {
}

// handleServices handle a request with a list of several services
//
//nolint:revive // TODO(APM) Fix revive linter
func (r *HTTPReceiver) handleServices(v Version, w http.ResponseWriter, req *http.Request) {
httpOK(w)

Expand Down
1 change: 1 addition & 0 deletions pkg/trace/api/api_oom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestOOMKill(t *testing.T) {
r.Start()
defer r.Stop()
go func() {
//nolint:revive // TODO(APM) Fix revive linter
for range r.out {
}
}()
Expand Down
1 change: 1 addition & 0 deletions pkg/trace/api/apiutil/limited_reader.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.

//nolint:revive // TODO(APM) Fix revive linter
package apiutil

import (
Expand Down
3 changes: 3 additions & 0 deletions pkg/trace/api/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
)

// connContext is unimplemented for non-linux builds.
//
//nolint:revive // TODO(APM) Fix revive linter
func connContext(ctx context.Context, c net.Conn) context.Context {
return ctx
}
Expand All @@ -32,6 +34,7 @@ func NewIDProvider(_ string) IDProvider {
return &idProvider{}
}

//nolint:revive // TODO(APM) Fix revive linter
func (_ *idProvider) GetContainerID(_ context.Context, h http.Header) string {
return h.Get(header.ContainerID)
}
3 changes: 3 additions & 0 deletions pkg/trace/api/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ func ensureKeys(expect, result map[string]interface{}, prefix string) error {
if prefix != "" {
path = prefix + "." + k
}
//nolint:revive // TODO(APM) Fix revive linter
return fmt.Errorf("Expected key %s, but it is not present in the output.\n", path)
}

if em, ok := ev.(map[string]interface{}); ok {
rm, ok := rv.(map[string]interface{})
if !ok {
//nolint:revive // TODO(APM) Fix revive linter
return fmt.Errorf("Expected key %s to be a map, but it is '%#v'.\n", k, rv)
}
if prefix != "" {
Expand All @@ -59,6 +61,7 @@ func ensureKeys(expect, result map[string]interface{}, prefix string) error {
if prefix != "" {
path = prefix + "." + k
}
//nolint:revive // TODO(APM) Fix revive linter
return fmt.Errorf("Found key %s, but it is not expected in the output. If you've added a new key to the /info endpoint, please add it to the tests.\n", path)
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/trace/api/internal/header/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// Copyright 2016-present Datadog, Inc.

// package header defines HTTP headers known convention used by the Trace Agent and Datadog's APM intake.
//
//nolint:revive // TODO(APM) Fix revive linter
package header

const (
Expand Down Expand Up @@ -55,6 +57,7 @@ const (
// If both agent and client have the same version, the agent won't return rates in API response.
RatesPayloadVersion = "Datadog-Rates-Payload-Version"

//nolint:revive // TODO(APM) Fix revive linter
// SendTrueHTTPStatus can be sent by the client to signal to the agent that
// it wants to receive the "real" status in the response. By default, the agent
// will send a 200 OK response for every payload, even those dropped due to
Expand Down
3 changes: 2 additions & 1 deletion pkg/trace/api/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (c *onCloseConn) Close() error {
return err
}

//nolint:revive // TODO(APM) Fix revive linter
func OnCloseConn(c net.Conn, onclose func()) net.Conn {
return &onCloseConn{c, onclose, sync.Once{}}
}
Expand Down Expand Up @@ -225,7 +226,7 @@ func (sl *rateLimitedListener) Accept() (net.Conn, error) {
if ne.Temporary() {
// deadline expired; continue
continue
} else {
} else { //nolint:revive // TODO(APM) Fix revive linter
// don't count temporary errors; they usually signify expired deadlines
// see (golang/go/src/internal/poll/fd.go).TimeoutError
sl.timedout.Inc()
Expand Down
1 change: 1 addition & 0 deletions pkg/trace/config/client.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.

//nolint:revive // TODO(APM) Fix revive linter
package config

import (
Expand Down
Loading

0 comments on commit 324b029

Please sign in to comment.