Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poc(ddtrace/tracer): migrate tracer config to knobs #3030

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

darccio
Copy link
Member

@darccio darccio commented Dec 11, 2024

What does this PR do?

Proof of concept using github.com/darccio/knobs proposal for describing configuration.

This PR depends on changes available in this PR's branch: darccio/knobs#5

Motivation

R&D week!

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.
  • 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.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@darccio darccio changed the title POC(ddtrace/tracer): migrate partialFlushMinSpans & partialFlushEnabled to knobs poc(ddtrace/tracer): migrate partialFlushMinSpans & partialFlushEnabled to knobs Dec 12, 2024
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Dec 12, 2024

Datadog Report

Branch report: rdw/knobs-poc
Commit report: c63aeb3
Test service: dd-trace-go

✅ 0 Failed, 5110 Passed, 67 Skipped, 2m 26.53s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Dec 12, 2024

Benchmarks

Benchmark execution time: 2024-12-13 14:40:31

Comparing candidate commit 6bacb78 in PR branch rdw/knobs-poc with baseline commit 79a1f60 in branch main.

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

scenario:BenchmarkPartialFlushing/Disabled-24

  • 🟥 execution_time [+26.918ms; +29.357ms] or [+9.981%; +10.886%]

scenario:BenchmarkPartialFlushing/Enabled-24

  • 🟥 execution_time [+33.414ms; +36.937ms] or [+12.103%; +13.379%]

scenario:BenchmarkSetTagStringer-24

  • 🟥 execution_time [+4.277ns; +8.783ns] or [+3.030%; +6.221%]

scenario:BenchmarkSingleSpanRetention/no-rules-24

  • 🟥 execution_time [+29.448µs; +30.245µs] or [+12.478%; +12.815%]

scenario:BenchmarkSingleSpanRetention/with-rules/match-all-24

  • 🟥 execution_time [+29.486µs; +30.481µs] or [+12.410%; +12.829%]

scenario:BenchmarkSingleSpanRetention/with-rules/match-half-24

  • 🟥 execution_time [+29.294µs; +30.011µs] or [+12.335%; +12.637%]

scenario:BenchmarkStartSpan-24

  • 🟥 execution_time [+90.313ns; +127.887ns] or [+4.039%; +5.720%]

scenario:BenchmarkStartSpanConcurrent-24

  • 🟥 execution_time [+1.220µs; +1.486µs] or [+22.603%; +27.534%]

scenario:BenchmarkTracerAddSpans-24

  • 🟥 execution_time [+147.017ns; +217.783ns] or [+3.729%; +5.524%]

@darccio darccio changed the title poc(ddtrace/tracer): migrate partialFlushMinSpans & partialFlushEnabled to knobs poc(ddtrace/tracer): migrate tracer config to knobs Dec 12, 2024
@darccio darccio force-pushed the rdw/knobs-poc branch 2 times, most recently from 7f88f14 to f03ee9d Compare December 12, 2024 17:27
Comment on lines 312 to 316
Parse: func(s string) (bool, error) {
if s == "" {
return true, nil
}
v, err := strconv.ParseBool(s)
if err != nil {
return true, err
}
return v, nil
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use knobs.ToBool here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because strconv.ParseBool("") returns an error, and it felt like a hidden behaviour.

Parse: func(v string) (int, error) {
i, _ := strconv.Atoi(v)
if i <= 0 {
log.Warn("DD_TRACE_PARTIAL_FLUSH_MIN_SPANS=%d is not a valid value, setting to default %d", i, 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

A thought about knobs that's been made clear by this example: the fact that the error log is so specific to environment variables makes me wonder again whether Parse should really be on EnvVar instead of Definition...

Copy link
Member Author

Choose a reason for hiding this comment

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

I see what you mean. We can leave Parse for general use - for any possible string source - and recommend using Transform for this kind of logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

First issue: all the logic in that Parse function is coupled with the float parsing. So, the only issue is that logging messages 😁 This reinforces the idea of having some kind of validation function, and also delegating logging to Parse's caller.

Transform: mapSampleRate,
},
},
Resolve: func(environ map[string]string, decision string) (string, error) {
Copy link
Member Author

@darccio darccio Dec 13, 2024

Choose a reason for hiding this comment

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

@mtoffl01 As you already saw, I took the liberty to create a Resolve function implementing what we discussed offline. This Resolve allows to do extra validations in the whole context, but also potentially overriding what environment variable should be used.

BTW, I'm open to better naming 😆

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.

2 participants