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

Fix tracing module's Jaeger sampling flag #3251

Merged
merged 2 commits into from
Aug 7, 2023

Conversation

oleiade
Copy link
Member

@oleiade oleiade commented Aug 4, 2023

What?

This Pull Request contains a fix for the sample flags values being incorrect when using the tracing module's Jaeger propagator.

Why?

As reported by @Blinkuu, the sampling option of the tracing module did not set the trace header flags correctly. That led to traces not being sampled, regardless of the options set on the instrumentHTTP called.

This was caused by the constant values defining the sampled/unsampled flags being inverted. This Pull Request sets their values back to their specified values. It also adds tests ensuring that we observe the correct flags from the propagators Propagate methods under various conditions.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make ci-like-lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

#3212

@oleiade oleiade added the bug label Aug 4, 2023
@oleiade oleiade added this to the v0.46.0 milestone Aug 4, 2023
@oleiade oleiade self-assigned this Aug 4, 2023
@oleiade oleiade requested a review from Blinkuu August 4, 2023 10:07
Copy link
Contributor

@Blinkuu Blinkuu left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@codecov-commenter
Copy link

Codecov Report

Merging #3251 (7561e06) into master (447b159) will decrease coverage by 0.06%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

❗ Current head 7561e06 differs from pull request most recent head af55151. Consider uploading reports for the commit af55151 to get more accurate results

@@            Coverage Diff             @@
##           master    #3251      +/-   ##
==========================================
- Coverage   73.23%   73.17%   -0.06%     
==========================================
  Files         259      257       -2     
  Lines       19899    19894       -5     
==========================================
- Hits        14573    14558      -15     
- Misses       4402     4407       +5     
- Partials      924      929       +5     
Flag Coverage Δ
ubuntu 73.17% <ø> (+0.03%) ⬆️
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
js/modules/k6/experimental/tracing/propagator.go 100.00% <ø> (ø)

... and 7 files with indirect coverage changes

@oleiade
Copy link
Member Author

oleiade commented Aug 4, 2023

This is currently red as a result of the #3253 mishap. As soon as v0.45.1 is released, we'll be able to rebase.

@mstoykov
Copy link
Collaborator

mstoykov commented Aug 4, 2023

@oleiade you should rebase on master - v0.45.1 is just to backport the fix and release a version/tag to be used in extensions until 0.46.0 a week from now

@oleiade
Copy link
Member Author

oleiade commented Aug 4, 2023

@mstoykov wilco! Thanks for the head-up 🙇🏻

@oleiade oleiade force-pushed the fix/tracing-module-jaeger-sampling-flag branch from af55151 to 5ed5b89 Compare August 4, 2023 13:47
Comment on lines +72 to +76
// JaegerUnsampledTraceFlag is the trace-flag value for an unsampled trace.
JaegerUnsampledTraceFlag = "0"

// JaegerUnsampledTraceFlag is the trace-flag value for a sampled trace.
JaegerUnsampledTraceFlag = "1"
// JaegerSampledTraceFlag is the trace-flag value for a sampled trace.
JaegerSampledTraceFlag = "1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit strange to me. It is a boolean, isn't possible to have a single value so a single source of truth?

Copy link
Member Author

@oleiade oleiade Aug 7, 2023

Choose a reason for hiding this comment

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

This is a small simplification. The sampled/not sampled flag is specified as part of a set of flags: a bit within a byte.

As per the specification it could have a range of values. It just so happens that we're only using the sample flag at the moment, and encode it, at the end of the chain as a string, so keeping the constant as a string is a shortcut that avoids adding conversion code.

Happy to change it to numerical values and do the encoding instead, if you prefer; but I would do it in a different PR (this is a bug fix). Just let me know 👍

@oleiade oleiade merged commit fcb19fb into master Aug 7, 2023
22 checks passed
@oleiade oleiade deleted the fix/tracing-module-jaeger-sampling-flag branch August 7, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants