commit | 3d1c9788268e14c3f686a827ec7fffbdbea17614 | [log] [tgz] |
---|---|---|
author | 吴晟 Wu Sheng <wu.sheng@foxmail.com> | Thu Feb 27 09:28:34 2020 +0800 |
committer | GitHub <noreply@github.com> | Thu Feb 27 09:28:34 2020 +0800 |
tree | a8d8f7b85d9aef65cb423d41506bef74e3d899de | |
parent | ac4ba62db712fc20ff7422f31b267923419b0fb5 [diff] |
Revert "feature: add CI and test cases for ngx lua. (#3)" (#5) This reverts commit ac4ba62db712fc20ff7422f31b267923419b0fb5.
SkyWalking Nginx Agent provides the native tracing capability for Nginx powered by Nginx LUA module.
This agent follows the SkyWalking tracing and header protocol. It reports tracing data to SkyWalking APM through HTTP protocol. All HTTP 1.1 requests go through Nginx could be collected by this agent.
http { lua_package_path "/Path/to/.../skywalking-nginx-lua/lib/skywalking/?.lua;;"; # Buffer represents the register inform and the queue of the finished segment lua_shared_dict tracing_buffer 100m; # Init is the timer setter and keeper # Setup an infinite loop timer to do register and trace report. init_worker_by_lua_block { local metadata_buffer = ngx.shared.tracing_buffer -- Set service name 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') require("client"):startBackendTimer("http://127.0.0.1:8080") } server { listen 8080; location /ingress { default_type text/html; rewrite_by_lua_block { require("tracer"):start() } -- Target upstream service proxy_pass http://127.0.0.1:8080/backend; body_filter_by_lua_block { if ngx.arg[2] then require("tracer"):finish() end } log_by_lua_block { require("tracer"):prepareForReport() } } } }
All codes in the lib/skywalking
require the *_test.lua
to do the UnitTest. To run that, you need to install
The following libs are required in runtime or test cases, please use LuaRocks
to install them.
luarocks install lua-cjson 2.1.0-1
)This LUA tracing lib is originally designed for Nginx+LUA/OpenResty ecosystems. But we write it to support more complex cases. If you just use this in the Ngnix, Setup Doc should be good enough. The following APIs are for developers or using this lib out of the Nginx case.
require("client"):startBackendTimer("http://127.0.0.1:8080")
. Start the backend timer. This timer register the metadata and report traces to the backend.require("tracer"):start()
. Begin the tracing before the upstream begin.require("tracer"):finish()
. Finish the tracing for this HTTP request.require("tracer"):prepareForReport()
. Prepare the finished segment for further report.TracingContext is the entrance API for lua level tracing.
TracingContext:new(serviceId, serviceInstID)
, create an active tracing context.TracingContext:newNoOP()
, create a no OP tracing context.TracingContext:drainAfterFinished()
, fetch the segment includes all finished spans.Create 2 kinds of span
TracingContext:createEntrySpan(operationName, parent, contextCarrier)
TracingContext:createExitSpan(operationName, parent, peer, contextCarrier)
Have no release yet.
[NIGNX-LUA]
as the issue title prefix.dev-subscribe@skywalking.apache.org
, follow the reply to subscribe the mail list.skywalking
channel at Apache Slack. If the link is not working, find the latest one at Apache INFRA WIKI.Apache 2.0