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

[Tracing] trace-flag of header 'Traceparent' is always '01' no matter the value of tracing_sampling_rate. #11626

Closed
1 task done
mong0520 opened this issue Sep 21, 2023 · 5 comments
Assignees
Labels
pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc...

Comments

@mong0520
Copy link

mong0520 commented Sep 21, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

Kong 3.4.0

Current Behavior

Regarding to the definition of header Traceparent, the last field should be represented this span is recored or not.

For example, no matter the value of tracing_sampling_rate is set, kong always sets the the trace-flag of Traceparent to 01.

It causes the behavior of Kong is doing the sampling correctly regarding to tracing_sampling_rate, but always tells the upstream 'this span should be recorded'. Child span respects parent span's flag to determine if this span should be recored or not, so since kong always set it to 01, it makes child span will be always recorded.

Traceparent: 00-eb00cf0993a96552c35f60db0c6af774-43573e953680fb1a-01

Expected Behavior

The last flag should 00 if kong does not record this span.

Steps To Reproduce

  1. Enable OpenTelemetry plugin
  2. Set tracing_sampling_rate to 0.5
  3. Setup an upstream and monitor the incoming header of Traceparent
  4. Found the trace-flag field is always 01 no matter kong recored the span or not.

Anything else?

the value of balancer_span.should_sample is always true(ref: https://github.com/Kong/kong/blob/3.4.0/kong/plugins/opentelemetry/handler.lua#L129), so that the trace-flag is always 01 in this function. (ref: https://github.com/Kong/kong/blob/3.4.0/kong/tracing/propagation.lua#L589)

@samugi
I am not sure if it related to #11468

No response

@samugi
Copy link
Member

samugi commented Sep 21, 2023

@mong0520 Hi, thanks for reporting this. I can already say it is not related to the PR you have linked because that has not been released yet. I will look into this and provide an update.

@samugi samugi self-assigned this Sep 21, 2023
@mong0520
Copy link
Author

mong0520 commented Sep 21, 2023

@samugi
I just did a very rough workaround on my side and it works as expectation as the trace-flag shows correctly.
The trace-flag of traceparent header will be 00 or 01 by this fix and it depends on the root span is traced or not. ( tracing_sampling_rate)

But I thought it is differently not a good fix , just FYI and try to reduce your time.
file path: kong/plugins/opentelemetry/handler.lua
image

@samugi
Copy link
Member

samugi commented Sep 23, 2023

Hi @mong0520 thanks for the additional details. I believe this should've been taken care of by #11468 - would it be possible for you to verify that the issue you encountered is not reproducible with that PR? That fix will be included in the next minor release.

@samugi samugi added the pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc... label Sep 23, 2023
@mong0520
Copy link
Author

mong0520 commented Oct 6, 2023

@samugi
This issue is fixed on my local testing with Kong 3.4.1, thank you!

@samugi
Copy link
Member

samugi commented Oct 6, 2023

awesome, thanks for confirming @mong0520

@samugi samugi closed this as completed Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending author feedback Waiting for the issue author to get back to a maintainer with findings, more details, etc...
Projects
None yet
Development

No branches or pull requests

2 participants