Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve eBPF context propagation stability #368

Merged
merged 72 commits into from
Oct 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
f380f11
Add WithPID InstrumentationOption
RonFed Sep 29, 2023
2133ddd
Update changelog
RonFed Sep 29, 2023
b7fa23d
Improve validation for inst config
RonFed Sep 30, 2023
254a80b
WIP
RonFed Sep 30, 2023
f93f386
more WIP
RonFed Oct 1, 2023
4470cb6
Remove exePath checks
RonFed Oct 1, 2023
00d0226
Fix lint
RonFed Oct 1, 2023
d82ad0a
remove traces-orig.json
RonFed Oct 1, 2023
b087541
.
RonFed Oct 1, 2023
a171403
Init log if not initialized in NewInstrumentation
RonFed Oct 2, 2023
aae2823
fix os.Exit
RonFed Oct 2, 2023
7ff2deb
Merge branch 'main' into add_WithPID
RonFed Oct 2, 2023
4b072cd
test
RonFed Oct 2, 2023
8dd135b
Test Madvise
RonFed Oct 3, 2023
d34c19f
More testing
RonFed Oct 3, 2023
0a7acd2
More testing...
RonFed Oct 3, 2023
f9125e2
....
RonFed Oct 3, 2023
fd73a5c
,,,,,
RonFed Oct 3, 2023
41b4d9c
....
RonFed Oct 3, 2023
3e6b20f
fix compilation
RonFed Oct 3, 2023
8aa390b
context_ptr fix
RonFed Oct 4, 2023
b4066bf
.,,
RonFed Oct 4, 2023
aa9d84f
.
RonFed Oct 4, 2023
c00e407
fix context propagation
RonFed Oct 4, 2023
2527b4e
Add padding
RonFed Oct 4, 2023
6527023
test no slice append
RonFed Oct 4, 2023
a87add1
debugging
RonFed Oct 4, 2023
ad6d428
more testing
RonFed Oct 5, 2023
3874781
...
RonFed Oct 5, 2023
d856c1f
test append to slice
RonFed Oct 5, 2023
2d8fb1e
Add validation in inject header for http instrumentation
RonFed Oct 5, 2023
8d0d8d7
fix context
RonFed Oct 5, 2023
a156b4f
http client is root?
RonFed Oct 5, 2023
8efd894
...
RonFed Oct 5, 2023
f6b2674
...
RonFed Oct 5, 2023
3f256fb
...
RonFed Oct 5, 2023
980e9e9
........
RonFed Oct 5, 2023
b70efbb
fff
RonFed Oct 5, 2023
519b6ca
use get_go_interface_instance
RonFed Oct 6, 2023
a80aa63
include go types in uprobe.h
RonFed Oct 6, 2023
b79b641
more context propagation
RonFed Oct 6, 2023
43053de
add include
RonFed Oct 6, 2023
18a8f79
checking if http client uprobe context was created
RonFed Oct 6, 2023
41bed4c
align get_consistent_key
RonFed Oct 6, 2023
cd3ebe5
return ctx_val
RonFed Oct 6, 2023
9bcfc45
test mlock
RonFed Oct 6, 2023
9ed2a9b
more testing
RonFed Oct 6, 2023
c842141
Test reducing the mmap size
RonFed Oct 7, 2023
48d6414
Increase back the pages allocated
RonFed Oct 7, 2023
a038935
refactor context prop
RonFed Oct 8, 2023
7cd9460
Add volataile const for global structs
RonFed Oct 8, 2023
c714202
Add get_go_string_from_user_ptr helper
RonFed Oct 8, 2023
4b1bb68
fix start time at grpc server
RonFed Oct 8, 2023
5f7b9c2
mem alloc fixup
RonFed Oct 8, 2023
f497a5d
reduce allocation
RonFed Oct 8, 2023
ef34a95
Add Allocater
RonFed Oct 9, 2023
4b7bc37
remove unused definition
RonFed Oct 9, 2023
1bf1fd0
add logic to stop_tracking_span
RonFed Oct 10, 2023
296f4fd
handle error at uprobe_return
RonFed Oct 10, 2023
a89548c
Remove root arg for uprobe_return
RonFed Oct 10, 2023
233b4ea
Merge branch 'main' into ebpf_context_propagation
RonFed Oct 10, 2023
eed4cd8
remove unused import
RonFed Oct 10, 2023
51f372a
Cleanup
RonFed Oct 10, 2023
692a391
Fix linter
RonFed Oct 10, 2023
c05fb44
Merge branch 'main' into ebpf_context_propagation
RonFed Oct 10, 2023
d90508f
Merge branch 'main' into ebpf_context_propagation
RonFed Oct 11, 2023
c73064d
Add error handling to avoid multiple map entries for the same uprobe
RonFed Oct 11, 2023
ca7f5ed
Improve stop_tracking_span to handle more cases
RonFed Oct 11, 2023
9801024
increase max concurrent spans capacity for maps
RonFed Oct 11, 2023
06116f2
remove printk's
RonFed Oct 11, 2023
f477690
Merge branch 'main' into ebpf_context_propagation
RonFed Oct 14, 2023
1e996bd
Fix stop_tracking_span
RonFed Oct 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
align get_consistent_key
RonFed committed Oct 6, 2023

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 41bed4c889af54a54df41906532cbfa3c05ed949
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

