You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ta...@apache.org on 2020/03/04 06:35:42 UTC
[skywalking-nginx-lua] branch master updated: Fix a wrong method
name and expose the upstream address as the variable (#13)
This is an automated email from the ASF dual-hosted git repository.
tanjian 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 6f8e8ad Fix a wrong method name and expose the upstream address as the variable (#13)
6f8e8ad is described below
commit 6f8e8ad7a5f8626cbc38bd01df019668f645cc04
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Mar 4 14:35:36 2020 +0800
Fix a wrong method name and expose the upstream address as the variable (#13)
* Fix a wrong method name and expose the upstream address as the variable
* Fix words.
* Fix method name and upstream name.
* Try to fix e2e.
---
README.md | 9 ++++++++-
examples/nginx.conf | 9 ++++++++-
lib/skywalking/tracer.lua | 12 +++---------
test/e2e/validator/docker/conf.d/nginx.conf | 4 ++--
test/e2e/validator/src/test/resources/expectedData.yaml | 2 +-
5 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index 906c8ff..e0ee074 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
+ --
+ -- Currently, we can 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..b3a8fd4 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
+ --
+ -- Currently, we can 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)
diff --git a/test/e2e/validator/docker/conf.d/nginx.conf b/test/e2e/validator/docker/conf.d/nginx.conf
index da2e81b..3f4d847 100644
--- a/test/e2e/validator/docker/conf.d/nginx.conf
+++ b/test/e2e/validator/docker/conf.d/nginx.conf
@@ -52,7 +52,7 @@ http {
default_type text/html;
rewrite_by_lua_block {
- require("tracer"):startBackendTimer()
+ require("tracer"):start("User_Service_Name-nginx:upstream_ip:port")
}
proxy_pass http://127.0.0.1:8080/tier2/lb;
@@ -70,7 +70,7 @@ http {
default_type text/html;
rewrite_by_lua_block {
- require("tracer"):startBackendTimer()
+ require("tracer"):start("User_Service_Name-nginx:upstream_ip2:port2")
}
proxy_pass http://127.0.0.1:8080/backend;
diff --git a/test/e2e/validator/src/test/resources/expectedData.yaml b/test/e2e/validator/src/test/resources/expectedData.yaml
index 96e6de0..237c04a 100644
--- a/test/e2e/validator/src/test/resources/expectedData.yaml
+++ b/test/e2e/validator/src/test/resources/expectedData.yaml
@@ -19,7 +19,7 @@ segmentItems:
isError: false
parentSpanId: 0
componentId: 6000
- peer: 'User_Service_Name-nginx:upstream_ip:port'
+ peer: 'User_Service_Name-nginx:upstream_ip2:port2'
spanLayer: HTTP
- operationName: /tier2/lb
startTime: gt 0