add upstream_status to tag http.status (#42)
diff --git a/lib/skywalking/tracer.lua b/lib/skywalking/tracer.lua
index 9803337..b71db28 100644
--- a/lib/skywalking/tracer.lua
+++ b/lib/skywalking/tracer.lua
@@ -68,6 +68,10 @@
function Tracer:finish()
-- Finish the exit span when received the first response package from upstream
if ngx.ctx.exitSpan ~= nil 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
end
@@ -77,7 +81,11 @@
local TC = require('tracing_context')
local Segment = require('segment')
if ngx.ctx.entrySpan ~= nil then
- Span.tag(ngx.ctx.entrySpan, 'http.status', ngx.var.status)
+ local ngxstatus = ngx.var.status
+ Span.tag(ngx.ctx.entrySpan, 'http.status', ngxstatus)
+ if tonumber(ngxstatus) >= 500 then
+ Span.errorOccurred(ngx.ctx.entrySpan)
+ end
Span.finish(ngx.ctx.entrySpan, ngx.now() * 1000)
local status, segment = TC.drainAfterFinished(ngx.ctx.tracingContext)
if status then
diff --git a/test/e2e/e2e-with-mock-collector/src/test/resources/expectedData.yaml b/test/e2e/e2e-with-mock-collector/src/test/resources/expectedData.yaml
index cb8f51c..578b35f 100644
--- a/test/e2e/e2e-with-mock-collector/src/test/resources/expectedData.yaml
+++ b/test/e2e/e2e-with-mock-collector/src/test/resources/expectedData.yaml
@@ -37,6 +37,8 @@
componentId: 6000
peer: 'e2e-test-with-mock-collector:upstream_ip2:port2'
spanLayer: Http
+ tags:
+ - {key: http.status, value: '200'}
- operationName: /tier2/lb
startTime: gt 0
tags:
@@ -67,6 +69,8 @@
componentId: 6000
peer: 'e2e-test-with-mock-collector:upstream_ip:port'
spanLayer: Http
+ tags:
+ - {key: http.status, value: '200'}
- operationName: /ingress
startTime: gt 0
tags: