Commit ee1fdc0
authored
fix(tracer): pass prioritySampler in agentTraceWriter benchmarks to prevent nil panic (#4601)
<!--
* New contributors are highly encouraged to read our
[CONTRIBUTING](/CONTRIBUTING.md) documentation.
* Commit and PR titles should be prefixed with the general area of the pull request's change.
-->
### What does this PR do?
Provides the agentTraceWriters used in writer_bench_test.go with a real prioritySampler, instead of nil.
### Motivation
I noticed `BenchmarkAgentTraceWriterFlush` panicking with a nil pointer dereference because `newAgentTraceWriter` was called with a `nil` prioritySampler. This panics because, after a successful flush, the writer calls `prioritySampling.readRatesJSON`, which dereferences the `nil`. Passing `newPrioritySampler()` in all benchmark constructors avoids the panic and matches how the writer is created in production.
### Reviewer's Checklist
<!--
* Authors can use this list as a reference to ensure that there are no problems
during the review but the signing off is to be done by the reviewer(s).
-->
- [ ] Changed code has unit tests for its functionality at or near 100% coverage.
- [ ] [System-Tests](https://github.com/DataDog/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 `make lint` locally.
- [ ] New code doesn't break existing tests. You can check this by running `make test` locally.
- [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
- [ ] All generated files are up to date. You can check this by running `make generate` locally.
- [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally.
Unsure? Have a question? Request a review!
Co-authored-by: mikayla.toffler <[email protected]>1 parent 944319d commit ee1fdc0
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
0 commit comments