@encore.dev/sdk 2.0.0-beta.15 → 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 +111 -101
- package/app_meta.ts +56 -54
- package/config/config.ts +60 -57
- package/config/secrets.ts +45 -52
- package/config/value.ts +23 -26
- package/cron/mod.ts +28 -29
- 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 -52
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +8 -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 +26 -27
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -14
- 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/runtime/napi/napi.cjs +1 -1
- package/dist/internal/runtime/napi/napi.d.cts +10 -3
- 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/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 +196 -225
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +71 -84
- 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/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/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/runtime/napi/napi.cjs +1 -1
- package/internal/runtime/napi/napi.d.cts +10 -3
- 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 +1 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- 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.ts +209 -239
- package/storage/objects/error.ts +4 -4
- 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/log/logger.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {encodeLog} from '../internal/runtime/napi/napi.cjs';
|
|
|
4
4
|
import {writeStderr} from './stderr';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* A field value
|
|
7
|
+
* A field value supported by structured logging.
|
|
8
8
|
*/
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
10
|
// @ts-expect-error
|
|
@@ -12,7 +12,7 @@ export type FieldValue =
|
|
|
12
12
|
string | number | boolean | null | undefined | FieldsObject | FieldValue[];
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* A map of fields
|
|
15
|
+
* A map of structured fields attached to a log record.
|
|
16
16
|
*/
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
18
18
|
// @ts-expect-error
|
|
@@ -27,10 +27,10 @@ export enum LogLevel {
|
|
|
27
27
|
Fatal,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
30
|
+
/** Sentinel level above all log levels; disables logging completely. */
|
|
31
31
|
export const OFF = LogLevel.Fatal + 1;
|
|
32
32
|
|
|
33
|
-
/**
|
|
33
|
+
/** Level names recognized by `ENCORE_LOG`. */
|
|
34
34
|
const LEVELS: Record<LogLevel, string> = {
|
|
35
35
|
[LogLevel.Trace]: 'trace',
|
|
36
36
|
[LogLevel.Debug]: 'debug',
|
|
@@ -40,7 +40,10 @@ const LEVELS: Record<LogLevel, string> = {
|
|
|
40
40
|
[LogLevel.Fatal]: 'fatal',
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Parses a case-insensitive log level name or `"off"`, defaulting to
|
|
45
|
+
* {@link LogLevel.Trace} for unrecognized or empty values.
|
|
46
|
+
*/
|
|
44
47
|
export function parseLevel(name: string | undefined): LogLevel {
|
|
45
48
|
const v = name?.toLowerCase();
|
|
46
49
|
if (v === 'off') return OFF;
|
|
@@ -50,48 +53,52 @@ export function parseLevel(name: string | undefined): LogLevel {
|
|
|
50
53
|
|
|
51
54
|
/** @internal */
|
|
52
55
|
export interface LoggerOptions {
|
|
53
|
-
/**
|
|
56
|
+
/** Minimum level to emit. */
|
|
54
57
|
level: LogLevel;
|
|
55
|
-
/**
|
|
58
|
+
/** Logger name recorded on each log line. */
|
|
56
59
|
name?: string;
|
|
57
|
-
/**
|
|
60
|
+
/** Default attributes attached to every log record. */
|
|
58
61
|
fields?: FieldsObject;
|
|
59
|
-
/**
|
|
62
|
+
/** Sink for encoded log lines; defaults to stderr. */
|
|
60
63
|
write?: (line: Buffer) => void;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
/**
|
|
66
|
+
/** Structured fields for a log record beyond its level and logger name. */
|
|
64
67
|
export interface RecordParts {
|
|
65
|
-
/**
|
|
68
|
+
/** Timestamp in Unix milliseconds; defaults to the current time. */
|
|
66
69
|
timeUnixMillis?: number;
|
|
67
|
-
message
|
|
68
|
-
/**
|
|
70
|
+
message?: string;
|
|
71
|
+
/** 25-byte encoded span context (trace ID, span ID, trace flags). */
|
|
69
72
|
spanCtx?: Buffer;
|
|
70
73
|
exceptionType?: string;
|
|
71
74
|
exceptionMessage?: string;
|
|
72
|
-
/**
|
|
75
|
+
/** JavaScript stack trace string. */
|
|
73
76
|
exceptionStacktrace?: string;
|
|
74
|
-
/**
|
|
77
|
+
/** Calling function name. */
|
|
75
78
|
codeFunction?: string;
|
|
76
|
-
/**
|
|
79
|
+
/** Caller source file, line, and column. */
|
|
77
80
|
codeFile?: string;
|
|
78
81
|
codeLine?: number;
|
|
79
82
|
codeColumn?: number;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
83
|
+
/**
|
|
84
|
+
* Runtime module target for internal runtime logs; replaces the logger name
|
|
85
|
+
* with the runtime logger when set.
|
|
86
|
+
*/
|
|
82
87
|
runtimeTarget?: string;
|
|
83
|
-
/**
|
|
88
|
+
/** JSON-encoded object of user attributes. */
|
|
84
89
|
attrsJson?: string;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
93
|
+
* Structured logger that writes one Encore-formatted log record per line to
|
|
94
|
+
* stderr, including the logger name, bound and per-call attributes, and active
|
|
95
|
+
* span IDs.
|
|
96
|
+
*
|
|
97
|
+
* Lines are encoded by the native SDK core without requiring the full runtime,
|
|
98
|
+
* and are written synchronously so no records are lost on `process.exit`.
|
|
99
|
+
* Attributes colliding with reserved log keys are promoted when valid or stored
|
|
100
|
+
* under `raw.<key>` otherwise; attributes colliding with exception fields are
|
|
101
|
+
* always stored under `raw.<key>`.
|
|
95
102
|
*/
|
|
96
103
|
export class Logger {
|
|
97
104
|
private readonly level: LogLevel;
|
|
@@ -108,22 +115,22 @@ export class Logger {
|
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
/**
|
|
111
|
-
* Returns a new logger with the specified level.
|
|
118
|
+
* Returns a new logger with the specified minimum level.
|
|
112
119
|
*/
|
|
113
120
|
withLevel(level: LogLevel): Logger {
|
|
114
121
|
return new Logger({...this.options(), level});
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
/**
|
|
118
|
-
* Returns a new logger
|
|
119
|
-
* this logger's level and fields.
|
|
125
|
+
* Returns a new logger with the given `name` (recorded as `logger` on each
|
|
126
|
+
* log line), inheriting this logger's level and fields.
|
|
120
127
|
*/
|
|
121
128
|
withName(name: string): Logger {
|
|
122
129
|
return new Logger({...this.options(), name});
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
/**
|
|
126
|
-
* Returns a new logger with the given fields
|
|
133
|
+
* Returns a new logger with the given fields merged into its default context.
|
|
127
134
|
*/
|
|
128
135
|
with(fields: FieldsObject): Logger {
|
|
129
136
|
return new Logger({
|
|
@@ -133,28 +140,28 @@ export class Logger {
|
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
/**
|
|
136
|
-
*
|
|
143
|
+
* Logs a message at the trace level.
|
|
137
144
|
*/
|
|
138
145
|
trace(msg: string, fields?: FieldsObject) {
|
|
139
146
|
this.log(LogLevel.Trace, msg, fields);
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
/**
|
|
143
|
-
*
|
|
150
|
+
* Logs a message at the debug level.
|
|
144
151
|
*/
|
|
145
152
|
debug(msg: string, fields?: FieldsObject) {
|
|
146
153
|
this.log(LogLevel.Debug, msg, fields);
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
/**
|
|
150
|
-
*
|
|
157
|
+
* Logs a message at the info level.
|
|
151
158
|
*/
|
|
152
159
|
info(msg: string, fields?: FieldsObject) {
|
|
153
160
|
this.log(LogLevel.Info, msg, fields);
|
|
154
161
|
}
|
|
155
162
|
|
|
156
163
|
/**
|
|
157
|
-
*
|
|
164
|
+
* Logs a message or error at the warn level.
|
|
158
165
|
*/
|
|
159
166
|
warn(err: Error | unknown, fields?: FieldsObject): void;
|
|
160
167
|
warn(err: Error | unknown, msg: string, fields?: FieldsObject): void;
|
|
@@ -164,7 +171,7 @@ export class Logger {
|
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
/**
|
|
167
|
-
*
|
|
174
|
+
* Logs a message or error at the error level.
|
|
168
175
|
*/
|
|
169
176
|
error(err: Error | unknown, fields?: FieldsObject): void;
|
|
170
177
|
error(err: Error | unknown, msg: string, fields?: FieldsObject): void;
|
|
@@ -174,7 +181,7 @@ export class Logger {
|
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
/**
|
|
177
|
-
*
|
|
184
|
+
* Logs a message or error at the fatal level.
|
|
178
185
|
*/
|
|
179
186
|
fatal(err: Error | unknown, fields?: FieldsObject): void;
|
|
180
187
|
fatal(err: Error | unknown, msg: string, fields?: FieldsObject): void;
|
|
@@ -201,7 +208,7 @@ export class Logger {
|
|
|
201
208
|
if (level < this.level) return;
|
|
202
209
|
|
|
203
210
|
let err: Error | undefined;
|
|
204
|
-
let msg: string;
|
|
211
|
+
let msg: string | undefined;
|
|
205
212
|
let fields: FieldsObject | undefined;
|
|
206
213
|
if (typeof errOrMsg === 'string') {
|
|
207
214
|
// log(msg, fields?)
|
|
@@ -217,7 +224,6 @@ export class Logger {
|
|
|
217
224
|
msg = msgOrFields;
|
|
218
225
|
fields = possibleFields as FieldsObject | undefined;
|
|
219
226
|
} else {
|
|
220
|
-
msg = '';
|
|
221
227
|
fields = msgOrFields as FieldsObject | undefined;
|
|
222
228
|
}
|
|
223
229
|
}
|
|
@@ -234,8 +240,7 @@ export class Logger {
|
|
|
234
240
|
}
|
|
235
241
|
|
|
236
242
|
/**
|
|
237
|
-
*
|
|
238
|
-
* logger's level.
|
|
243
|
+
* Writes a log record if `level` is at or above this logger's minimum level.
|
|
239
244
|
* @internal
|
|
240
245
|
*/
|
|
241
246
|
emit(level: LogLevel, parts: RecordParts): void {
|
|
@@ -248,8 +253,7 @@ export class Logger {
|
|
|
248
253
|
}
|
|
249
254
|
}
|
|
250
255
|
|
|
251
|
-
/**
|
|
252
|
-
* OpenTelemetry severity number. */
|
|
256
|
+
/** Encodes a log record in the Encore format using an OpenTelemetry severity number. */
|
|
253
257
|
function encode(
|
|
254
258
|
severity: number,
|
|
255
259
|
logger: string | undefined,
|
|
@@ -273,7 +277,7 @@ function encode(
|
|
|
273
277
|
);
|
|
274
278
|
}
|
|
275
279
|
|
|
276
|
-
/** `span`
|
|
280
|
+
/** Encodes `span` into its 25-byte wire form (trace ID, span ID, flags). */
|
|
277
281
|
function spanBytes(span: SpanContext): Buffer {
|
|
278
282
|
const b = Buffer.allocUnsafe(25);
|
|
279
283
|
b.write(span.traceId, 0, 16, 'hex');
|
|
@@ -282,8 +286,7 @@ function spanBytes(span: SpanContext): Buffer {
|
|
|
282
286
|
return b;
|
|
283
287
|
}
|
|
284
288
|
|
|
285
|
-
/** `attrs`
|
|
286
|
-
* `undefined` left out; a value JSON cannot hold (a cycle) as its string. */
|
|
289
|
+
/** Serializes `attrs` to JSON, converting bigints, errors, and non-serializable values to strings. */
|
|
287
290
|
function attrsJson(attrs: Record<string, unknown>): string {
|
|
288
291
|
try {
|
|
289
292
|
return JSON.stringify(attrs, replacer);
|