Skip to content

Support file-based configurations (Phase 1)#3438

Merged
mtoffl01 merged 43 commits into
mainfrom
mtoff/v2-stable_cfg_1
May 27, 2025
Merged

Support file-based configurations (Phase 1)#3438
mtoffl01 merged 43 commits into
mainfrom
mtoff/v2-stable_cfg_1

Conversation

@mtoffl01

@mtoffl01 mtoffl01 commented Apr 15, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Support reading product-enablement configurations from user-managed (/etc/datadog-agent/application_monitoring.yaml) and fleet-managed (/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml) yaml files for dd-trace-go. In-scope configurations include:

  • DD_APM_TRACING_ENABLED
  • DD_RUNTIME_METRICS_ENABLED
  • DD_LOGS_INJECTION
  • DD_PROFILING_ENABLED
  • DD_DATA_STREAMS_ENABLED
  • DD_APPSEC_ENABLED
  • DD_IAST_ENABLED
  • DD_DYNAMIC_INSTRUMENTATION_ENABLED
  • DD_DATA_JOBS_ENABLED
  • DD_APPSEC_SCA_ENABLED
  • DD_TRACE_DEBUG

RFC: Stable Configuration Phase 1

Notes

  • All TODOs for APMAPI-1358 are just markers for the next phase of work, where we report Origin to telemetry.
  • Orchestrion support/tests are out of scope for this PR.

Testing

This PR passes all system-tests as per: DataDog/system-tests#4604. To pass the system-tests, I had to update the startup log to include data streams info.

Motivation

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running golangci-lint run locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 15, 2025

Copy link
Copy Markdown

Datadog Report

Branch report: mtoff/v2-stable_cfg_1
Commit report: 2809bc1
Test service: dd-trace-go

✅ 0 Failed, 4562 Passed, 65 Skipped, 3m 16.41s Total Time

@pr-commenter

pr-commenter Bot commented Apr 15, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-05-27 20:29:50

Comparing candidate commit 631d655 in PR branch mtoff/v2-stable_cfg_1 with baseline commit 1d6075b in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 21 metrics, 0 unstable metrics.

Comment thread internal/stableconfig/api.go Outdated
"github.com/DataDog/dd-trace-go/v2/internal/telemetry"
)

func BoolStableConfig(env string, def bool) (value bool, origin telemetry.Origin, err error) {

@mtoffl01 mtoffl01 Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should BoolStableConfig and StringStableConfig live in internal/env.go instead?

@mtoffl01
mtoffl01 force-pushed the mtoff/v2-stable_cfg_1 branch from 0435678 to d8fb6c4 Compare May 7, 2025 16:41
@mtoffl01
mtoffl01 marked this pull request as ready for review May 7, 2025 20:28
@mtoffl01
mtoffl01 requested review from a team as code owners May 7, 2025 20:28
Comment thread profiler/options.go

@nsrip-dd nsrip-dd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for the profiling portion of the change. Let me know if you want me to take a closer look at the rest.

Comment thread profiler/options.go
Comment thread internal/stableconfig/api.go

@eliottness eliottness left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work. Excited to test it 👍

Comment on lines +19 to +20
localFilePath = "/etc/datadog-agent/application_monitoring.yaml"
managedFilePath = "/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on Windows ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Support is for linux, only (ref). Thanks to your comment, I've now called this out on line 19.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably warrant a test or at least a manual check in our windows CI to make we dont spit any uncomprehensible errors/logs for windows users. If it is the case then adding a if runtime.GOOS == "linux" somewhere could be something. WDYT ?

Comment thread internal/stableconfig/api.go Outdated
Comment thread internal/stableconfig/api.go Outdated
if val, err := strconv.ParseBool(v); err == nil {
return val, o, nil
}
err = fmt.Errorf("non-boolean value for %s: '%s' in %s configuration, dropping", env, v, o)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say it makes sense to use errors.Join if there is multiple errors here.
Also maybe adding a special case to not report an error if val is an empty string can also make sense I believe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to have functions for duration, for int, for float and for net.IP to cover all cases that where previously convered by internal/env.go?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also wondering if we should call telemetry.RegisterAppConfig directly here. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eliottness ,

Would it be possible to have functions for duration, for int, for float and for net.IP...

Yes, I will add this in a separate PR, so that this work is not blocked! #3537

I am also wondering if we should call telemetry.RegisterAppConfig directly here. What do you think?

Good idea. Telemetry will be added in a separate PR, as part of Phase "1.5," also scheduled for this quarter (by contrast, sourcing stable configurations is "Phase 1").

@mtoffl01
mtoffl01 requested a review from eliottness May 21, 2025 11:12
@mtoffl01
mtoffl01 force-pushed the mtoff/v2-stable_cfg_1 branch from 3076429 to a49337b Compare May 27, 2025 19:54
@mtoffl01
mtoffl01 merged commit 0c7fa4b into main May 27, 2025
@mtoffl01
mtoffl01 deleted the mtoff/v2-stable_cfg_1 branch May 27, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants