|
|
@@ -13,6 +13,7 @@
|
|
|
#define PROTOCOL_HTTP2 11
|
|
|
#define PROTOCOL_DUBBO2 12
|
|
|
#define PROTOCOL_DNS 13
|
|
|
+#define PROTOCOL_DM 14
|
|
|
|
|
|
|
|
|
|
|
|
@@ -57,6 +58,7 @@
|
|
|
#include "http2.c"
|
|
|
#include "dubbo2.c"
|
|
|
#include "dns.c"
|
|
|
+#include "dm.c"
|
|
|
#include "apm_trace.c"
|
|
|
|
|
|
// go type l7Event struct && type RequestData struct
|
|
|
@@ -202,7 +204,7 @@ void send_event(void *ctx, struct l7_event *e, __u32 pid, __u64 fd) {
|
|
|
__u64 *timestamp = bpf_map_lookup_elem(&connection_timestamps, &sk);
|
|
|
if (timestamp) {
|
|
|
if (*timestamp == 0) {
|
|
|
-// bpf_printk("timestamp=0");
|
|
|
+ bpf_printk("timestamp=0");
|
|
|
return;
|
|
|
}
|
|
|
e->connection_timestamp = *timestamp;
|
|
|
@@ -395,10 +397,13 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
} else if (is_mysql_query(payload, size, &req->request_type)) {
|
|
|
cw_bpf_debug("[Enter][Mysql]:thread_id:%d\n",tid);
|
|
|
if (req->request_type == MYSQL_COM_STMT_CLOSE) {
|
|
|
+ return 0;
|
|
|
struct l7_event *e = bpf_map_lookup_elem(&l7_event_heap, &zero);
|
|
|
if (!e) {
|
|
|
return 0;
|
|
|
}
|
|
|
+ __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
+ e->trace_id = trace_id;
|
|
|
e->protocol = PROTOCOL_MYSQL;
|
|
|
e->method = METHOD_STATEMENT_CLOSE;
|
|
|
e->payload_size = size;
|
|
|
@@ -408,6 +413,9 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
|
|
|
return 0;
|
|
|
}
|
|
|
req->protocol = PROTOCOL_MYSQL;
|
|
|
+ } else if (is_dm_query(payload, size,&req->request_type)) {
|
|
|
+ bpf_printk("[Enter][DM]:req->request_type:%d\n",req->request_type);
|
|
|
+ req->protocol = PROTOCOL_DM;
|
|
|
} else if (is_mongo_query(payload, size)) {
|
|
|
req->protocol = PROTOCOL_MONGO;
|
|
|
} else if (is_rabbitmq_produce(payload, size)) {
|
|
|
@@ -533,7 +541,9 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
e->method = METHOD_UNKNOWN;
|
|
|
e->statement_id = 0;
|
|
|
e->payload_size = 0;
|
|
|
-
|
|
|
+ __u8 b[8];
|
|
|
+ bpf_read(payload, b);
|
|
|
+ bpf_printk("payload44444:[0x%x]",b[4]);
|
|
|
// __u32 k0 = 0;
|
|
|
// struct member_fields_offset *offset = members_offset__lookup(&k0);
|
|
|
// if (!offset)
|
|
|
@@ -620,6 +630,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
struct l7_request *req = bpf_map_lookup_elem(&active_l7_requests, &k);
|
|
|
int response = 0;
|
|
|
if (!req) {
|
|
|
+ bpf_printk("no req? 6:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
if (is_dns_response(payload, ret, &k.stream_id, &e->status)) {
|
|
|
req = bpf_map_lookup_elem(&active_l7_requests, &k);
|
|
|
if (!req) {
|
|
|
@@ -646,6 +657,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
send_event(ctx, e, k.pid, k.fd);
|
|
|
return 0;
|
|
|
} else {
|
|
|
+ bpf_printk("bb 6:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
@@ -655,6 +667,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
COPY_PAYLOAD(e->payload, req->payload_size, req->payload);
|
|
|
|
|
|
bpf_map_delete_elem(&active_l7_requests, &k);
|
|
|
+ bpf_printk("delete req--------:[0x%x] k.pid:%d, k.fd:%d",b[4],k.pid,k.fd);
|
|
|
if (e->protocol == PROTOCOL_HTTP) {
|
|
|
__u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
e->trace_id = trace_id;
|
|
|
@@ -707,7 +720,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
} else if (e->protocol == PROTOCOL_MEMCACHED) {
|
|
|
response = is_memcached_response(payload, ret, &e->status);
|
|
|
} else if (e->protocol == PROTOCOL_MYSQL) {
|
|
|
- cw_bpf_debug("[Response][Mysql]:thread_id:%d\n",tid);
|
|
|
+ bpf_printk("[Response][Mysql]:thread_id:%d\n",tid);
|
|
|
__u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
// cw_bpf_debug("[Mysql] trace_id:%llu", trace_id);
|
|
|
e->trace_id = trace_id;
|
|
|
@@ -715,6 +728,13 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
|
|
|
if (req->request_type == MYSQL_COM_STMT_PREPARE) {
|
|
|
e->method = METHOD_STATEMENT_PREPARE;
|
|
|
}
|
|
|
+ } else if (e->protocol == PROTOCOL_DM) {
|
|
|
+ __u64 trace_id = get_apm_trace_id(pid, tid);
|
|
|
+ e->trace_id = trace_id;
|
|
|
+ bpf_printk("[DM] trace_id:%llu", trace_id);
|
|
|
+ bpf_printk("[Response][DM] ---------start");
|
|
|
+ response = is_dm_response(payload, ret, req->request_type, &e->statement_id, &e->status);
|
|
|
+ bpf_printk("[Response][DM]end ---------- %d\n",e->status);
|
|
|
} else if (e->protocol == PROTOCOL_MONGO) {
|
|
|
response = is_mongo_response(payload, ret, req->partial);
|
|
|
if (response == 2) { // partial
|