Skip to content

Commit

Permalink
fix(tracing): should trace request stopped by extern plugin (#6500)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander authored Mar 6, 2022
1 parent 0aeba95 commit 492f782
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apisix/plugins/zipkin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ local schema = {

local _M = {
version = 0.1,
priority = 11011,
priority = 12011,
name = plugin_name,
schema = schema,
}
Expand Down
2 changes: 1 addition & 1 deletion conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ plugins: # plugin list (sorted by priority)
- real-ip # priority: 23000
- client-control # priority: 22000
- proxy-control # priority: 21990
- zipkin # priority: 12011
- ext-plugin-pre-req # priority: 12000
- zipkin # priority: 11011
- request-id # priority: 11010
- fault-injection # priority: 11000
- mocking # priority: 10900
Expand Down
2 changes: 1 addition & 1 deletion t/admin/plugins.t
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ __DATA__
real-ip
client-control
proxy-control
ext-plugin-pre-req
zipkin
ext-plugin-pre-req
request-id
fault-injection
mocking
Expand Down
2 changes: 1 addition & 1 deletion t/debug/debug-mode.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ done
--- error_log
loaded plugin and sort by priority: 23000 name: real-ip
loaded plugin and sort by priority: 22000 name: client-control
loaded plugin and sort by priority: 12011 name: zipkin
loaded plugin and sort by priority: 12000 name: ext-plugin-pre-req
loaded plugin and sort by priority: 11011 name: zipkin
loaded plugin and sort by priority: 11010 name: request-id
loaded plugin and sort by priority: 11000 name: fault-injection
loaded plugin and sort by priority: 10000 name: serverless-pre-function
Expand Down
67 changes: 67 additions & 0 deletions t/plugin/ext-plugin/http-req-call.t
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,70 @@ X-Resp: foo
X-Req: bar
Content-Type: text/plain
Content-Encoding:
=== TEST 21: trace stopped request
--- config
location /t {
content_by_lua_block {
local json = require("toolkit.json")
local t = require("lib.test_admin")
local code, message, res = t.test('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"uri": "/hello",
"plugins": {
"zipkin": {
"endpoint": "http://127.0.0.1:1980/mock_zipkin",
"sample_ratio": 1
},
"ext-plugin-pre-req": {
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
}
}]]
)
if code >= 300 then
ngx.status = code
ngx.say(message)
return
end
ngx.say(message)
}
}
--- response_body
passed
=== TEST 22: hit
--- extra_init_by_lua
local prev_new = require("opentracing.tracer").new
local function new(...)
ngx.log(ngx.WARN, "tracer attached to stopped request")
return prev_new(...)
end
require("opentracing.tracer").new = new
--- request
GET /hello
--- extra_stream_config
server {
listen unix:$TEST_NGINX_HTML_DIR/nginx.sock;
content_by_lua_block {
local ext = require("lib.ext-plugin")
ext.go({stop = true})
}
}
--- error_code: 405
--- error_log
tracer attached to stopped request

0 comments on commit 492f782

Please sign in to comment.