Commit 3498b89
authored
fix(http): consolidate clients (#1062)
## Overview
The extension was constructing up to 6 separate HTTP clients across
different subsystems (metrics, logs, trace proxy, trace flusher, stats
flusher, and Lambda API). Three of the reqwest::Client instances
(metrics, logs, trace proxy) were identically configured via
get_client(config), and two HttpClient (hyper) instances (trace flusher,
stats flusher) were identically configured via
http_client::create_client().
Each independent client maintains its own connection pool and TLS
sessions, which means:
- Duplicate TLS handshakes to the same Datadog intake hosts
- No connection reuse across subsystems hitting the same endpoints
- Unnecessary memory overhead from redundant connection pools
This change consolidates to 3 clients total:
1. reqwest::Client (no-proxy) — Lambda Extensions API (intentionally
isolated, localhost only)
2. reqwest::Client (shared) — Metrics, Logs, Trace proxy
3. HttpClient (shared) — Trace flusher, Stats flusher
Both reqwest::Client and HttpClient are Arc-based internally, so cloning
is a refcount increment that shares the underlying connection pool.
This also removes the lazy OnceCell initialization from TraceFlusher and
StatsFlusher in favor of eager construction at startup. The lazy init
was retrying on failure, but the only failure modes (bad proxy URL,
unreadable cert file) are configuration errors that won't
self-resolve between retries, so failing fast is preferable.
## Testing
Unit tests, integration tests, and self monitoring1 parent 321fb09 commit 3498b89
File tree
6 files changed
+54
-88
lines changed- bottlecap
- src
- bin/bottlecap
- logs
- traces
- tests
6 files changed
+54
-88
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
295 | 301 | | |
296 | 302 | | |
297 | 303 | | |
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
| 308 | + | |
302 | 309 | | |
303 | 310 | | |
304 | | - | |
305 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
306 | 318 | | |
307 | 319 | | |
308 | 320 | | |
| |||
345 | 357 | | |
346 | 358 | | |
347 | 359 | | |
| 360 | + | |
348 | 361 | | |
349 | 362 | | |
350 | 363 | | |
| |||
1020 | 1033 | | |
1021 | 1034 | | |
1022 | 1035 | | |
| 1036 | + | |
1023 | 1037 | | |
1024 | 1038 | | |
1025 | 1039 | | |
| |||
1048 | 1062 | | |
1049 | 1063 | | |
1050 | 1064 | | |
1051 | | - | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1052 | 1071 | | |
1053 | 1072 | | |
1054 | 1073 | | |
| |||
1059 | 1078 | | |
1060 | 1079 | | |
1061 | 1080 | | |
| 1081 | + | |
1062 | 1082 | | |
1063 | 1083 | | |
1064 | 1084 | | |
| |||
1069 | 1089 | | |
1070 | 1090 | | |
1071 | 1091 | | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1072 | 1100 | | |
1073 | 1101 | | |
1074 | 1102 | | |
| |||
1080 | 1108 | | |
1081 | 1109 | | |
1082 | 1110 | | |
| 1111 | + | |
1083 | 1112 | | |
1084 | 1113 | | |
1085 | 1114 | | |
| |||
1092 | 1121 | | |
1093 | 1122 | | |
1094 | 1123 | | |
| 1124 | + | |
1095 | 1125 | | |
1096 | 1126 | | |
1097 | 1127 | | |
| |||
1117 | 1147 | | |
1118 | 1148 | | |
1119 | 1149 | | |
| 1150 | + | |
1120 | 1151 | | |
1121 | 1152 | | |
1122 | 1153 | | |
| |||
1157 | 1188 | | |
1158 | 1189 | | |
1159 | 1190 | | |
| 1191 | + | |
1160 | 1192 | | |
1161 | 1193 | | |
1162 | 1194 | | |
| |||
1180 | 1212 | | |
1181 | 1213 | | |
1182 | 1214 | | |
1183 | | - | |
1184 | 1215 | | |
1185 | 1216 | | |
1186 | 1217 | | |
1187 | 1218 | | |
1188 | | - | |
| 1219 | + | |
1189 | 1220 | | |
1190 | 1221 | | |
1191 | 1222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| 38 | + | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
199 | 198 | | |
200 | 199 | | |
201 | 200 | | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| 41 | + | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
| |||
33 | 30 | | |
34 | 31 | | |
35 | 32 | | |
| 33 | + | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
42 | | - | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
97 | 95 | | |
98 | 96 | | |
99 | 97 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 98 | | |
108 | 99 | | |
109 | 100 | | |
110 | 101 | | |
111 | | - | |
| 102 | + | |
112 | 103 | | |
113 | 104 | | |
114 | 105 | | |
| |||
170 | 161 | | |
171 | 162 | | |
172 | 163 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | 164 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 30 | + | |
35 | 31 | | |
36 | 32 | | |
37 | 33 | | |
| |||
40 | 36 | | |
41 | 37 | | |
42 | 38 | | |
| 39 | + | |
43 | 40 | | |
44 | 41 | | |
45 | 42 | | |
| |||
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
68 | | - | |
| 65 | + | |
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
| |||
83 | 80 | | |
84 | 81 | | |
85 | 82 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 83 | + | |
91 | 84 | | |
92 | 85 | | |
93 | 86 | | |
| |||
167 | 160 | | |
168 | 161 | | |
169 | 162 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | 163 | | |
197 | 164 | | |
198 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
0 commit comments