Skip to content

Commit d3a9ba2

Browse files
committed
feature: initial support for dtrace static probes. it requires nginx-dtrace though: https://github.com/agentzh/nginx-dtrace
1 parent c25689b commit d3a9ba2

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ if [ $ngx_found = yes ]; then
247247
CORE_LIBS="-Wl,-E $CORE_LIBS"
248248
fi
249249

250+
NGX_DTRACE_PROVIDERS="$NGX_DTRACE_PROVIDERS $ngx_addon_dir/dtrace/ngx_lua_provider.d"
251+
NGX_TAPSET_SRCS="$NGX_TAPSET_SRCS $ngx_addon_dir/tapset/ngx_lua.stp"
252+
250253
USE_MD5=YES
251254
USE_SHA1=YES
252255

dtrace/ngx_lua_provider.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
typedef struct { int dummy; } lua_State;
2+
3+
4+
provider nginx_lua {
5+
probe http__lua__register__preload__package(lua_State *L, char *pkg);
6+
};
7+
8+
9+
#pragma D attributes Evolving/Evolving/Common provider nginx provider
10+
#pragma D attributes Private/Private/Unknown provider nginx module
11+
#pragma D attributes Private/Private/Unknown provider nginx function
12+
#pragma D attributes Private/Private/Common provider nginx name
13+
#pragma D attributes Evolving/Evolving/Common provider nginx args
14+

src/ngx_http_lua_probe.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef NGX_HTTP_LUA_PROBE_H
2+
#define NGX_HTTP_LUA_PROBE_H
3+
4+
5+
#include <ngx_config.h>
6+
#include <ngx_core.h>
7+
#include <ngx_http.h>
8+
9+
10+
#if defined(NGX_DTRACE) && NGX_DTRACE
11+
12+
#include <ngx_dtrace_provider.h>
13+
14+
#define ngx_http_lua_probe_register_preload_package(L, pkg) \
15+
NGINX_LUA_HTTP_LUA_REGISTER_PRELOAD_PACKAGE(L, pkg)
16+
17+
#else /* !(NGX_DTRACE) */
18+
19+
#define ngx_http_lua_probe_register_preload_package(L, pkg)
20+
21+
#endif
22+
23+
24+
#endif /* NGX_HTTP_LUA_PROBE_H */

tapset/ngx_lua.stp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function ngx_http_lua_ctx_context(r)
2+
{
3+
4+
}
5+

0 commit comments

Comments
 (0)