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 c42f221 feat: add a global field 'includeHostInEntrySpan', type
'boolean', mark the entrySpan include host/domain (#59)
c42f221 is described below
commit c42f22122a982c56a7733bdd0d345974a1202bf6
Author: dufei <[email protected]>
AuthorDate: Tue Jan 12 11:26:31 2021 +0800
feat: add a global field 'includeHostInEntrySpan', type 'boolean', mark the
entrySpan include host/domain (#59)
* feat: add a global field 'includeHostInEntrySpan', type 'boolean', mark
the entrySpan include host/domain
* doc: update setup doc, add a global field 'includeHostInEntrySpan', mark
the entrySpan include host/domain
Co-authored-by: dufei <[email protected]>
---
README.md | 4 +++-
examples/nginx.conf | 1 +
lib/skywalking/tracer.lua | 8 +++++++-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 2145bfd..91cfd17 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,9 @@ http {
metadata_buffer:set('serviceName', 'User Service Name')
-- Instance means the number of Nginx deployment, does not mean the
worker instances
metadata_buffer:set('serviceInstanceName', 'User Service Instance
Name')
-
+ -- type 'boolean', mark the entrySpan include host/domain
+ metadata_buffer:set('includeHostInEntrySpan', 'Whether the endpoint
name include host/domain')
+
-- set random seed
require("skywalking.util").set_randomseed()
require("skywalking.client"):startBackendTimer("http://127.0.0.1:8080")
diff --git a/examples/nginx.conf b/examples/nginx.conf
index 980cbac..9e4b495 100644
--- a/examples/nginx.conf
+++ b/examples/nginx.conf
@@ -37,6 +37,7 @@ http {
metadata_buffer:set('serviceName', 'User Service Name')
-- Instance means the number of Nginx deloyment, does not mean the
worker instances
metadata_buffer:set('serviceInstanceName', 'User Service Instance
Name')
+ metadata_buffer:set('includeHostInEntrySpan', 'Whether the endpoint
name include HOST/domain')
require("skywalking.util").set_randomseed()
require("skywalking.client"):startBackendTimer("http://127.0.0.1:8080")
diff --git a/lib/skywalking/tracer.lua b/lib/skywalking/tracer.lua
index 167b397..9e5a3cd 100644
--- a/lib/skywalking/tracer.lua
+++ b/lib/skywalking/tracer.lua
@@ -33,6 +33,7 @@ local Tracer = {}
function Tracer:start(upstream_name, correlation)
local serviceName = metadata_shdict:get("serviceName")
local serviceInstanceName = metadata_shdict:get('serviceInstanceName')
+ local includeHostInEntrySpan =
metadata_shdict:get('includeHostInEntrySpan')
local tracingContext = TC.new(serviceName, serviceInstanceName)
-- Constant pre-defined in SkyWalking main repo
@@ -43,7 +44,12 @@ function Tracer:start(upstream_name, correlation)
contextCarrier["sw8-correlation"] = ngx.var.http_sw8_correlation
local time_now = ngx.now() * 1000
- local entrySpan = TC.createEntrySpan(tracingContext, ngx.var.uri, nil,
contextCarrier)
+ local entrySpan
+ if (includeHostInEntrySpan) then
+ entrySpan = TC.createEntrySpan(tracingContext, ngx.var.host ..
ngx.var.uri, nil, contextCarrier)
+ else
+ entrySpan = TC.createEntrySpan(tracingContext, ngx.var.uri, nil,
contextCarrier)
+ end
Span.start(entrySpan, time_now)
Span.setComponentId(entrySpan, nginxComponentId)
Span.setLayer(entrySpan, Layer.HTTP)