dd-trace-go
dd-trace-go copied to clipboard
[Draft; don't merge] v1 as frontend of v2
What does this PR do?
Turns the current v1 a frontend of v2, wrapping the new API while keeping the original behaviour.
Motivation
Simplify internal testing and future migration to v2.
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 Datadog employees:
- [ ] If this PR touches code that handles credentials of any kind, such as Datadog API keys, I've requested a review from
@DataDog/security-design-and-guidance. - [ ] This PR doesn't touch any of that.
Unsure? Have a question? Request a review!
Notes about benchmarks:
scenario:BenchmarkOTelApiWithCustomTags/datadog_otel_api-24
As reported in March 14:
- ๐ฅ allocations [+3; +3] or [+10.000%; +10.000%]
- ๐ฅ execution_time [+453.667ns; +514.533ns] or [+8.967%; +10.170%]
The extra allocations are:
ApplyV1Optionsadded 2 allocations, one for the anonymous function and another for the v1 ddtrace.StartSpanConfig required. The latter is avoided using a pool. The same applies toApplyV1FinishOptions.- No overhead from v2 detected.
- The execution time overhead may be related to the use of pools (previously it was closer to +5%). Needs further investigation.
scenario:BenchmarkOTelApiWithCustomTags/otel_api-24
- ๐ฅ execution_time [+198.903ns; +282.297ns] or [+2.669%; +3.789%]
- ๐ฉ allocated_mem [-194 bytes; -184 bytes] or [-3.902%; -3.704%]
Execution time is within the acceptable range (below +5%). Reduced memory usage comes from the removal of interfaces in the API. This is consistent with v2 benchmarks.
scenario:BenchmarkStartRequestSpan-24
As reported in March 14:
- ๐ฅ allocated_mem [+8 bytes; +8 bytes] or [+4.545%; +4.545%]
- ๐ฅ allocations [+1; +1] or [+20.000%; +20.000%]
- ๐ฅ execution_time [+19.684ns; +21.716ns] or [+4.938%; +5.447%]
The extra allocation is inevitable. It's the allocation for an anonymous function - returned by ApplyV1Options - that we need to process any v1 StartSpanOption in v2.
We also found that the current implementation of StartSpanConfig.Tags as map[string]interface{} causes a lot of allocations that can be avoided with a design that avoids interface{} as type.
The memory and execution time increases are acceptable, around +5%.
scenario:BenchmarkHttpServeTrace-24
๐ฅ allocated_mem [+4.671KB; +4.698KB] or [+94.121%; +94.667%] ๐ฅ allocations [+33; +33] or [+67.347%; +67.347%] ๐ฅ execution_time [+7.616ยตs; +7.710ยตs] or [+73.904%; +74.817%]
main was using the mocktracer, while v2 uses the real tracer. To avoid measuring different things, we are updating main in this PR.
The rest of benchmarks
After verifying everything works as expected, we conclude that the tracer default config in test is affecting the output of the tests. As this branch has specific details to its tests, we can assume that the real v2 performance is very similar to v1. This is what early benchmarks show in v2-dev.
Benchmarks
Benchmark execution time: 2024-09-18 11:12:35
Comparing candidate commit 3e438864cfdb59e4d21c3bfc6989242b477def5c in PR branch vits with baseline commit 1f0966ddb5080481b80941d8cb0ce0a8ed598b4b in branch main.
Some scenarios are present only in baseline or only in candidate runs. If you didn't create or remove some scenarios in your branch, this maybe a sign of crashed benchmarks ๐ฅ๐ฅ๐ฅ Check Gitlab CI job log to find if any benchmark has crashed.
Scenarios present only in baseline:
- BenchmarkSampleWAFContext-24
Found 10 performance improvements and 32 performance regressions! Performance is the same for 12 metrics, 2 unstable metrics.
scenario:BenchmarkExtractW3C-24
- ๐ฅ
execution_time[+112.075ns; +117.125ns] or [+4.655%; +4.865%]
scenario:BenchmarkHttpServeTrace-24
- ๐ฅ
allocated_mem[+439 bytes; +461 bytes] or [+4.704%; +4.934%] - ๐ฅ
allocations[+4; +4] or [+5.195%; +5.195%] - ๐ฅ
execution_time[+1.143ยตs; +1.252ยตs] or [+7.418%; +8.121%]
scenario:BenchmarkInjectW3C-24
- ๐ฉ
allocated_mem[-800 bytes; -800 bytes] or [-70.922%; -70.922%] - ๐ฉ
allocations[-3; -3] or [-25.000%; -25.000%] - ๐ฉ
execution_time[-2.621ยตs; -2.600ยตs] or [-62.377%; -61.871%]
scenario:BenchmarkOTelApiWithCustomTags/datadog_otel_api-24
- ๐ฅ
allocated_mem[+101 bytes; +112 bytes] or [+2.815%; +3.135%] - ๐ฅ
allocations[+2; +2] or [+6.667%; +6.667%] - ๐ฅ
execution_time[+382.230ns; +413.370ns] or [+7.918%; +8.563%]
scenario:BenchmarkPartialFlushing/Disabled-24
- ๐ฅ
allocated_mem[+13.441MB; +13.667MB] or [+4.169%; +4.239%] - ๐ฅ
allocations[+500815; +503776] or [+15.312%; +15.403%] - ๐ฅ
execution_time[+82.454ms; +94.917ms] or [+30.766%; +35.416%]
scenario:BenchmarkPartialFlushing/Enabled-24
- ๐ฅ
allocations[+491024; +492600] or [+14.961%; +15.009%] - ๐ฅ
execution_time[+84.996ms; +88.757ms] or [+31.136%; +32.514%]
scenario:BenchmarkSetTagMetric-24
- ๐ฉ
execution_time[-88.560ns; -86.744ns] or [-74.489%; -72.962%]
scenario:BenchmarkSetTagString-24
- ๐ฉ
execution_time[-82.951ns; -81.497ns] or [-73.098%; -71.816%]
scenario:BenchmarkSetTagStringPtr-24
- ๐ฉ
allocated_mem[-16 bytes; -16 bytes] or [-100.000%; -100.000%] - ๐ฉ
allocations[-1; -1] or [-100.000%; -100.000%] - ๐ฉ
execution_time[-145.670ns; -143.196ns] or [-82.951%; -81.542%]
scenario:BenchmarkSetTagStringer-24
- ๐ฉ
execution_time[-109.503ns; -107.861ns] or [-78.250%; -77.077%]
scenario:BenchmarkSingleSpanRetention/no-rules-24
- ๐ฅ
allocated_mem[+13.770KB; +13.849KB] or [+8.330%; +8.378%] - ๐ฅ
allocations[+503; +503] or [+35.298%; +35.298%] - ๐ฅ
execution_time[+84.414ยตs; +106.513ยตs] or [+35.675%; +45.015%]
scenario:BenchmarkSingleSpanRetention/with-rules/match-all-24
- ๐ฅ
allocated_mem[+11.096KB; +11.746KB] or [+6.608%; +6.995%] - ๐ฅ
allocations[+503; +503] or [+35.298%; +35.298%] - ๐ฅ
execution_time[+85.530ยตs; +107.291ยตs] or [+35.810%; +44.921%]
scenario:BenchmarkSingleSpanRetention/with-rules/match-half-24
- ๐ฅ
allocated_mem[+11.203KB; +11.842KB] or [+6.675%; +7.056%] - ๐ฅ
allocations[+503; +503] or [+35.298%; +35.298%] - ๐ฅ
execution_time[+82.618ยตs; +104.010ยตs] or [+34.531%; +43.472%]
scenario:BenchmarkStartRequestSpan-24
- ๐ฅ
allocated_mem[+8 bytes; +8 bytes] or [+4.545%; +4.545%] - ๐ฅ
allocations[+1; +1] or [+20.000%; +20.000%] - ๐ฅ
execution_time[+52.378ns; +53.502ns] or [+17.195%; +17.564%]
scenario:BenchmarkStartSpan-24
- ๐ฅ
allocated_mem[+40 bytes; +41 bytes] or [+2.469%; +2.509%] - ๐ฅ
allocations[+2; +2] or [+12.500%; +12.500%] - ๐ฅ
execution_time[+398.690ns; +589.910ns] or [+17.780%; +26.308%]
scenario:BenchmarkStartSpanConcurrent-24
- ๐ฅ
allocated_mem[+369 bytes; +383 bytes] or [+2.243%; +2.326%] - ๐ฅ
allocations[+20; +20] or [+12.500%; +12.500%] - ๐ฉ
execution_time[-952.817ns; -516.383ns] or [-17.938%; -9.722%]
scenario:BenchmarkTracerAddSpans-24
- ๐ฅ
allocated_mem[+285 bytes; +290 bytes] or [+12.475%; +12.708%] - ๐ฅ
allocations[+6; +6] or [+24.000%; +24.000%] - ๐ฅ
execution_time[+1.192ยตs; +1.562ยตs] or [+30.797%; +40.354%]
This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR was closed because it has been open for 30 days with no activity.
This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR was closed because it has been open for 30 days with no activity.