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

ddtrace/opentelemetry: refactor OTel API tests #2503

Merged
merged 9 commits into from Jan 30, 2024

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Jan 12, 2024

What does this PR do?

  • Makes the mockTracerProvider return an empty JSON object on GET of URLs that aren't relevant to the test
  • Uses an atomic pointer to hold the payload in the trace writer to remove a data race (this has been removed)
  • The tests now marshal the trace payloads into a map that can be more easily accessed and more accurately tested, instead of checking exact string matches on the marshaled payloads.
  • Removes timed contexts from all tests, and instead changes the function that waits for trace payloads to have a 10 second timer. This simplifies the code.

Motivation

This removes error logs (stemming from receiving an empty response) that otherwise can confuse someone trying to diagnose a bug into looking at the wrong problems.

This also addresses data corruption that happened if multiple concurrent accesses to the trace writer's payload happened (in particular in concurrency with flush).

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!

@RomainMuller RomainMuller requested a review from a team as a code owner January 12, 2024 10:43
@pr-commenter
Copy link

pr-commenter bot commented Jan 12, 2024

Benchmarks

Benchmark execution time: 2024-01-25 17:36:08

Comparing candidate commit 8b46ec8 in PR branch romain.marcadier/diagnose-failure with baseline commit 882cddb in branch main.

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

@RomainMuller RomainMuller force-pushed the romain.marcadier/diagnose-failure branch 2 times, most recently from 86c434c to 365d936 Compare January 12, 2024 11:18
@RomainMuller RomainMuller changed the title ddtrace/opentelemetry: Make test server return an empty JSON object on abritrary GET URLs ddtrace/opentelemetry: Fix broken test Jan 12, 2024
@RomainMuller RomainMuller force-pushed the romain.marcadier/diagnose-failure branch from 365d936 to eb4d2ea Compare January 12, 2024 12:40
@katiehockman katiehockman changed the base branch from katie.hockman/v1.60.x-bump-version to main January 12, 2024 17:22
@katiehockman katiehockman requested a review from a team as a code owner January 12, 2024 17:22
@katiehockman katiehockman force-pushed the romain.marcadier/diagnose-failure branch from eb4d2ea to e32ddc7 Compare January 12, 2024 17:24
@katiehockman katiehockman changed the base branch from main to release-v1.60.x January 12, 2024 19:15
@RomainMuller RomainMuller requested a review from a team as a code owner January 12, 2024 19:27
@katiehockman katiehockman force-pushed the romain.marcadier/diagnose-failure branch from 132a3e5 to 43a1231 Compare January 12, 2024 22:33
@katiehockman katiehockman changed the title ddtrace/opentelemetry: Fix broken test ddtrace/opentelemetry: fix broken test Jan 12, 2024
@katiehockman katiehockman changed the base branch from release-v1.60.x to main January 12, 2024 22:34
ddtrace/opentelemetry/span_test.go Outdated Show resolved Hide resolved
ddtrace/opentelemetry/span_test.go Outdated Show resolved Hide resolved
@katiehockman katiehockman force-pushed the romain.marcadier/diagnose-failure branch from 2e163f5 to 7f1897c Compare January 18, 2024 17:26
@katiehockman katiehockman changed the title ddtrace/opentelemetry: fix broken test ddtrace/opentelemetry: refactor OTel API tests Jan 18, 2024
@katiehockman
Copy link
Contributor

katiehockman commented Jan 18, 2024

This is ready for re-review. I don't think I should approve it, since I wrote a lot of the commits. @dianashevchenko can you take a look at this when you get the chance?
@RomainMuller I'm curious if you think d8f2dd5 is still worth having in this PR. If we do think it's worth including, we should probably try to create a test that can simulate the race that we're concerned about here. It's been removed.

@katiehockman katiehockman force-pushed the romain.marcadier/diagnose-failure branch from 0a8fb1e to 8b46ec8 Compare January 25, 2024 17:20
@katiehockman katiehockman enabled auto-merge (squash) January 30, 2024 18:39
@katiehockman katiehockman merged commit 8c4834f into main Jan 30, 2024
153 of 154 checks passed
@katiehockman katiehockman deleted the romain.marcadier/diagnose-failure branch January 30, 2024 18:46
darccio added a commit that referenced this pull request Feb 5, 2024
Co-authored-by: Katie Hockman <katie.hockman@datadoghq.com>
Co-authored-by: Dario Castañé <dario.castane@datadoghq.com>
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.

None yet

5 participants