@encore.dev/sdk 2.0.0-beta.14 → 2.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/README.md +144 -90
  2. package/app_meta.ts +56 -54
  3. package/config/config.test.ts +47 -13
  4. package/config/config.ts +60 -57
  5. package/config/secrets.ts +47 -50
  6. package/config/value.ts +23 -26
  7. package/cron/mod.test.ts +12 -0
  8. package/cron/mod.ts +37 -22
  9. package/dist/app_meta.d.ts +52 -50
  10. package/dist/app_meta.d.ts.map +1 -1
  11. package/dist/app_meta.js +2 -2
  12. package/dist/app_meta.js.map +1 -1
  13. package/dist/config/config.d.ts +58 -55
  14. package/dist/config/config.d.ts.map +1 -1
  15. package/dist/config/config.js +8 -9
  16. package/dist/config/config.js.map +1 -1
  17. package/dist/config/secrets.d.ts +45 -50
  18. package/dist/config/secrets.d.ts.map +1 -1
  19. package/dist/config/secrets.js +11 -9
  20. package/dist/config/secrets.js.map +1 -1
  21. package/dist/config/value.d.ts +20 -23
  22. package/dist/config/value.d.ts.map +1 -1
  23. package/dist/config/value.js +20 -23
  24. package/dist/config/value.js.map +1 -1
  25. package/dist/cron/mod.d.ts +34 -20
  26. package/dist/cron/mod.d.ts.map +1 -1
  27. package/dist/cron/mod.js +13 -13
  28. package/dist/cron/mod.js.map +1 -1
  29. package/dist/frontends/mod.d.ts +20 -19
  30. package/dist/frontends/mod.d.ts.map +1 -1
  31. package/dist/frontends/mod.js +20 -19
  32. package/dist/frontends/mod.js.map +1 -1
  33. package/dist/gateway/errors.d.ts +28 -30
  34. package/dist/gateway/errors.d.ts.map +1 -1
  35. package/dist/gateway/errors.js +29 -31
  36. package/dist/gateway/errors.js.map +1 -1
  37. package/dist/gateway/match.d.ts +54 -54
  38. package/dist/gateway/match.d.ts.map +1 -1
  39. package/dist/gateway/match.js +56 -56
  40. package/dist/gateway/match.js.map +1 -1
  41. package/dist/gateway/middleware.d.ts +62 -64
  42. package/dist/gateway/middleware.d.ts.map +1 -1
  43. package/dist/gateway/middleware.js +1 -1
  44. package/dist/gateway/middleware.js.map +1 -1
  45. package/dist/gateway/mod.d.ts +64 -67
  46. package/dist/gateway/mod.d.ts.map +1 -1
  47. package/dist/gateway/mod.js +72 -76
  48. package/dist/gateway/mod.js.map +1 -1
  49. package/dist/gateway/request.d.ts +138 -134
  50. package/dist/gateway/request.d.ts.map +1 -1
  51. package/dist/gateway/request.js +117 -108
  52. package/dist/gateway/request.js.map +1 -1
  53. package/dist/gateway/serve.d.ts +29 -34
  54. package/dist/gateway/serve.d.ts.map +1 -1
  55. package/dist/gateway/serve.js +51 -56
  56. package/dist/gateway/serve.js.map +1 -1
  57. package/dist/gateways/mod.d.ts +23 -21
  58. package/dist/gateways/mod.d.ts.map +1 -1
  59. package/dist/gateways/mod.js +25 -23
  60. package/dist/gateways/mod.js.map +1 -1
  61. package/dist/internal/otel/http.d.ts +4 -2
  62. package/dist/internal/otel/http.d.ts.map +1 -1
  63. package/dist/internal/otel/http.js +32 -5
  64. package/dist/internal/otel/http.js.map +1 -1
  65. package/dist/internal/runtime/napi/napi.cjs +6 -5
  66. package/dist/internal/runtime/napi/napi.d.cts +58 -16
  67. package/dist/internal/runtime/shutdown.d.ts +75 -57
  68. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  69. package/dist/internal/runtime/shutdown.js +88 -84
  70. package/dist/internal/runtime/shutdown.js.map +1 -1
  71. package/dist/log/logger.d.ts +43 -37
  72. package/dist/log/logger.d.ts.map +1 -1
  73. package/dist/log/logger.js +26 -25
  74. package/dist/log/logger.js.map +1 -1
  75. package/dist/metrics/mod.d.ts +133 -114
  76. package/dist/metrics/mod.d.ts.map +1 -1
  77. package/dist/metrics/mod.js +109 -101
  78. package/dist/metrics/mod.js.map +1 -1
  79. package/dist/otel.d.ts +6 -3
  80. package/dist/otel.d.ts.map +1 -1
  81. package/dist/otel.js +6 -3
  82. package/dist/otel.js.map +1 -1
  83. package/dist/pubsub/subscription.d.ts +88 -116
  84. package/dist/pubsub/subscription.d.ts.map +1 -1
  85. package/dist/pubsub/subscription.js +14 -17
  86. package/dist/pubsub/subscription.js.map +1 -1
  87. package/dist/pubsub/topic.d.ts +86 -113
  88. package/dist/pubsub/topic.d.ts.map +1 -1
  89. package/dist/pubsub/topic.js +68 -82
  90. package/dist/pubsub/topic.js.map +1 -1
  91. package/dist/redaction/mod.d.ts +62 -0
  92. package/dist/redaction/mod.d.ts.map +1 -0
  93. package/dist/redaction/mod.js +102 -0
  94. package/dist/redaction/mod.js.map +1 -0
  95. package/dist/reqctx/mod.d.ts +83 -86
  96. package/dist/reqctx/mod.d.ts.map +1 -1
  97. package/dist/reqctx/mod.js +39 -41
  98. package/dist/reqctx/mod.js.map +1 -1
  99. package/dist/services/index.d.ts +76 -75
  100. package/dist/services/index.d.ts.map +1 -1
  101. package/dist/services/index.js +73 -71
  102. package/dist/services/index.js.map +1 -1
  103. package/dist/shutdown/mod.d.ts +26 -25
  104. package/dist/shutdown/mod.d.ts.map +1 -1
  105. package/dist/shutdown/mod.js +26 -25
  106. package/dist/shutdown/mod.js.map +1 -1
  107. package/dist/storage/clickhouse/database.d.ts +113 -115
  108. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  109. package/dist/storage/clickhouse/database.js +65 -79
  110. package/dist/storage/clickhouse/database.js.map +1 -1
  111. package/dist/storage/clickhouse/errors.d.ts +25 -26
  112. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  113. package/dist/storage/clickhouse/errors.js +15 -17
  114. package/dist/storage/clickhouse/errors.js.map +1 -1
  115. package/dist/storage/clickhouse/mod.d.ts +10 -10
  116. package/dist/storage/clickhouse/mod.js +10 -10
  117. package/dist/storage/objects/bucket.d.ts +230 -203
  118. package/dist/storage/objects/bucket.d.ts.map +1 -1
  119. package/dist/storage/objects/bucket.js +146 -106
  120. package/dist/storage/objects/bucket.js.map +1 -1
  121. package/dist/storage/objects/error.d.ts +4 -4
  122. package/dist/storage/objects/error.js +4 -4
  123. package/dist/storage/objects/mod.d.ts +1 -1
  124. package/dist/storage/objects/mod.d.ts.map +1 -1
  125. package/dist/storage/objects/mod.js.map +1 -1
  126. package/dist/storage/objects/refs.d.ts +2 -5
  127. package/dist/storage/objects/refs.d.ts.map +1 -1
  128. package/dist/storage/objects/refs.js.map +1 -1
  129. package/dist/storage/postgres/database.d.ts +124 -149
  130. package/dist/storage/postgres/database.d.ts.map +1 -1
  131. package/dist/storage/postgres/database.js +98 -135
  132. package/dist/storage/postgres/database.js.map +1 -1
  133. package/dist/storage/postgres/errors.d.ts +42 -48
  134. package/dist/storage/postgres/errors.d.ts.map +1 -1
  135. package/dist/storage/postgres/errors.js +44 -51
  136. package/dist/storage/postgres/errors.js.map +1 -1
  137. package/dist/storage/postgres/interval.d.ts +19 -19
  138. package/dist/storage/postgres/interval.d.ts.map +1 -1
  139. package/dist/storage/postgres/interval.js +21 -21
  140. package/dist/storage/postgres/interval.js.map +1 -1
  141. package/dist/storage/redis/bitfield.d.ts +48 -23
  142. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  143. package/dist/storage/redis/bitfield.js +38 -19
  144. package/dist/storage/redis/bitfield.js.map +1 -1
  145. package/dist/storage/redis/command.d.ts +16 -12
  146. package/dist/storage/redis/command.d.ts.map +1 -1
  147. package/dist/storage/redis/command.js +16 -12
  148. package/dist/storage/redis/command.js.map +1 -1
  149. package/dist/storage/redis/commands.d.ts +99 -100
  150. package/dist/storage/redis/commands.d.ts.map +1 -1
  151. package/dist/storage/redis/commands.js +84 -85
  152. package/dist/storage/redis/commands.js.map +1 -1
  153. package/dist/storage/redis/database.d.ts +138 -122
  154. package/dist/storage/redis/database.d.ts.map +1 -1
  155. package/dist/storage/redis/database.js +120 -101
  156. package/dist/storage/redis/database.js.map +1 -1
  157. package/dist/storage/redis/mod.d.ts +52 -48
  158. package/dist/storage/redis/mod.d.ts.map +1 -1
  159. package/dist/storage/redis/mod.js +52 -48
  160. package/dist/storage/redis/mod.js.map +1 -1
  161. package/dist/storage/redis/options.d.ts +26 -24
  162. package/dist/storage/redis/options.d.ts.map +1 -1
  163. package/dist/storage/redis/options.js.map +1 -1
  164. package/dist/storage/redis/pubsub.d.ts +16 -16
  165. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  166. package/dist/storage/redis/pubsub.js +14 -14
  167. package/dist/storage/redis/pubsub.js.map +1 -1
  168. package/dist/storage/redis/reply.d.ts +80 -72
  169. package/dist/storage/redis/reply.d.ts.map +1 -1
  170. package/dist/storage/redis/reply.js +53 -46
  171. package/dist/storage/redis/reply.js.map +1 -1
  172. package/dist/storage/redis/scan.d.ts +4 -4
  173. package/dist/storage/redis/scan.d.ts.map +1 -1
  174. package/dist/storage/redis/scan.js +6 -6
  175. package/dist/storage/redis/scan.js.map +1 -1
  176. package/dist/storage/redis/script.d.ts +28 -21
  177. package/dist/storage/redis/script.d.ts.map +1 -1
  178. package/dist/storage/redis/script.js +29 -22
  179. package/dist/storage/redis/script.js.map +1 -1
  180. package/dist/storage/redis/target.d.ts +17 -1
  181. package/dist/storage/redis/target.d.ts.map +1 -1
  182. package/dist/storage/redis/target.js +30 -1
  183. package/dist/storage/redis/target.js.map +1 -1
  184. package/dist/storage/redis/wire.d.ts +6 -6
  185. package/dist/storage/redis/wire.d.ts.map +1 -1
  186. package/dist/storage/redis/wire.js +6 -6
  187. package/dist/storage/redis/wire.js.map +1 -1
  188. package/dist/testing/mod.d.ts +83 -88
  189. package/dist/testing/mod.d.ts.map +1 -1
  190. package/dist/testing/mod.js +75 -81
  191. package/dist/testing/mod.js.map +1 -1
  192. package/dist/testing/playwright.d.ts +28 -32
  193. package/dist/testing/playwright.d.ts.map +1 -1
  194. package/dist/testing/playwright.js +22 -27
  195. package/dist/testing/playwright.js.map +1 -1
  196. package/dist/testing/puppeteer.d.ts +11 -12
  197. package/dist/testing/puppeteer.d.ts.map +1 -1
  198. package/dist/testing/puppeteer.js +17 -18
  199. package/dist/testing/puppeteer.js.map +1 -1
  200. package/dist/testing/system.d.ts +72 -90
  201. package/dist/testing/system.d.ts.map +1 -1
  202. package/dist/testing/system.js +90 -107
  203. package/dist/testing/system.js.map +1 -1
  204. package/dist/tracing/http.d.ts +2 -1
  205. package/dist/tracing/http.d.ts.map +1 -1
  206. package/dist/tracing/http.js +2 -1
  207. package/dist/tracing/http.js.map +1 -1
  208. package/dist/tracing/node.d.ts.map +1 -1
  209. package/dist/tracing/node.js +1 -1
  210. package/dist/tracing/node.js.map +1 -1
  211. package/dist/tsconfig.build.tsbuildinfo +1 -1
  212. package/frontends/mod.test.ts +6 -2
  213. package/frontends/mod.ts +20 -19
  214. package/gateway/errors.ts +30 -32
  215. package/gateway/match.ts +61 -57
  216. package/gateway/middleware.ts +62 -64
  217. package/gateway/mod.ts +73 -76
  218. package/gateway/request.ts +143 -140
  219. package/gateway/serve.ts +58 -63
  220. package/gateways/mod.ts +25 -23
  221. package/internal/otel/http.test.ts +50 -0
  222. package/internal/otel/http.ts +40 -5
  223. package/internal/runtime/napi/napi.cjs +6 -5
  224. package/internal/runtime/napi/napi.d.cts +58 -16
  225. package/internal/runtime/shutdown.ts +113 -101
  226. package/log/logger.test.ts +8 -0
  227. package/log/logger.ts +48 -45
  228. package/metrics/mod.ts +138 -122
  229. package/otel.ts +6 -3
  230. package/package.json +6 -1
  231. package/pubsub/subscription.ts +93 -123
  232. package/pubsub/topic.ts +96 -130
  233. package/redaction/bridge.test.ts +99 -0
  234. package/redaction/mod.test.ts +188 -0
  235. package/redaction/mod.ts +226 -0
  236. package/reqctx/mod.ts +83 -86
  237. package/services/index.ts +78 -78
  238. package/shutdown/mod.ts +26 -25
  239. package/storage/clickhouse/database.ts +115 -129
  240. package/storage/clickhouse/errors.ts +27 -29
  241. package/storage/clickhouse/mod.ts +10 -10
  242. package/storage/objects/bucket.test.ts +168 -16
  243. package/storage/objects/bucket.ts +336 -247
  244. package/storage/objects/error.ts +4 -4
  245. package/storage/objects/mod.ts +1 -0
  246. package/storage/objects/refs.ts +2 -5
  247. package/storage/postgres/database.ts +131 -164
  248. package/storage/postgres/errors.ts +45 -52
  249. package/storage/postgres/interval.ts +21 -21
  250. package/storage/redis/bitfield.ts +51 -26
  251. package/storage/redis/command.ts +16 -12
  252. package/storage/redis/commands.ts +99 -100
  253. package/storage/redis/database.ts +145 -123
  254. package/storage/redis/mod.ts +52 -48
  255. package/storage/redis/options.ts +26 -24
  256. package/storage/redis/pubsub.ts +14 -14
  257. package/storage/redis/redis.test.ts +17 -2
  258. package/storage/redis/reply.ts +85 -77
  259. package/storage/redis/scan.ts +6 -6
  260. package/storage/redis/script.ts +29 -22
  261. package/storage/redis/target.ts +34 -1
  262. package/storage/redis/wire.ts +8 -8
  263. package/testing/mod.ts +99 -105
  264. package/testing/playwright.ts +32 -37
  265. package/testing/puppeteer.ts +22 -23
  266. package/testing/system.ts +117 -133
  267. package/tracing/http.ts +2 -1
  268. package/tracing/native.test.ts +158 -8
  269. package/tracing/node.ts +1 -0