4 changes: 1 addition & 3 deletions internal/include/arguments.h
Original file line number Diff line number Diff line change
@@ -80,9 +80,7 @@ static __always_inline void *get_consistent_key(struct pt_regs *ctx, void *conte
return (void *)GOROUTINE(ctx);
}

void *ctx_ptr = 0;
bpf_probe_read(&ctx_ptr, sizeof(ctx_ptr), contextContext);
return ctx_ptr;
return contextContext;
}

#endif
4 changes: 3 additions & 1 deletion internal/include/go_context.h
Original file line number Diff line number Diff line change
@@ -114,7 +114,9 @@ static __always_inline void *get_Go_context(void *ctx, int context_pos, u64 cont
if (passed_as_arg) {
return arg;
}
return get_go_interface_instance(arg + context_offset);
void *ctx_addr = get_go_interface_instance(arg + context_offset);
void *ctx_val = 0;
bpf_probe_read_user(&ctx_val, sizeof(ctx_val), ctx_addr);
}

#endif
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ int uprobe_server_handleStream(struct pt_regs *ctx)
void *ctx_address = get_go_interface_instance(stream_ptr + stream_ctx_pos);
void *ctx_iface = 0;
bpf_probe_read(&ctx_iface, sizeof(ctx_iface), ctx_address);
void *key = get_consistent_key(ctx, ctx_address);
void *key = get_consistent_key(ctx, ctx_iface);

// Write event
bpf_map_update_elem(&grpc_events, &key, &grpcReq, 0);
Original file line number Diff line number Diff line change
@@ -157,16 +157,17 @@ int uprobe_HttpClient_Do(struct pt_regs *ctx) {

// Get parent if exists
void *context_ptr = get_go_interface_instance(req_ptr+ctx_ptr_pos);
void *key = get_consistent_key(ctx, context_ptr);
void *context_ptr_val = 0;
bpf_probe_read(&context_ptr_val, sizeof(context_ptr_val), context_ptr);
void *key = get_consistent_key(ctx, context_ptr_val);
void *httpReq_ptr = bpf_map_lookup_elem(&http_events, &key);
if (httpReq_ptr != NULL)
{
bpf_printk("client: httpReq_ptr is not null");
return 0;
}
//void *context_ptr = (void *)(req_ptr+ctx_ptr_pos);
void *context_ptr_val = 0;
bpf_probe_read(&context_ptr_val, sizeof(context_ptr_val), context_ptr);

struct span_context *parent_span_ctx = get_parent_span_context(context_ptr_val);
if (parent_span_ctx != NULL) {
bpf_probe_read(&httpReq.psc, sizeof(httpReq.psc), parent_span_ctx);
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@ int uprobe_ServerMux_ServeHTTP(struct pt_regs *ctx)
void *req_ctx_ptr = 0;
void *ctx_address = get_go_interface_instance(req_ptr + ctx_ptr_pos);
bpf_probe_read(&req_ctx_ptr, sizeof(req_ctx_ptr), ctx_address);
void *key = get_consistent_key(ctx, ctx_address);
void *key = get_consistent_key(ctx, req_ctx_ptr);
void *httpReq_ptr = bpf_map_lookup_elem(&http_events, &key);
if (httpReq_ptr != NULL)
{