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 2020/03/04 06:12:00 UTC
[skywalking-nginx-lua] 01/01: Fix a wrong method name and expose
the upstream address as the variable
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch expose-upstream-name
in repository https://gitbox.apache.org/repos/asf/skywalking-nginx-lua.git
commit ba709b9b24b6d5ef991a5104b5eaaa22fa9ffe9e
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Mar 4 14:11:47 2020 +0800
Fix a wrong method name and expose the upstream address as the variable
---
README.md | 9 ++++++++-
examples/nginx.conf | 9 ++++++++-
lib/skywalking/tracer.lua | 12 +++---------
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 906c8ff..b4dc5d1 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,14 @@ http {
default_type text/html;
rewrite_by_lua_block {
- require("tracer"):start()
+ ------------------------------------------------------
+ -- NOTICE, this should be changed manually
+ -- This variable represents the upstream logic address
+ -- Please set them as service logic name or DNS name
+ --
+ -- TODO, currently, we ca not have the upstream real network address
+ ------------------------------------------------------
+ require("tracer"):start("upstream service")
}
-- Target upstream service
diff --git a/examples/nginx.conf b/examples/nginx.conf
index 0eaa3bc..8bc1558 100644
--- a/examples/nginx.conf
+++ b/examples/nginx.conf
@@ -51,7 +51,14 @@ http {
default_type text/html;
rewrite_by_lua_block {
- require("tracer"):startBackendTimer()
+ ------------------------------------------------------
+ -- NOTICE, this should be changed manually
+ -- This variable represents the upstream logic address
+ -- Please set them as service logic name or DNS name
+ --
+ -- TODO, currently, we ca not have the upstream real network address
+ ------------------------------------------------------
+ require("tracer"):start("upstream service")
}
proxy_pass http://127.0.0.1:8080/tier2/lb;
diff --git a/lib/skywalking/tracer.lua b/lib/skywalking/tracer.lua
index e3d8fcc..1689d79 100644
--- a/lib/skywalking/tracer.lua
+++ b/lib/skywalking/tracer.lua
@@ -17,7 +17,7 @@
local Tracer = {}
-function Tracer:startBackendTimer()
+function Tracer:start(upstream_name)
local metadata_buffer = ngx.shared.tracing_buffer
local TC = require('tracing_context')
local Layer = require('span_layer')
@@ -50,14 +50,8 @@ function Tracer:startBackendTimer()
-- Use the same URI to represent incoming and forwarding requests
-- Change it if you need.
local upstreamUri = ngx.var.uri
- ------------------------------------------------------
- -- NOTICE, this should be changed manually
- -- This variable represents the upstream logic address
- -- Please set them as service logic name or DNS name
- --
- -- TODO, currently, we can't have the upstream real network address
- ------------------------------------------------------
- local upstreamServerName = serviceName .. "-nginx:upstream_ip:port"
+
+ local upstreamServerName = upstream_name
------------------------------------------------------
local exitSpan = tracingContext:createExitSpan(upstreamUri, entrySpan, upstreamServerName, contextCarrier)
exitSpan:start(ngx.now() * 1000)