nic-6443 commented on code in PR #12686:
URL: https://github.com/apache/apisix/pull/12686#discussion_r2464711981
##########
apisix/plugins/opentelemetry.lua:
##########
@@ -376,13 +376,57 @@ function _M.rewrite(conf, api_ctx)
ngx_var.opentelemetry_span_id = span_context.span_id
end
+ if not ctx:span():is_recording() then
+ ngx.ctx._apisix_skip_tracing = true
+ end
+
api_ctx.otel_context_token = ctx:attach()
-- inject trace context into the headers of upstream HTTP request
trace_context_propagator:inject(ctx, ngx.req)
end
+local function create_child_span(tracer, parent_span_ctx, span)
+ local new_span_ctx, new_span = tracer:start(parent_span_ctx, span.name,
+ {
+ kind = span.kind,
+ attributes = span.attributes,
+ })
+ new_span.start_time = span.start_time
+
+ for _, child in ipairs(span.children or {}) do
+ create_child_span(tracer, new_span_ctx, child)
+ end
+ if span.status then
+ new_span:set_status(span.status.code, span.status.message)
+ end
+ new_span:finish(span.end_time)
+end
+
+
+local function inject_core_spans(root_span_ctx, api_ctx, conf)
+ local metadata = plugin.plugin_metadata(plugin_name)
+ local plugin_info = metadata.value
+ if root_span_ctx.span and not root_span_ctx:span():is_recording() then
+ return
+ end
+ local conf = core.table.deepcopy(conf)
+ conf.sampler.name = "always_on"
Review Comment:
we should reuse this deepcopy result
--
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]