Skip to content

Commit 6f8e8ad

Browse files
authored
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.
1 parent 2857bf5 commit 6f8e8ad

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ http {
4141
default_type text/html;
4242
4343
rewrite_by_lua_block {
44-
require("tracer"):start()
44+
------------------------------------------------------
45+
-- NOTICE, this should be changed manually
46+
-- This variable represents the upstream logic address
47+
-- Please set them as service logic name or DNS name
48+
--
49+
-- Currently, we can not have the upstream real network address
50+
------------------------------------------------------
51+
require("tracer"):start("upstream service")
4552
}
4653
4754
-- Target upstream service

examples/nginx.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ http {
5151
default_type text/html;
5252

5353
rewrite_by_lua_block {
54-
require("tracer"):startBackendTimer()
54+
------------------------------------------------------
55+
-- NOTICE, this should be changed manually
56+
-- This variable represents the upstream logic address
57+
-- Please set them as service logic name or DNS name
58+
--
59+
-- Currently, we can not have the upstream real network address
60+
------------------------------------------------------
61+
require("tracer"):start("upstream service")
5562
}
5663

5764
proxy_pass http://127.0.0.1:8080/tier2/lb;

lib/skywalking/tracer.lua

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
local Tracer = {}
1919

20-
function Tracer:startBackendTimer()
20+
function Tracer:start(upstream_name)
2121
local metadata_buffer = ngx.shared.tracing_buffer
2222
local TC = require('tracing_context')
2323
local Layer = require('span_layer')
@@ -50,14 +50,8 @@ function Tracer:startBackendTimer()
5050
-- Use the same URI to represent incoming and forwarding requests
5151
-- Change it if you need.
5252
local upstreamUri = ngx.var.uri
53-
------------------------------------------------------
54-
-- NOTICE, this should be changed manually
55-
-- This variable represents the upstream logic address
56-
-- Please set them as service logic name or DNS name
57-
--
58-
-- TODO, currently, we can't have the upstream real network address
59-
------------------------------------------------------
60-
local upstreamServerName = serviceName .. "-nginx:upstream_ip:port"
53+
54+
local upstreamServerName = upstream_name
6155
------------------------------------------------------
6256
local exitSpan = tracingContext:createExitSpan(upstreamUri, entrySpan, upstreamServerName, contextCarrier)
6357
exitSpan:start(ngx.now() * 1000)

test/e2e/validator/docker/conf.d/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ http {
5252
default_type text/html;
5353

5454
rewrite_by_lua_block {
55-
require("tracer"):startBackendTimer()
55+
require("tracer"):start("User_Service_Name-nginx:upstream_ip:port")
5656
}
5757

5858
proxy_pass http://127.0.0.1:8080/tier2/lb;
@@ -70,7 +70,7 @@ http {
7070
default_type text/html;
7171

7272
rewrite_by_lua_block {
73-
require("tracer"):startBackendTimer()
73+
require("tracer"):start("User_Service_Name-nginx:upstream_ip2:port2")
7474
}
7575

7676
proxy_pass http://127.0.0.1:8080/backend;

test/e2e/validator/src/test/resources/expectedData.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ segmentItems:
1919
isError: false
2020
parentSpanId: 0
2121
componentId: 6000
22-
peer: 'User_Service_Name-nginx:upstream_ip:port'
22+
peer: 'User_Service_Name-nginx:upstream_ip2:port2'
2323
spanLayer: HTTP
2424
- operationName: /tier2/lb
2525
startTime: gt 0

0 commit comments

Comments
 (0)