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

Prevent telemetry requests from being traced #2961

Merged
merged 2 commits into from
Jul 13, 2023
Merged

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jul 13, 2023

Telemetry has its own custom transport, and it was missing a flag that lets the Net::HTTP tracing integration know to skip instrumenting the telemetry request.

This PR adds that flag, as an HTTP header, similar to how other ddtrace components operate.

There is also a bit of refactoring around this flag, to easy clarity during future use and simplify the circuit breaker implementation.

@marcotc marcotc requested a review from a team July 13, 2023 00:12
@marcotc marcotc self-assigned this Jul 13, 2023
@github-actions github-actions bot added core Involves Datadog core libraries integrations Involves tracing integrations tracing labels Jul 13, 2023
@@ -74,45 +74,19 @@
it { is_expected.to be false }
end
end
end

context 'integration' do
Copy link
Member Author

Choose a reason for hiding this comment

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

This integration test was moved to spec/datadog/tracing/contrib/http/request_spec.rb and refactored.

Comment on lines -115 to +89
it { is_expected.to be true }
it { is_expected.to be false }
Copy link
Member Author

Choose a reason for hiding this comment

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

This diff is confusing because of the test removed: this PR did not change this assertion from true to false. See side-by-side for more clarity.

Copy link
Member

@lloeki lloeki left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +30 to +33
'Content-Type' => 'application/json',
'DD-Telemetry-API-Version' => 'v1',
'DD-Telemetry-Request-Type' => 'app-started',
'DD-Internal-Untraced-Request' => '1',
Copy link
Member

Choose a reason for hiding this comment

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

Curious why you decided to remove the constants. Not opposed to the change, I just want to know your reasoning 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

When you use to the System Under Test (SUT) as test assertions, you can end up with test assertions that are couple to your SUT.

This means you could have wrong assertions, because they are simply reflecting something incorrect in your SUT, and regurgitating it back to you in a test case.

This doesn't mean we should replace every reference from the SUT from our test assertions, but when feasible, it's good to avoid it.

In a few cases, it can create unmaintainable tests, and it might be fine to use the SUT, but I tend to avoid it if possible.

@marcotc marcotc merged commit 2c96c31 into master Jul 13, 2023
@marcotc marcotc deleted the no-trace-telemetry branch July 13, 2023 22:41
@github-actions github-actions bot added this to the 1.13.0 milestone Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants