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/tracer: add interchangeable writer to logTraceWriter #939

Merged
merged 16 commits into from
Jul 5, 2021

Conversation

knusbaum
Copy link
Contributor

The TestTracerCleanStop test had LambdaMode added to it, which generates a
lot of output for the tests.
(See: https://app.circleci.com/pipelines/github/DataDog/dd-trace-go/1442/workflows/9add3fc7-f60c-4d09-b370-1af3aa5a851a/jobs/9866)
There is no reason why running the test in LambdaMode should improve this test.

This change seems to have been made in #859, but it doesn't look related.
(Maybe @gbbr can comment why we want to do this)

If we want to test LambdaMode too, we can duplicate the test for lambda mode,
but we should solve the test output issue.

The TestTracerCleanStop test had LambdaMode added to it, which generates a
lot of output for the tests. There is no reason why running the test in
LambdaMode should improve this test.
@knusbaum knusbaum added this to the 1.32.0 milestone May 28, 2021
@knusbaum knusbaum requested a review from gbbr May 28, 2021 16:53
felixge
felixge previously approved these changes Jun 15, 2021
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.

LGTM. But I don't know why this was enabled to begin with, I'm just approving this because it seems like an improvement and the tests are passing.

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Should be fine. This was added because the initial implementation of the referenced PR (#859) triggered agent discovery at startup, and that severely stalled this particular test due to the repeated HTTP calls. The whole thing was later placed behind a feature flag, technically removing that issue.

It's fine for now, but when the feature flag will be on by default, the discovery will significantly stall this test, in which case, we might want to consider leaving lambda mode there and instead making sure the output isn't logged.

As a precautionary measure, I think the best improvement would be to do that as of this PR: disable logging by configuring the output of lambda mode to be some /dev/null writer. Otherwise, when the feature will become enabled again, we'll be back to square one...

I will leave it up to you to decide, I'm fine with either outcome.

@knusbaum
Copy link
Contributor Author

@gbbr Cool, that's good to know.

I've put the lambda mode back in that case, but added an unexported function to switch out the io.Writer that will be used by the log writers. This should solve both of the problems.

@knusbaum knusbaum requested review from gbbr and felixge June 19, 2021 03:17
felixge
felixge previously approved these changes Jun 21, 2021
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.

LGTM

gbbr
gbbr previously approved these changes Jun 22, 2021
ddtrace/tracer/tracer_test.go Outdated Show resolved Hide resolved

// setLogWriter sets the io.Writer that any new logTraceWriter will write to and returns a function
// which will return the io.Writer to its original value.
func setLogWriter(w io.Writer) func() {
Copy link
Contributor

@gbbr gbbr Jun 22, 2021

Choose a reason for hiding this comment

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

I think this func is only needed in tests right? If so, does it make sense to move it into a test file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered it, but since var logWriter is declared and used here, I thought the function for manipulating it should be co-located so the intention/usage is apparent for whoever next looks at var logWriter.

Let me know if you feel strongly that it should be moved.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's test code (unused elsewhere), so it belongs in a test. But likewise, if you feel strongly, leave it :)

ddtrace/tracer/writer.go Show resolved Hide resolved
@knusbaum knusbaum requested a review from felixge June 23, 2021 21:17
felixge
felixge previously approved these changes Jun 24, 2021
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.

LGTM

@knusbaum
Copy link
Contributor Author

@gbbr Fixed. Please check it out.

@gbbr gbbr changed the title ddtrace/tracer: remove lambda mode option from TestTracerCleanStop ddtrace/tracer: add test replaceable to logTraceWriter Jul 5, 2021
@gbbr gbbr changed the title ddtrace/tracer: add test replaceable to logTraceWriter ddtrace/tracer: add test replaceable writer to logTraceWriter Jul 5, 2021
@gbbr gbbr merged commit 5f6503d into v1 Jul 5, 2021
@gbbr gbbr deleted the knusbaum/revert-clean-stop-lambda branch July 5, 2021 06:13
@gbbr gbbr changed the title ddtrace/tracer: add test replaceable writer to logTraceWriter ddtrace/tracer: add interchangeable writer to logTraceWriter Jul 5, 2021
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.

4 participants