@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.
- package/README.md +144 -90
- package/app_meta.ts +56 -54
- package/config/config.test.ts +47 -13
- package/config/config.ts +60 -57
- package/config/secrets.ts +47 -50
- package/config/value.ts +23 -26
- package/cron/mod.test.ts +12 -0
- package/cron/mod.ts +37 -22
- package/dist/app_meta.d.ts +52 -50
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +2 -2
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -55
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +8 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +45 -50
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +11 -9
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +20 -23
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +20 -23
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +34 -20
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -13
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +20 -19
- package/dist/frontends/mod.d.ts.map +1 -1
- package/dist/frontends/mod.js +20 -19
- package/dist/frontends/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +28 -30
- package/dist/gateway/errors.d.ts.map +1 -1
- package/dist/gateway/errors.js +29 -31
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/match.d.ts +54 -54
- package/dist/gateway/match.d.ts.map +1 -1
- package/dist/gateway/match.js +56 -56
- package/dist/gateway/match.js.map +1 -1
- package/dist/gateway/middleware.d.ts +62 -64
- package/dist/gateway/middleware.d.ts.map +1 -1
- package/dist/gateway/middleware.js +1 -1
- package/dist/gateway/middleware.js.map +1 -1
- package/dist/gateway/mod.d.ts +64 -67
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +72 -76
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateway/request.d.ts +138 -134
- package/dist/gateway/request.d.ts.map +1 -1
- package/dist/gateway/request.js +117 -108
- package/dist/gateway/request.js.map +1 -1
- package/dist/gateway/serve.d.ts +29 -34
- package/dist/gateway/serve.d.ts.map +1 -1
- package/dist/gateway/serve.js +51 -56
- package/dist/gateway/serve.js.map +1 -1
- package/dist/gateways/mod.d.ts +23 -21
- package/dist/gateways/mod.d.ts.map +1 -1
- package/dist/gateways/mod.js +25 -23
- package/dist/gateways/mod.js.map +1 -1
- package/dist/internal/otel/http.d.ts +4 -2
- package/dist/internal/otel/http.d.ts.map +1 -1
- package/dist/internal/otel/http.js +32 -5
- package/dist/internal/otel/http.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +6 -5
- package/dist/internal/runtime/napi/napi.d.cts +58 -16
- package/dist/internal/runtime/shutdown.d.ts +75 -57
- package/dist/internal/runtime/shutdown.d.ts.map +1 -1
- package/dist/internal/runtime/shutdown.js +88 -84
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/log/logger.d.ts +43 -37
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +26 -25
- package/dist/log/logger.js.map +1 -1
- package/dist/metrics/mod.d.ts +133 -114
- package/dist/metrics/mod.d.ts.map +1 -1
- package/dist/metrics/mod.js +109 -101
- package/dist/metrics/mod.js.map +1 -1
- package/dist/otel.d.ts +6 -3
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +6 -3
- package/dist/otel.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +88 -116
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js +14 -17
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +86 -113
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +68 -82
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/redaction/mod.d.ts +62 -0
- package/dist/redaction/mod.d.ts.map +1 -0
- package/dist/redaction/mod.js +102 -0
- package/dist/redaction/mod.js.map +1 -0
- package/dist/reqctx/mod.d.ts +83 -86
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +39 -41
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +76 -75
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +73 -71
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +26 -25
- package/dist/shutdown/mod.d.ts.map +1 -1
- package/dist/shutdown/mod.js +26 -25
- package/dist/shutdown/mod.js.map +1 -1
- package/dist/storage/clickhouse/database.d.ts +113 -115
- package/dist/storage/clickhouse/database.d.ts.map +1 -1
- package/dist/storage/clickhouse/database.js +65 -79
- package/dist/storage/clickhouse/database.js.map +1 -1
- package/dist/storage/clickhouse/errors.d.ts +25 -26
- package/dist/storage/clickhouse/errors.d.ts.map +1 -1
- package/dist/storage/clickhouse/errors.js +15 -17
- package/dist/storage/clickhouse/errors.js.map +1 -1
- package/dist/storage/clickhouse/mod.d.ts +10 -10
- package/dist/storage/clickhouse/mod.js +10 -10
- package/dist/storage/objects/bucket.d.ts +230 -203
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +146 -106
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +4 -4
- package/dist/storage/objects/error.js +4 -4
- package/dist/storage/objects/mod.d.ts +1 -1
- package/dist/storage/objects/mod.d.ts.map +1 -1
- package/dist/storage/objects/mod.js.map +1 -1
- package/dist/storage/objects/refs.d.ts +2 -5
- package/dist/storage/objects/refs.d.ts.map +1 -1
- package/dist/storage/objects/refs.js.map +1 -1
- package/dist/storage/postgres/database.d.ts +124 -149
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +98 -135
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +42 -48
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +44 -51
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/interval.d.ts +19 -19
- package/dist/storage/postgres/interval.d.ts.map +1 -1
- package/dist/storage/postgres/interval.js +21 -21
- package/dist/storage/postgres/interval.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +48 -23
- package/dist/storage/redis/bitfield.d.ts.map +1 -1
- package/dist/storage/redis/bitfield.js +38 -19
- package/dist/storage/redis/bitfield.js.map +1 -1
- package/dist/storage/redis/command.d.ts +16 -12
- package/dist/storage/redis/command.d.ts.map +1 -1
- package/dist/storage/redis/command.js +16 -12
- package/dist/storage/redis/command.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +99 -100
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +84 -85
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +138 -122
- package/dist/storage/redis/database.d.ts.map +1 -1
- package/dist/storage/redis/database.js +120 -101
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +52 -48
- package/dist/storage/redis/mod.d.ts.map +1 -1
- package/dist/storage/redis/mod.js +52 -48
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/options.d.ts +26 -24
- package/dist/storage/redis/options.d.ts.map +1 -1
- package/dist/storage/redis/options.js.map +1 -1
- package/dist/storage/redis/pubsub.d.ts +16 -16
- package/dist/storage/redis/pubsub.d.ts.map +1 -1
- package/dist/storage/redis/pubsub.js +14 -14
- package/dist/storage/redis/pubsub.js.map +1 -1
- package/dist/storage/redis/reply.d.ts +80 -72
- package/dist/storage/redis/reply.d.ts.map +1 -1
- package/dist/storage/redis/reply.js +53 -46
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +4 -4
- package/dist/storage/redis/scan.d.ts.map +1 -1
- package/dist/storage/redis/scan.js +6 -6
- package/dist/storage/redis/scan.js.map +1 -1
- package/dist/storage/redis/script.d.ts +28 -21
- package/dist/storage/redis/script.d.ts.map +1 -1
- package/dist/storage/redis/script.js +29 -22
- package/dist/storage/redis/script.js.map +1 -1
- package/dist/storage/redis/target.d.ts +17 -1
- package/dist/storage/redis/target.d.ts.map +1 -1
- package/dist/storage/redis/target.js +30 -1
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +6 -6
- package/dist/storage/redis/wire.d.ts.map +1 -1
- package/dist/storage/redis/wire.js +6 -6
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/mod.d.ts +83 -88
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +75 -81
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +28 -32
- package/dist/testing/playwright.d.ts.map +1 -1
- package/dist/testing/playwright.js +22 -27
- package/dist/testing/playwright.js.map +1 -1
- package/dist/testing/puppeteer.d.ts +11 -12
- package/dist/testing/puppeteer.d.ts.map +1 -1
- package/dist/testing/puppeteer.js +17 -18
- package/dist/testing/puppeteer.js.map +1 -1
- package/dist/testing/system.d.ts +72 -90
- package/dist/testing/system.d.ts.map +1 -1
- package/dist/testing/system.js +90 -107
- package/dist/testing/system.js.map +1 -1
- package/dist/tracing/http.d.ts +2 -1
- package/dist/tracing/http.d.ts.map +1 -1
- package/dist/tracing/http.js +2 -1
- package/dist/tracing/http.js.map +1 -1
- package/dist/tracing/node.d.ts.map +1 -1
- package/dist/tracing/node.js +1 -1
- package/dist/tracing/node.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +6 -2
- package/frontends/mod.ts +20 -19
- package/gateway/errors.ts +30 -32
- package/gateway/match.ts +61 -57
- package/gateway/middleware.ts +62 -64
- package/gateway/mod.ts +73 -76
- package/gateway/request.ts +143 -140
- package/gateway/serve.ts +58 -63
- package/gateways/mod.ts +25 -23
- package/internal/otel/http.test.ts +50 -0
- package/internal/otel/http.ts +40 -5
- package/internal/runtime/napi/napi.cjs +6 -5
- package/internal/runtime/napi/napi.d.cts +58 -16
- package/internal/runtime/shutdown.ts +113 -101
- package/log/logger.test.ts +8 -0
- package/log/logger.ts +48 -45
- package/metrics/mod.ts +138 -122
- package/otel.ts +6 -3
- package/package.json +6 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- package/redaction/bridge.test.ts +99 -0
- package/redaction/mod.test.ts +188 -0
- package/redaction/mod.ts +226 -0
- package/reqctx/mod.ts +83 -86
- package/services/index.ts +78 -78
- package/shutdown/mod.ts +26 -25
- package/storage/clickhouse/database.ts +115 -129
- package/storage/clickhouse/errors.ts +27 -29
- package/storage/clickhouse/mod.ts +10 -10
- package/storage/objects/bucket.test.ts +168 -16
- package/storage/objects/bucket.ts +336 -247
- package/storage/objects/error.ts +4 -4
- package/storage/objects/mod.ts +1 -0
- package/storage/objects/refs.ts +2 -5
- package/storage/postgres/database.ts +131 -164
- package/storage/postgres/errors.ts +45 -52
- package/storage/postgres/interval.ts +21 -21
- package/storage/redis/bitfield.ts +51 -26
- package/storage/redis/command.ts +16 -12
- package/storage/redis/commands.ts +99 -100
- package/storage/redis/database.ts +145 -123
- package/storage/redis/mod.ts +52 -48
- package/storage/redis/options.ts +26 -24
- package/storage/redis/pubsub.ts +14 -14
- package/storage/redis/redis.test.ts +17 -2
- package/storage/redis/reply.ts +85 -77
- package/storage/redis/scan.ts +6 -6
- package/storage/redis/script.ts +29 -22
- package/storage/redis/target.ts +34 -1
- package/storage/redis/wire.ts +8 -8
- package/testing/mod.ts +99 -105
- package/testing/playwright.ts +32 -37
- package/testing/puppeteer.ts +22 -23
- package/testing/system.ts +117 -133
- package/tracing/http.ts +2 -1
- package/tracing/native.test.ts +158 -8
- package/tracing/node.ts +1 -0
package/tracing/native.test.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
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