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: Change opentelemetry's span kind to server #7830

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/plugins/opentelemetry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function _M.rewrite(conf, api_ctx)
end

local ctx = tracer:start(upstream_context, api_ctx.var.request_uri, {
kind = span_kind.client,
kind = span_kind.server,
attributes = attributes,
})
ctx:attach()
Expand Down
7 changes: 7 additions & 0 deletions t/plugin/opentelemetry.t
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ plugin_attr:
--- extra_init_by_lua
local core = require("apisix.core")
local otlp = require("opentelemetry.trace.exporter.otlp")
local span_kind = require("opentelemetry.trace.span_kind")
otlp.export_spans = function(self, spans)
if (#spans ~= 1) then
ngx.log(ngx.ERR, "unexpected spans length: ", #spans)
Expand All @@ -565,6 +566,12 @@ plugin_attr:
return
end

local current_span_kind = span:plain().kind
if current_span_kind ~= span_kind.server then
ngx.log(ngx.ERR, "expected span.kind to be server but got ", current_span_kind)
return
end

if span.name ~= "/opentracing?foo=bar&a=b" then
ngx.log(ngx.ERR, "expect span name: /opentracing?foo=bar&a=b, but got ", span.name)
return
Expand Down