@@ -35,7 +35,7 @@ test('public spans reach the native OTLP destination with parents, errors, and l
35
35
  return new Response("placed");
36
36
  }))(new Request("http://shop.test:8080/reset/PATH_SECRET?token=QUERY_SECRET", {
37
37
  method: "POST",
38
- headers: {traceparent: "00-0123456789abcdef0123456789abcdef-1234567890abcdef-01"},
38
+ headers: {traceparent: "00-0123456789abcdef0123456789abcdef-1234567890abcdef-01", "user-agent": "AGENT_SECRET"},
39
39
  }));
40
40
  for (const [url, status, method] of [
41
41
  ["https://[::1]:8443/fail?token=private", 500, "GET"],
@@ -75,7 +75,9 @@ test('public spans reach the native OTLP destination with parents, errors, and l
75
75
  stdout += new TextDecoder().decode(value);
76
76
  if (stdout.includes('ready')) break;
77
77
  }
78
- expect(await proc.exited).toBe(0);
78
+ const exitCode = await proc.exited;
79
+ const stderr = await new Response(proc.stderr).text();
80
+ if (exitCode !== 0) throw new Error(stderr);
79
81
  expect(stdout).toContain('ready');
80
82
  const exported = received.flatMap(body =>
81
83
  fields(body, 1).flatMap(rs => fields(rs, 2).flatMap(ss => fields(ss, 2))),
@@ -87,7 +89,7 @@ test('public spans reach the native OTLP destination with parents, errors, and l
87
89
  expect([...named.keys()].sort()).toEqual([
88
90
  'GET',
89
91
  'HTTP',
90
- 'POST',
92
+ 'POST /reset/{id}',
91
93
  'QUERY',
92
94
  'order_request',
93
95
  'rejected_order',
@@ -108,6 +110,10 @@ test('public spans reach the native OTLP destination with parents, errors, and l
108
110
  'url.scheme': 'http',
109
111
  'server.address': 'shop.test',
110
112
  'server.port': 8080,
113
+ 'http.route': '/reset/{id}',
114
+ 'url.path': '/reset/REDACTED',
115
+ 'url.query': 'token=REDACTED',
116
+ 'user_agent.original': '[REDACTED]',
111
117
  });
112
118
  const failure = http.find(
113
119
  span => attributes(span)['http.response.status_code'] === 500,
@@ -147,14 +153,18 @@ test('public spans reach the native OTLP destination with parents, errors, and l
147
153
  });
148
154
  for (const span of http) {
149
155
  const recorded = attributes(span);
150
- expect(recorded['url.path']).toBeUndefined();
156
+ if (span !== request) expect(recorded['url.path']).toBeUndefined();
151
157
  expect(recorded['url.full']).toBeUndefined();
152
- expect(recorded['url.query']).toBeUndefined();
158
+ if (span !== request) {
159
+ expect(recorded['url.query']).toBeUndefined();
160
+ expect(recorded['user_agent.original']).toBeUndefined();
161
+ }
153
162
  expect(JSON.stringify(recorded)).not.toContain('private');
154
163
  }
155
164
  for (const body of received) {
156
165
  expect(body.includes(Buffer.from('PATH_SECRET'))).toBe(false);
157
166
  expect(body.includes(Buffer.from('QUERY_SECRET'))).toBe(false);
167
+ expect(body.includes(Buffer.from('AGENT_SECRET'))).toBe(false);
158
168
  }
159
169
  const outer = named.get('order_request')!;
160
170
  for (const name of ['validate_order', 'rejected_order']) {
@@ -167,7 +177,6 @@ test('public spans reach the native OTLP destination with parents, errors, and l
167
177
  expect(fields(fields(failed, 15)[0]!, 3)[0]).toEqual(Buffer.from([2]));
168
178
  const event = fields(failed, 11)[0]!;
169
179
  expect(fields(event, 2)[0]!.toString()).toBe('exception');
170
- const stderr = await new Response(proc.stderr).text();
171
180
  const record = stderr
172
181
  .split('\n')
173
182
  .filter(line => line.startsWith('{'))
@@ -185,6 +194,127 @@ test('public spans reach the native OTLP destination with parents, errors, and l
185
194
  }
186
195
  }, 15_000);
187
196
 
197
+ const routes: RouteSpec[] = [
198
+ ['/orders/{schema_id}', 'GET', 'schema_id'],
199
+ ['/graphql', 'POST'],
200
+ ['/orders.Orders/Get', 'POST'],
201
+ ];
202
+
203
+ for (const runtime of ['node', 'bun']) {
204
+ for (const schema of [true, false]) {
205
+ test(`${runtime} exports protocol SERVER spans (${schema ? 'with' : 'without'} schema)`, async () => {
206
+ const executable =
207
+ runtime === 'bun' ? process.execPath : Bun.which('node');
208
+ if (!executable)
209
+ throw new Error('Node is required for the SDK protocol matrix');
210
+ const received: Buffer[] = [];
211
+ const receiver = Bun.serve({
212
+ hostname: '127.0.0.1',
213
+ port: 0,
214
+ async fetch(request) {
215
+ expect(new URL(request.url).pathname).toBe('/v1/traces');
216
+ expect(request.method).toBe('POST');
217
+ expect(request.headers.get('content-type')).toBe(
218
+ 'application/x-protobuf',
219
+ );
220
+ received.push(Buffer.from(await request.arrayBuffer()));
221
+ return new Response(new Uint8Array(), {
222
+ headers: {'content-type': 'application/x-protobuf'},
223
+ });
224
+ },
225
+ });
226
+ const proc = Bun.spawn({
227
+ cmd: [executable, join(import.meta.dir, 'protocol.fixture.mjs')],
228
+ cwd: import.meta.dir,
229
+ env: {
230
+ ...process.env,
231
+ NODE_ENV: 'production',
232
+ ENCORE_RUNTIME_CONFIG: runtimeConfig(
233
+ `http://127.0.0.1:${receiver.port}`,
234
+ schema ? routes : [],
235
+ ),
236
+ OTEL_BSP_SCHEDULE_DELAY: '60000',
237
+ },
238
+ stdout: 'pipe',
239
+ stderr: 'pipe',
240
+ });
241
+ const timeout = setTimeout(() => proc.kill('SIGKILL'), 10_000);
242
+ try {
243
+ const [exitCode, stdout, stderr] = await Promise.all([
244
+ proc.exited,
245
+ new Response(proc.stdout).text(),
246
+ new Response(proc.stderr).text(),
247
+ ]);
248
+ if (exitCode !== 0)
249
+ throw new Error(`${runtime} fixture exited ${exitCode}: ${stderr}`);
250
+ const requests: Record<string, {port: number; traceId: string}> =
251
+ JSON.parse(stdout);
252
+ const exported = received.flatMap(body =>
253
+ fields(body, 1).flatMap(rs =>
254
+ fields(rs, 2).flatMap(ss => fields(ss, 2)),
255
+ ),
256
+ );
257
+ const cases = [
258
+ ['Node GET', 'GET', '/orders/{schema_id}', '/orders/REDACTED'],
259
+ ['Node GraphQL', 'POST', '/graphql', '/graphql'],
260
+ ['Node gRPC', 'POST', '/orders.Orders/Get', '/orders.Orders/Get'],
261
+ ];
262
+ if (runtime === 'bun')
263
+ cases.push(
264
+ ['Bun Fetch GET', 'GET', '/orders/{schema_id}', '/orders/REDACTED'],
265
+ ['Bun Fetch GraphQL', 'POST', '/graphql', '/graphql'],
266
+ );
267
+ expect(exported).toHaveLength(cases.length);
268
+ for (const [row, method, template, path] of cases) {
269
+ const {port, traceId} = requests[row]!;
270
+ const matches = exported.filter(
271
+ span => fields(span, 1)[0]?.toString('hex') === traceId,
272
+ );
273
+ expect(matches).toHaveLength(1);
274
+ const [span] = matches;
275
+ expect(fields(span!, 6)[0]?.[0]).toBe(2); // SERVER
276
+ expect(fields(span!, 5)[0]?.toString()).toBe(
277
+ schema ? `${method} ${template}` : method,
278
+ );
279
+ const attrs = attributes(span!);
280
+ expect(attrs['http.route']).toBe(schema ? template : undefined);
281
+ expect(attrs['url.path']).toBe(schema ? path : undefined);
282
+ expect(
283
+ Object.keys(attrs).filter(key =>
284
+ /^(rpc|graphql|encore)\./.test(key),
285
+ ),
286
+ ).toEqual([]);
287
+ expect(attrs).toEqual({
288
+ 'http.request.method': method,
289
+ 'http.response.status_code': 200,
290
+ 'url.scheme': 'http',
291
+ // HTTP/2 supplies :authority, not the Host the node:http adapter reads.
292
+ 'server.address': row === 'Node gRPC' ? 'localhost' : '127.0.0.1',
293
+ 'server.port': row === 'Node gRPC' ? 80 : port,
294
+ ...(schema
295
+ ? {
296
+ 'http.route': template,
297
+ 'url.path': path,
298
+ 'user_agent.original': '[REDACTED]',
299
+ ...(method === 'GET' ? {'url.query': 'token=REDACTED'} : {}),
300
+ }
301
+ : {}),
302
+ });
303
+ }
304
+ for (const body of received) {
305
+ expect(body.toString()).not.toMatch(
306
+ /\/orders\/synthetic|GetOrder|QUERY_SECRET|AGENT_SECRET/,
307
+ );
308
+ }
309
+ } finally {
310
+ clearTimeout(timeout);
311
+ proc.kill();
312
+ receiver.stop(true);
313
+ }
314
+ }, 15_000);
315
+ }
316
+ }
317
+
188
318
  /** Raw values of protobuf field `want`. */
189
319
  function fields(buf: Buffer, want: number): Buffer[] {
190
320
  const out: Buffer[] = [];
@@ -247,8 +377,13 @@ function attributes(span: Buffer): Record<string, string | number> {
247
377
  );
248
378
  }
249
379
 
380
+ type RouteSpec = [template: string, method: string, param?: string];
381
+
250
382
  /** RuntimeConfig hosting shop with an explicit TracingProvider OTLP/HTTP sink. */
251
- function runtimeConfig(endpoint: string): string {
383
+ function runtimeConfig(
384
+ endpoint: string,
385
+ routes: RouteSpec[] = [['/reset/{id}', 'POST', 'id']],
386
+ ): string {
252
387
  const varint = (n: number): number[] => {
253
388
  const bytes: number[] = [];
254
389
  do {
@@ -268,7 +403,22 @@ function runtimeConfig(endpoint: string): string {
268
403
  // RuntimeConfig{environment=1, deployment=3}; Deployment{hosted_services=5,
269
404
  // observability=7}; Observability{tracing=1}; TracingProvider{rid=1, otlp_http=12}.
270
405
  const tracing = [...str(1, 'traces'), ...msg(12, str(1, endpoint))];
271
- const deployment = [...msg(5, str(1, 'shop')), ...msg(7, msg(1, tracing))];
406
+ const hosted = str(1, 'shop');
407
+ for (const [template, method, param] of routes) {
408
+ const policy = [
409
+ ...str(3, 'user-agent'),
410
+ ...str(5, 'token'),
411
+ ...(param ? str(6, param) : []),
412
+ ];
413
+ const endpointPolicy = [...str(1, 'endpoint'), ...msg(3, policy)];
414
+ const route = [
415
+ ...str(1, template),
416
+ ...str(2, method),
417
+ ...msg(3, endpointPolicy),
418
+ ];
419
+ hosted.push(...msg(4, route));
420
+ }
421
+ const deployment = [...msg(5, hosted), ...msg(7, msg(1, tracing))];
272
422
  return Buffer.from([
273
423
  ...msg(1, str(1, 'app')),
274
424
  ...msg(3, deployment),
package/tracing/node.ts CHANGED
@@ -43,6 +43,7 @@ export function instrumentHTTP<This = Server, Result = void>(
43
43
  headersGetter,
44
44
  request.method || '',
45
45
  url,
46
+ request.url ?? '/',
46
47
  );
47
48
  const restoreRequest = bindEmitter(request, context);
48
49
  const restoreResponse = bindEmitter(response, context);