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

internal/exectracetest: move execution trace testing to separate module #2709

Conversation

nsrip-dd
Copy link
Contributor

What does this PR do?

Creates a new module for execution trace-related testing.

Motivation

To parse execution traces for testing execution trace-related
functionality, we'll need to use golang.org/x/exp/trace. As new versions
of the format come out, we'll need to upgrade that dependency to keep
tests working. The golang.org/x/exp module is prone to breaking changes,
so we should try not to inflict them on our users. Thus, this PR
creates a separate module where execution trace testing logic can live,
so we can freely upgrade golang.org/x/exp. Future PRs will move
existing test logic, which uses gotraceui's parser, to this new module.

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.

Unsure? Have a question? Request a review!

@pr-commenter
Copy link

pr-commenter bot commented May 23, 2024

Benchmarks

Benchmark execution time: 2024-05-30 14:02:35

Comparing candidate commit 8f4e834 in PR branch nick.ripley/new-exectrace-test-module with baseline commit 3c50bd6 in branch nick.ripley/only-finish-span-once.

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

To parse execution traces for testing execution trace-related
functionality, we'll need to use golang.org/x/exp/trace. As new versions
of the format come out, we'll need to upgrade that dependency to keep
tests working. The golang.org/x/exp module is prone to breaking changes,
so we should try not to inflict them on our users. Thus, this commit
creates a separate module where execution trace testing logic can live,
so we can freely upgrade golang.org/x/exp. Future commits will move
existing test logic, which uses gotraceui's parser, to this new module.
@nsrip-dd nsrip-dd force-pushed the nick.ripley/new-exectrace-test-module branch from 1f76dd1 to 10c4ad9 Compare May 24, 2024 13:35
@nsrip-dd nsrip-dd marked this pull request as ready for review May 24, 2024 13:39
@nsrip-dd nsrip-dd requested a review from a team as a code owner May 24, 2024 13:39
@felixge felixge self-requested a review May 29, 2024 20:49
Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

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

Thanks for working on this 🙇 . I found a few problems.

Problem 1

The test passes even if I revert #2708.

$ git revert 3c50bd6f4f0856e10c54d419f691234a17867bc1
$ cd internal/exectracetest
$ go test .
ok  	gopkg.in/DataDog/dd-trace-go.v1/internal/exectracetest	0.458s

Problem 2

Moving the test into its own go module seems to prevent it from being executed by the CI according to the logs.

Problem 3

The golang.org/x/exp module is prone to breaking changes, so we should try not to inflict them on our users.

I don't follow. If we're only using x/exp from _test.go files, it should be impossible for x/exp changes to break our customers. The blast radius should strictly be limited to our test suite?

nsrip-dd added 2 commits May 29, 2024 19:21
This was a sloppy mistake during a cleanup of the test case that failed
to actually start the tracer. This made the test pass even when
reverting the fix it was intended to test.
They're in a separate module so the first gotestsum command won't pick
them up. We need to be working from the exectracetest directory.
Copy link
Contributor Author

@nsrip-dd nsrip-dd left a comment

Choose a reason for hiding this comment

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

Thanks for the thorough review!

Problem 1 - test passes even after revert

😅 Fixed, I was sloppy and lost the bits to start & stop the APM tracer when tidying up the test case. Added back and confirmed that the test fails after reverting the fix it is meant to test.

Problem 2 - CI didn't run

Also good catch. I updated the CI script, should actually run the test now. You unfortunately won't see it here because PR tests run on Go 1.20 right now, which golang.org/x/exp doesn't support. But it will run on main, and we're planning to drop Go 1.20 support soon anyway (working on #2705) so soon it'll run on PRs, too.

Problem 3 - why a separate module

The issue is that there is only one entry for golang.org/x/exp in our main go.mod file. If we need a newer version, even if it's only for a test, our main go.mod file would need to be updated to specify at least that version. I've run into breakage in the past from upgrading golang.org/x/exp. See #2212 and my internal v1.55.0 release checklist for more, but basically golang.org/x/exp made a breaking change to some slice functions that broke the build internally.

@felixge felixge self-requested a review May 31, 2024 13:14
Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

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

Thanks 🙇

@felixge felixge merged commit d7711b8 into nick.ripley/only-finish-span-once May 31, 2024
199 checks passed
@felixge felixge deleted the nick.ripley/new-exectrace-test-module branch May 31, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants