This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new ec36a1744 fix: Change opentelemetry's span kind to server (#7830)
ec36a1744 is described below

commit ec36a1744caf38dd73c584b58b6a9e5bab552754
Author: Jayson Reis <[email protected]>
AuthorDate: Thu Sep 1 14:19:18 2022 +0200

    fix: Change opentelemetry's span kind to server (#7830)
---
 apisix/plugins/opentelemetry.lua | 2 +-
 t/plugin/opentelemetry.t         | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/opentelemetry.lua b/apisix/plugins/opentelemetry.lua
index ea05b0a80..d41d4598d 100644
--- a/apisix/plugins/opentelemetry.lua
+++ b/apisix/plugins/opentelemetry.lua
@@ -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()
diff --git a/t/plugin/opentelemetry.t b/t/plugin/opentelemetry.t
index 0c142667a..759b248c6 100644
--- a/t/plugin/opentelemetry.t
+++ b/t/plugin/opentelemetry.t
@@ -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)
@@ -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

Reply via email to