prasunsrivastav123-lang commented on code in PR #12990:
URL: https://github.com/apache/apisix/pull/12990#discussion_r3030325293
##########
apisix/plugins/opentelemetry.lua:
##########
@@ -231,9 +249,17 @@ end
local function create_tracer_obj(conf, plugin_info)
if plugin_info.trace_id_source == "x-request-id" then
+ local _original_new_ids = id_generator.new_ids
+
id_generator.new_ids = function()
- local trace_id = core.request.headers()["x-request-id"] or
ngx_var.request_id
- return trace_id, id_generator.new_span_id()
+ local trace_id = core.request.headers()["x-request-id"]
+ or ngx_var.request_id
+
+ if is_valid_trace_id(trace_id) then
+ return trace_id, id_generator.new_span_id()
+ end
+
+ return _original_new_ids()
Review Comment:
You're right — the current implementation wraps `id_generator.new_ids`
multiple times when the tracer is recreated, which breaks idempotency and can
lead to stacked wrappers over time.
My intention was to validate the x-request-id and fallback safely, but I see
that the current approach needs adjustment to avoid repeated wrapping.
I’ll update the implementation to ensure the override happens only once
(idempotent behavior) and push a fix shortly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]