Skip to content

Commit

Permalink
fix: Change opentelemetry's span kind to server (#7830)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysonsantos authored Sep 1, 2022
1 parent 3a795f6 commit ec36a17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit ec36a17

Please sign in to comment.