Commit f72b8c1
committed
feat(tracing): add chunked tail-call traceparent scanner for large HTTP headers (fixes #1381)
When a Traceparent header is preceded by large headers (e.g. Authorization
tokens, X-Custom-Data payloads), it can land beyond the initial 1 KB eBPF
capture window and be silently missed. This change adds a tail-call based
chunked scanner that walks the request buffer in 956-byte steps, stopping at
the end-of-headers marker or when the traceparent is found.
bpf/common/trace_util.h:
- Add bpf_strstr_tp_eoh(): single bpf_loop pass that finds either the
traceparent or the \r\n\r\n end-of-headers marker, whichever comes first.
Uses the existing k_tp_pos_not_found sentinel from the preceding bugfix PR.
bpf/generictracer/k_tracer_tailcall.h:
- Add k_tail_parse_traceparent_http = 10. k_tail_continue_netfd_read moves
from index 10 to 11. WARNING: changing jump_table indices is a hard ABI
break; the BPF objects and both Go loaders (generictracer and gotracer)
must be updated atomically — a full pod restart is required.
bpf/generictracer/protocol_http.h:
- Add obi_parse_traceparent_http: the new tail-call program. Iterates up to
MAX_CHUNKS (29) times, calling bpf_strstr_tp_eoh on each 956-byte slice.
Stops at EOH, traceparent found, or iteration limit.
bpf/generictracer/protocol_handler.c:
- Dispatch to obi_parse_traceparent_http from the still_reading path in
obi_handle_buf_with_args when chunked scanning is configured.
bpf/generictracer/k_tracer.c:
- Support ITER_UBUF and single-segment ITER_IOVEC in return_recvmsg; set
u_buf_is_user=1 so downstream code uses bpf_probe_read_user.
bpf/generictracer/k_tracer_defs.h:
- Rename handle_buf_with_connection to handle_buf_with_connection_ext;
add handle_user_buf_with_connection wrapper that sets u_buf_is_user=1.
bpf/generictracer/ssl_defs.h, java_tls.c:
- Switch SSL/Java-TLS paths to handle_user_buf_with_connection.
pkg/internal/ebpf/generictracer/generictracer.go:
- Register obi_parse_traceparent_http in the jump table at index 10.
- Write bpf_max_request_tp_parse_size_kb from MaxRequestTPParseSizeKB;
set to 0 on legacy kernels that lack bpf_loop.
pkg/internal/ebpf/gotracer/gotracer.go:
- Update k_tail_continue_netfd_read registration from index 10 to 11.
pkg/ebpf/common/http_transform.go:
- Use event.OriginalTraceId (not event.Tp.TraceId) as the large-buffer
map key in extractTCPLargeBuffer. The scanner may overwrite Tp.TraceId
after the buffer is stored; OriginalTraceId is stable.
pkg/ebpf/common/common.go:
- Register a dummy stub for obi_parse_traceparent_http on legacy kernels
that do not support bpf_loop (dummy.Copy() from the preceding bugfix PR).
pkg/config/ebpf_tracer.go, pkg/obi/config.go:
- Add MaxRequestTPParseSizeKB (default 4, range 4-27 KB). Controls the
maximum request size scanned by the chunked parser.
devdocs/config/CONFIG.md, config-schema.json: document the new knob.
internal/test/integration/components/tpclient/service.js:
- Add /with-huge-tp endpoint; refactor /with-tp span-ID increment to use
the new nextTraceparent() helper.
internal/test/integration/traceparent_extraction_test.go:
- Add testWithHugeHeadersTraceparent: sends a 2500-byte filler header
before Traceparent on the HTTP/kprobe path and asserts that all spans
in the tpclient-a/b/c chain carry the static trace ID.1 parent f151a9d commit f72b8c1
21 files changed
Lines changed: 773 additions & 56 deletions
File tree
- bpf
- common
- generictracer
- devdocs/config
- internal/test/integration
- components/tpclient
- pkg
- config
- ebpf/common
- internal/ebpf
- generictracer
- gotracer
- obi
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
101 | 168 | | |
102 | 169 | | |
103 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
963 | 963 | | |
964 | 964 | | |
965 | 965 | | |
| 966 | + | |
| 967 | + | |
966 | 968 | | |
967 | 969 | | |
968 | 970 | | |
| |||
972 | 974 | | |
973 | 975 | | |
974 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
975 | 993 | | |
976 | 994 | | |
977 | 995 | | |
| |||
1025 | 1043 | | |
1026 | 1044 | | |
1027 | 1045 | | |
1028 | | - | |
1029 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
1030 | 1056 | | |
1031 | 1057 | | |
1032 | 1058 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| |||
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
86 | 97 | | |
87 | 98 | | |
88 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
89 | 122 | | |
90 | 123 | | |
91 | 124 | | |
| |||
101 | 134 | | |
102 | 135 | | |
103 | 136 | | |
| 137 | + | |
104 | 138 | | |
105 | 139 | | |
106 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | 145 | | |
| 146 | + | |
153 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
159 | 172 | | |
160 | 173 | | |
161 | 174 | | |
| |||
0 commit comments