You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/06/02 13:24:27 UTC
[skywalking-nginx-lua] branch master updated: add flag to makesure
Tracer:finish called (#85)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-nginx-lua.git
The following commit(s) were added to refs/heads/master by this push:
new 312b8a2 add flag to makesure Tracer:finish called (#85)
312b8a2 is described below
commit 312b8a2b35a83cf03441eca616300f8f21750671
Author: Joshua Yang <yx...@gmail.com>
AuthorDate: Wed Jun 2 21:24:17 2021 +0800
add flag to makesure Tracer:finish called (#85)
---
CHANGES.md | 4 ++++
lib/skywalking/tracer.lua | 7 ++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/CHANGES.md b/CHANGES.md
index 0b6466f..df4ffb4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,9 @@
# Changes
+## 0.6.0
+
+1. fix: `skywalking_tracer:finish()` will not be called in some case such as upstream timeout.
+
## 0.5.0
1. Adapt to Kong agent.
diff --git a/lib/skywalking/tracer.lua b/lib/skywalking/tracer.lua
index 88941b2..5bf8a88 100644
--- a/lib/skywalking/tracer.lua
+++ b/lib/skywalking/tracer.lua
@@ -79,21 +79,26 @@ function Tracer:start(upstream_name, correlation)
ctx.tracingContext = tracingContext
ctx.entrySpan = entrySpan
ctx.exitSpan = exitSpan
+ ctx.is_finished = false
end
function Tracer:finish()
-- Finish the exit span when received the first response package from upstream
- if ngx.ctx.exitSpan ~= nil then
+ if ngx.ctx.exitSpan ~= nil and not ngx.ctx.is_finished then
local upstream_status = tonumber(ngx.var.upstream_status)
if upstream_status then
Span.tag(ngx.ctx.exitSpan, 'http.status', upstream_status)
end
Span.finish(ngx.ctx.exitSpan, ngx.now() * 1000)
ngx.ctx.exitSpan = nil
+ ngx.ctx.is_finished = true
end
end
function Tracer:prepareForReport()
+ if not ngx.ctx.is_finished then
+ self.finish()
+ end
local entrySpan = ngx.ctx.entrySpan
if not entrySpan then
return