在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:skywalking-nginx-lua开源软件地址:https://gitee.com/OpenSkywalking/skywalking-nginx-lua开源软件介绍:Apache SkyWalking Nginx AgentSkyWalking 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. Setup DocThe following setup is targeting for OpenResty, if you want SkyWalking integrated Gateway, you could jump to http { lua_package_path "/Path/to/.../skywalking-nginx-lua/lib/?.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 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', false) -- set random seed require("skywalking.util").set_randomseed() require("skywalking.client"):startBackendTimer("http://127.0.0.1:8080") -- If there is a bug of this `tablepool` implementation, we can -- disable it in this way -- require("skywalking.util").disable_tablepool() skywalking_tracer = require("skywalking.tracer") } server { listen 8090; location /ingress { default_type text/html; rewrite_by_lua_block { ------------------------------------------------------ -- 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 ------------------------------------------------------ skywalking_tracer:start("upstream service") -- If you want correlation custom data to the downstream service -- skywalking_tracer:start("upstream service", {custom = "custom_value"}) } -- Target upstream service proxy_pass http://127.0.0.1:8080/backend; body_filter_by_lua_block { if ngx.arg[2] then skywalking_tracer:finish() end } log_by_lua_block { skywalking_tracer:prepareForReport() } } }} DownloadPlease head to the releases page to download a release of Apache SkyWalking. Require SkyWalking 8 OAP server Set up dev envDebug StartupBy using the
2020/04/04 15:15:37 [debug] 12089#1446111: *4 [lua] content_by_lua(nginx.conf:175):4: Instance report request = {"service":"User Service Name","serviceInstance":"User Service Instance Name","properties":[{"language":"Lua"}]}2020/04/04 15:15:37 [debug] 12089#1446111: *2 [lua] client.lua:89: reportServiceInstance(): Instance report response = {}
2020/04/04 15:15:40 [debug] 12089#1446111: *4 [lua] content_by_lua(nginx.conf:188):3: KeepAlive request = {"service":"User Service Name","serviceInstance":"User Service Instance Name"}
2020/04/04 15:15:46 [debug] 12089#1446111: *11 [lua] tracer.lua:83: prepareForReport(): segment = {"traceId":"1585984546953.410917649.45972","serviceInstance":"User Service Instance Name","spans":[{"operationName":"\/tier2\/lb","startTime":1585984546967,"endTime":1585984546968,"spanType":"Exit","spanId":1,"isError":false,"parentSpanId":0,"componentId":6000,"peer":"backend service","spanLayer":"Http"},{"operationName":"\/tier2\/lb","startTime":1585984546967,"tags":[{"key":"http.method","value":"GET"},{"key":"http.params","value":"http:\/\/127.0.0.1\/tier2\/lb"}],"endTime":1585984546968,"spanType":"Entry","spanId":0,"isError":false,"parentSpanId":-1,"componentId":6000,"refs":[{"traceId":"1585984546953.410917649.45972","networkAddressUsedAtPeer":"upstream service","parentEndpoint":"\/ingress","parentServiceInstance":"User Service Instance Name","parentSpanId":1,"parentService":"User Service Name","parentTraceSegmentId":"1585984546953.410917649.45972","refType":"CrossProcess"}],"spanLayer":"Http"}],"service":"User Service Name","traceSegmentId":"1585984546967.449397702.9959"}2020/04/04 15:15:46 [debug] 12089#1446111: *11 [lua] tracer.lua:87: prepareForReport(): segment buffer size = 12020/04/04 15:15:46 [debug] 12089#1446111: *8 [lua] tracer.lua:83: prepareForReport(): segment = {"traceId":"1585984546953.410917649.45972","serviceInstance":"User Service Instance Name","spans":[{"operationName":"\/ingress","startTime":1585984546953,"endTime":1585984546968,"spanType":"Exit","spanId":1,"isError":false,"parentSpanId":0,"componentId":6000,"peer":"upstream service","spanLayer":"Http"},{"operationName":"\/ingress","startTime":1585984546953,"tags":[{"key":"http.method","value":"GET"},{"key":"http.params","value":"http:\/\/localhost\/ingress"}],"endTime":1585984546968,"spanType":"Entry","spanId":0,"parentSpanId":-1,"isError":false,"spanLayer":"Http","componentId":6000}],"service":"User Service Name","traceSegmentId":"1585984546953.410917649.45972"} Local Development and Unit TestsAll codes in the
The following libs are required in runtime or test cases, please use
APIsThis 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. Nginx APIs
Tracing APIs at LUA levelTracingContext is the entrance API for lua level tracing.
Create 2 kinds of span
Contact Us
Release GuideAll committers should follow Release Guide to publish the official release. LicenseApache 2.0 |
请发表评论