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

tracer.startTestTracer: Call SetServiceName("") when stopping #2260

Merged
merged 3 commits into from Oct 13, 2023

Conversation

evanj
Copy link
Contributor

@evanj evanj commented Oct 11, 2023

What does this PR do?

While debugging a different unit test, I noticed that the service name can leak between tests. For TestSpanLog: if you remove some of the WithService(...) options, the tests still pass because it uses the service name that was previously set.

To prevent this, call globalconfig.SetServiceName("") when stopping the tracer. I also added a test to verify that the span log does not include any options, even after setting all the options.

This isn't really causing any problems, except that it prevents running the unit tests with the -shuffle=on flag, because some tests are accidentally depending on other tests.

Motivation

Found while attempting to write a unit test for a race bug.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • 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.

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!

While debugging a different unit test, I noticed that the service
name can leak between tests. For TestSpanLog: if you remove some of
the WithService(...) options, the tests still pass because it uses
the service name that was previously set.

To prevent this, call globalconfig.SetServiceName("") when stopping
the tracer. I also added a test to verify that the span log does not
include any options, even after setting all the options.

This isn't really causing any problems, except that it prevents
running the unit tests with the -shuffle=on flag, because some tests
are accidentally depending on other tests.
@evanj evanj requested a review from a team October 11, 2023 19:38
@pr-commenter
Copy link

pr-commenter bot commented Oct 11, 2023

Benchmarks

Benchmark execution time: 2023-10-12 16:37:52

Comparing candidate commit f77f6fa in PR branch evan.jones/tracer-clear-servicename with baseline commit b7546cf in branch main.

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

Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for catching this and fixing it

@evanj evanj mentioned this pull request Oct 12, 2023
5 tasks
@felixge felixge enabled auto-merge (squash) October 12, 2023 16:22
@felixge felixge merged commit b9c67e8 into main Oct 13, 2023
50 of 51 checks passed
@felixge felixge deleted the evan.jones/tracer-clear-servicename branch October 13, 2023 11:29
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

3 participants