Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/setup-go-5…
Browse files Browse the repository at this point in the history
….2.0
  • Loading branch information
chouetz authored Dec 18, 2024
2 parents d07c256 + 919ff87 commit 6a20799
Show file tree
Hide file tree
Showing 84 changed files with 1,331 additions and 428 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@

/.gitlab/package_build/ @DataDog/agent-delivery
/.gitlab/package_build/windows.yml @DataDog/agent-delivery @DataDog/windows-agent
/.gitlab/package_build/installer.yml @DataDog/agent-delivery @DataDog/fleet
/.gitlab/packaging/ @DataDog/agent-delivery

/.gitlab/benchmarks/benchmarks.yml @DataDog/agent-apm
Expand Down
7 changes: 2 additions & 5 deletions .gitlab/common/test_infra_version.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
variables:
# To use images from test-infra-definitions dev branches, set the SUFFIX variable to -dev
# and check the job creating the image to make sure you have the right SHA prefix
TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX: ""
# Make sure to update test-infra-definitions version in go.mod as well
TEST_INFRA_DEFINITIONS_BUILDIMAGES: 6459608ed9fa
TEST_INFRA_DEFINITIONS_BUILDIMAGES: 221bbc806266
TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX: ''
4 changes: 2 additions & 2 deletions Dockerfiles/agent-ot/Dockerfile.agent-otel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG AGENT_VERSION=7.57.0-v1.0-ot-beta-jmx
ARG AGENT_BRANCH=7.57.x-otel-beta-v1
ARG AGENT_VERSION=7.59.0-v1.1.0-ot-beta-jmx
ARG AGENT_BRANCH=7.59.x
# Use the Ubuntu Slim AMD64 base image
FROM ubuntu:24.04 AS builder

Expand Down
3 changes: 0 additions & 3 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2906,9 +2906,6 @@ core,google.golang.org/protobuf/types/known/timestamppb,BSD-3-Clause,Copyright (
core,google.golang.org/protobuf/types/known/wrapperspb,BSD-3-Clause,Copyright (c) 2018 The Go Authors. All rights reserved
core,google.golang.org/protobuf/types/pluginpb,BSD-3-Clause,Copyright (c) 2018 The Go Authors. All rights reserved
core,gopkg.in/DataDog/dd-trace-go.v1/appsec/events,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/contrib/internal/httptrace,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/contrib/internal/options,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/datastreams/options,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/ddtrace,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
core,gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext,Apache-2.0,"Copyright 2016-Present Datadog, Inc."
Expand Down
6 changes: 3 additions & 3 deletions cmd/installer-downloader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func main() {
ctx := context.Background()

t := telemetry.NewTelemetry(env.HTTPClient(), env.APIKey, env.Site, fmt.Sprintf("datadog-installer-downloader-%s", Flavor))
_ = t.Start(ctx)
defer func() { _ = t.Stop(ctx) }()
var err error
span, ctx := telemetry.StartSpanFromEnv(ctx, fmt.Sprintf("downloader-%s", Flavor))
defer func() { span.Finish(err) }()
err = runDownloader(ctx, env, Version, Flavor)

span.Finish(err)
t.Stop()
if err != nil {
fmt.Fprintf(os.Stderr, "Installation failed: %v\n", err)
os.Exit(1)
Expand Down
12 changes: 2 additions & 10 deletions cmd/installer/subcommands/installer/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func UnprivilegedCommands(_ *command.GlobalParams) []*cobra.Command {
type cmd struct {
t *telemetry.Telemetry
ctx context.Context
span telemetry.Span
span *telemetry.Span
env *env.Env
}

Expand All @@ -107,10 +107,7 @@ func newCmd(operation string) *cmd {
func (c *cmd) Stop(err error) {
c.span.Finish(err)
if c.t != nil {
err := c.t.Stop(context.Background())
if err != nil {
fmt.Fprintf(os.Stderr, "failed to stop telemetry: %v\n", err)
}
c.t.Stop()
}
}

Expand Down Expand Up @@ -225,11 +222,6 @@ func newTelemetry(env *env.Env) *telemetry.Telemetry {
site = config.Site
}
t := telemetry.NewTelemetry(env.HTTPClient(), apiKey, site, "datadog-installer") // No sampling rules for commands
err := t.Start(context.Background())
if err != nil {
fmt.Printf("failed to start telemetry: %v\n", err)
return nil
}
return t
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/installer/subcommands/installer/umask_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// setInstallerUmask sets umask 0 to override any inherited umask
func setInstallerUmask(span telemetry.Span) {
func setInstallerUmask(span *telemetry.Span) {
oldmask := syscall.Umask(0)
span.SetTag("inherited_umask", oldmask)
}
2 changes: 1 addition & 1 deletion cmd/installer/subcommands/installer/umask_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ package installer
import "github.com/DataDog/datadog-agent/pkg/fleet/telemetry"

// setInstallerUmask no-op on Windows
func setInstallerUmask(_ telemetry.Span) {}
func setInstallerUmask(_ *telemetry.Span) {}
15 changes: 14 additions & 1 deletion cmd/otel-agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface"
"github.com/DataDog/datadog-agent/comp/core/hostname/remotehostnameimpl"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
logfx "github.com/DataDog/datadog-agent/comp/core/log/fx"
logtracefx "github.com/DataDog/datadog-agent/comp/core/log/fx-trace"
"github.com/DataDog/datadog-agent/comp/core/secrets"
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
Expand Down Expand Up @@ -106,8 +107,20 @@ func runOTelAgentCommand(ctx context.Context, params *subcommands.GlobalParams,
fx.Provide(func() coreconfig.Component {
return acfg
}),
fx.Provide(func(_ coreconfig.Component) log.Params {
return log.ForDaemon(params.LoggerName, "log_file", pkgconfigsetup.DefaultOTelAgentLogFile)
}),
logfx.Module(),
fetchonlyimpl.Module(),
// TODO: don't rely on this pattern; remove this `OptionalModuleWithParams` thing
// and instead adapt OptionalModule to allow parameter passing naturally.
// See: https://github.com/DataDog/datadog-agent/pull/28386
configsyncimpl.OptionalModuleWithParams(),
fx.Provide(func() configsyncimpl.Params {
return configsyncimpl.NewParams(params.SyncTimeout, params.SyncDelay, true)
}),
converterfx.Module(),
fx.Provide(func(cp converter.Component) confmap.Converter {
fx.Provide(func(cp converter.Component, _ optional.Option[configsync.Component]) confmap.Converter {
return cp
}),
collectorcontribFx.Module(),
Expand Down
2 changes: 1 addition & 1 deletion cmd/trace-agent/config/remote/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func putBuffer(buffer *bytes.Buffer) {

// ConfigHandler is the HTTP handler for configs
func ConfigHandler(r *api.HTTPReceiver, cf rcclient.ConfigFetcher, cfg *config.AgentConfig, statsd statsd.ClientInterface, timing timing.Reporter) http.Handler {
cidProvider := api.NewIDProvider(cfg.ContainerProcRoot)
cidProvider := api.NewIDProvider(cfg.ContainerProcRoot, cfg.ContainerIDFromOriginInfo)
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
defer timing.Since("datadog.trace_agent.receiver.config_process_ms", time.Now())
tags := r.TagStats(api.V07, req.Header, "").AsTags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,22 @@ func (wcd *AgentCrashDetect) Run() error {
}

log.Infof("Sending crash: %v", formatText(crash))
lts := internaltelemetry.NewClient(wcd.tconfig.NewHTTPClient(), wcd.tconfig.TelemetryConfig.Endpoints, "ddnpm", true)
lts := internaltelemetry.NewClient(wcd.tconfig.NewHTTPClient(), toTelemEndpoints(wcd.tconfig.TelemetryConfig.Endpoints), "ddnpm", true)
lts.SendLog("WARN", formatText(crash))
return nil
}

func toTelemEndpoints(endpoints []*traceconfig.Endpoint) []*internaltelemetry.Endpoint {
telemEndpoints := make([]*internaltelemetry.Endpoint, 0, len(endpoints))
for _, e := range endpoints {
telemEndpoints = append(telemEndpoints, &internaltelemetry.Endpoint{
Host: e.Host,
APIKey: e.APIKey,
})
}
return telemEndpoints
}

func newAgentCrashComponent(deps dependencies) agentcrashdetect.Component {
instance := &agentCrashComponent{}
instance.tconfig = deps.TConfig.Object()
Expand Down
2 changes: 2 additions & 0 deletions comp/core/tagger/collectors/pod_tag_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func (p *PodTagExtractor) Extract(podEntity *workloadmeta.KubernetesPod, cardina
return append(tagInfos.LowCardTags, tagInfos.OrchestratorCardTags...)
case types.LowCardinality:
return tagInfos.LowCardTags
case types.NoneCardinality:
return []string{}
default:
log.Errorf("unsupported tag cardinality %v", cardinality)
return []string{}
Expand Down
5 changes: 2 additions & 3 deletions comp/core/tagger/impl/tagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (t *TaggerWrapper) EnrichTags(tb tagset.TagsAccumulator, originInfo taggert
// | none | empty || empty |
// | empty | not empty || container prefix + originFromMsg |
// | none | not empty || container prefix + originFromMsg |
if t.datadogConfig.dogstatsdOptOutEnabled && originInfo.Cardinality == "none" {
if t.datadogConfig.dogstatsdOptOutEnabled && originInfo.Cardinality == types.NoneCardinalityString {
originInfo.ContainerIDFromSocket = packets.NoOrigin
originInfo.PodUID = ""
originInfo.ContainerID = ""
Expand Down Expand Up @@ -460,8 +460,7 @@ func (t *TaggerWrapper) EnrichTags(tb tagset.TagsAccumulator, originInfo taggert
}
default:
// Disable origin detection if cardinality is none
// TODO: The `none` cardinality should be directly supported by the Tagger.
if originInfo.Cardinality == "none" {
if originInfo.Cardinality == types.NoneCardinalityString {
originInfo.ContainerIDFromSocket = packets.NoOrigin
originInfo.PodUID = ""
originInfo.ContainerID = ""
Expand Down
37 changes: 37 additions & 0 deletions comp/core/tagger/subscriber/subscription_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ func TestSubscriptionManager(t *testing.T) {

highCardSubscription.Unsubscribe()

// None Cardinality Subscriber
noneCardSubID := "none-card-sub"
noneCardSubscription, err := sm.Subscribe(noneCardSubID, types.NewFilterBuilder().Include(types.EntityIDPrefix("foo")).Build(types.NoneCardinality), nil)
require.NoError(t, err)

sm.Notify([]types.EntityEvent{
events["added"],
events["modified"],
events["deleted"],
events["added-with-no-id"],
events["added-with-unmatched-prefix"],
})

noneCardSubscription.Unsubscribe()

// Verify low cardinality subscriber received events
assertReceivedEvents(t, lowCardSubscription.EventsChan(), []types.EntityEvent{
{
Expand Down Expand Up @@ -192,6 +207,28 @@ func TestSubscriptionManager(t *testing.T) {
},
},
})

// Verify none cardinality subscriber received events
assertReceivedEvents(t, noneCardSubscription.EventsChan(), []types.EntityEvent{
{
EventType: types.EventTypeAdded,
Entity: types.Entity{
ID: entityID,
},
},
{
EventType: types.EventTypeModified,
Entity: types.Entity{
ID: entityID,
},
},
{
EventType: types.EventTypeDeleted,
Entity: types.Entity{
ID: entityID,
},
},
})
}

func assertReceivedEvents(t *testing.T, ch chan []types.EntityEvent, expectedEvents []types.EntityEvent) {
Expand Down
12 changes: 9 additions & 3 deletions comp/core/tagger/tagstore/entity_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,16 @@ func (e *EntityTagsWithMultipleSources) getStandard() []string {
func (e *EntityTagsWithMultipleSources) getHashedTags(cardinality types.TagCardinality) tagset.HashedTags {
e.computeCache()

if cardinality == types.HighCardinality {
switch cardinality {
case types.HighCardinality:
return e.cachedAll
} else if cardinality == types.OrchestratorCardinality {
case types.OrchestratorCardinality:
return e.cachedOrchestrator
case types.NoneCardinality:
return tagset.HashedTags{}
default:
return e.cachedLow
}
return e.cachedLow
}

func (e *EntityTagsWithMultipleSources) computeCache() {
Expand Down Expand Up @@ -302,6 +306,8 @@ func (e *EntityTagsWithSingleSource) getHashedTags(cardinality types.TagCardinal
return e.cachedAll
case types.OrchestratorCardinality:
return e.cachedOrchestrator
case types.NoneCardinality:
return tagset.HashedTags{}
default:
return e.cachedLow
}
Expand Down
6 changes: 6 additions & 0 deletions comp/core/tagger/tagstore/entity_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func TestGetHashedTags(t *testing.T) {
[]string{"l1:v1", "l2:v2", "service:s1", "o1:v1", "o2:v2", "h1:v1", "h2:v2"},
entityTags.getHashedTags(types.HighCardinality).Get(),
)

assert.Equal(
t,
[]string(nil),
entityTags.getHashedTags(types.NoneCardinality).Get(),
)
}

func TestTagsForSource(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions comp/core/tagger/tagstore/tagstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ func (s *StoreTestSuite) TestLookup() {
tagsHigh := s.tagstore.Lookup(entityID, types.HighCardinality)
tagsOrch := s.tagstore.Lookup(entityID, types.OrchestratorCardinality)
tagsLow := s.tagstore.Lookup(entityID, types.LowCardinality)
tagsNone := s.tagstore.Lookup(entityID, types.NoneCardinality)

assert.Len(s.T(), tagsHigh, 4)
assert.Len(s.T(), tagsLow, 2)
assert.Len(s.T(), tagsOrch, 3)
assert.Nil(s.T(), tagsNone)
}

func (s *StoreTestSuite) TestLookupHashedWithEntityStr() {
Expand All @@ -118,10 +120,12 @@ func (s *StoreTestSuite) TestLookupHashedWithEntityStr() {
tagsLow := s.tagstore.LookupHashedWithEntityStr(entityID, types.LowCardinality)
tagsOrch := s.tagstore.LookupHashedWithEntityStr(entityID, types.OrchestratorCardinality)
tagsHigh := s.tagstore.LookupHashedWithEntityStr(entityID, types.HighCardinality)
tagsNone := s.tagstore.LookupHashedWithEntityStr(entityID, types.NoneCardinality)

assert.ElementsMatch(s.T(), tagsLow.Get(), []string{"low1", "low2"})
assert.ElementsMatch(s.T(), tagsOrch.Get(), []string{"low1", "low2", "orchestrator1"})
assert.ElementsMatch(s.T(), tagsHigh.Get(), []string{"low1", "low2", "orchestrator1", "high1"})
assert.ElementsMatch(s.T(), tagsNone.Get(), []string{})
}

func (s *StoreTestSuite) TestLookupStandard() {
Expand Down
4 changes: 4 additions & 0 deletions comp/core/tagger/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Store struct {
LowCardinalityQueries CardinalityTelemetry
OrchestratorCardinalityQueries CardinalityTelemetry
HighCardinalityQueries CardinalityTelemetry
NoneCardinalityQueries CardinalityTelemetry
UnknownCardinalityQueries CardinalityTelemetry
}

Expand Down Expand Up @@ -144,6 +145,7 @@ func NewStore(telemetryComp telemetry.Component) *Store {
LowCardinalityQueries: newCardinalityTelemetry(queries, types.LowCardinalityString),
OrchestratorCardinalityQueries: newCardinalityTelemetry(queries, types.OrchestratorCardinalityString),
HighCardinalityQueries: newCardinalityTelemetry(queries, types.HighCardinalityString),
NoneCardinalityQueries: newCardinalityTelemetry(queries, types.NoneCardinalityString),
UnknownCardinalityQueries: newCardinalityTelemetry(queries, types.UnknownCardinalityString),
}
})
Expand All @@ -160,6 +162,8 @@ func (s *Store) QueriesByCardinality(card types.TagCardinality) *CardinalityTele
return &s.OrchestratorCardinalityQueries
case types.HighCardinality:
return &s.HighCardinalityQueries
case types.NoneCardinality:
return &s.NoneCardinalityQueries
default:
return &s.UnknownCardinalityQueries
}
Expand Down
16 changes: 16 additions & 0 deletions comp/core/tagger/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const (
LowCardinality TagCardinality = iota
OrchestratorCardinality
HighCardinality
NoneCardinality
)

// Entity is an entity ID + tags.
Expand All @@ -92,6 +93,10 @@ type Entity struct {
// GetTags flattens all tags from all cardinalities into a single slice of tag
// strings.
func (e Entity) GetTags(cardinality TagCardinality) []string {
if cardinality == NoneCardinality {
return []string{}
}

tagArrays := make([][]string, 0, 3)
tagArrays = append(tagArrays, e.LowCardinalityTags)

Expand All @@ -117,6 +122,11 @@ func (e Entity) Copy(cardinality TagCardinality) Entity {
case LowCardinality:
newEntity.HighCardinalityTags = nil
newEntity.OrchestratorCardinalityTags = nil
case NoneCardinality:
newEntity.HighCardinalityTags = nil
newEntity.OrchestratorCardinalityTags = nil
newEntity.LowCardinalityTags = nil
newEntity.StandardTags = nil
}

return newEntity
Expand All @@ -131,6 +141,8 @@ const (
ShortOrchestratorCardinalityString = "orch"
// HighCardinalityString is the string representation of the high cardinality
HighCardinalityString = "high"
// NoneCardinalityString is the string representation of the none cardinality
NoneCardinalityString = "none"
// UnknownCardinalityString represents an unknown level of cardinality
UnknownCardinalityString = "unknown"
)
Expand All @@ -145,6 +157,8 @@ func StringToTagCardinality(c string) (TagCardinality, error) {
return OrchestratorCardinality, nil
case LowCardinalityString:
return LowCardinality, nil
case NoneCardinalityString:
return NoneCardinality, nil
default:
return LowCardinality, fmt.Errorf("unsupported value %s received for tag cardinality", c)
}
Expand All @@ -160,6 +174,8 @@ func TagCardinalityToString(c TagCardinality) string {
return OrchestratorCardinalityString
case LowCardinality:
return LowCardinalityString
case NoneCardinality:
return NoneCardinalityString
default:
return UnknownCardinalityString
}
Expand Down
Loading

0 comments on commit 6a20799

Please sign in to comment.