@lunora/server 1.0.0-alpha.289 → 1.0.0-alpha.290
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/dist/otel.d.mts +84 -32
- package/dist/otel.d.ts +84 -32
- package/dist/otel.mjs +1 -1
- package/package.json +2 -2
package/dist/otel.d.mts
CHANGED
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d--zaGh3rX.mjs";
|
|
45
45
|
import '@lunora/values';
|
|
46
|
+
//#region src/context/types.d.ts
|
|
46
47
|
/**
|
|
47
48
|
* @since 1.0.0
|
|
48
49
|
*/
|
|
@@ -69,24 +70,76 @@ interface Context {
|
|
|
69
70
|
*/
|
|
70
71
|
deleteValue(key: symbol): Context;
|
|
71
72
|
}
|
|
73
|
+
//#region src/common/AnyValue.d.ts
|
|
72
74
|
/**
|
|
73
|
-
*
|
|
75
|
+
* AnyValue can be:
|
|
76
|
+
* - a string, number, boolean value
|
|
77
|
+
* - a byte array (Uint8Array)
|
|
78
|
+
* - array of any value
|
|
79
|
+
* - map from string to any value (a plain Object)
|
|
80
|
+
* - null (an empty value)
|
|
74
81
|
*
|
|
75
|
-
*
|
|
82
|
+
* https://opentelemetry.io/docs/specs/otel/common/#anyvalue
|
|
76
83
|
*
|
|
77
|
-
*
|
|
84
|
+
* Notable JavaScript types that are excluded:
|
|
85
|
+
* - `undefined` - Excluding this means the common practice in instrumentations,
|
|
86
|
+
* using `undefined` to mean "no value for this optional attribute", can
|
|
87
|
+
* remain supported.
|
|
88
|
+
* - `BigInt`
|
|
89
|
+
* - TypedArrays other than `Uint8Array`
|
|
90
|
+
* - subclasses of Object, e.g. Date, Error
|
|
91
|
+
*
|
|
92
|
+
* The TypeScript type `unknown` is used for `AnyValue`. This has some
|
|
93
|
+
* implications:
|
|
94
|
+
* - Callers of `@opentelemetry/api` APIs using `AnyValue` can pass in
|
|
95
|
+
* whatever type. This was always the case for (untyped) JavaScript usage.
|
|
96
|
+
* - SDK implementations of `@opentelemetry/api` need to document if/when they
|
|
97
|
+
* support a subset of AnyValue types.
|
|
98
|
+
* - Using `unknown` allows future changes to support more types (e.g. BigInt).
|
|
99
|
+
*
|
|
100
|
+
* @since 1.10.0
|
|
101
|
+
*/
|
|
102
|
+
type AnyValue = unknown;
|
|
103
|
+
//#region src/common/Attributes.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* Attributes is a mapping from string to attribute values.
|
|
106
|
+
* https://opentelemetry.io/docs/specs/otel/common/#attribute-collections
|
|
107
|
+
*
|
|
108
|
+
* @since 1.1.0
|
|
78
109
|
*/
|
|
79
110
|
interface Attributes {
|
|
80
|
-
[attributeKey: string]:
|
|
111
|
+
[attributeKey: string]: AnyValue;
|
|
81
112
|
}
|
|
82
113
|
/**
|
|
83
|
-
*
|
|
114
|
+
* @since 1.1.0
|
|
115
|
+
* @deprecated use AnyValue
|
|
116
|
+
*/
|
|
117
|
+
type AttributeValue = AnyValue;
|
|
118
|
+
//#region src/common/Time.d.ts
|
|
119
|
+
/**
|
|
120
|
+
* Defines High-Resolution Time.
|
|
121
|
+
*
|
|
122
|
+
* The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
|
|
123
|
+
* The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
|
|
124
|
+
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
|
|
125
|
+
* The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds:
|
|
126
|
+
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
|
|
127
|
+
* The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
|
|
128
|
+
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
|
|
129
|
+
* This is represented in HrTime format as [1609504210, 150000000].
|
|
130
|
+
*
|
|
131
|
+
* @since 1.0.0
|
|
132
|
+
*/
|
|
133
|
+
type HrTime = [number, number];
|
|
134
|
+
/**
|
|
135
|
+
* Defines TimeInput.
|
|
84
136
|
*
|
|
85
|
-
*
|
|
137
|
+
* hrtime, epoch milliseconds, performance.now() or Date
|
|
86
138
|
*
|
|
87
|
-
* @since 1.
|
|
139
|
+
* @since 1.0.0
|
|
88
140
|
*/
|
|
89
|
-
type
|
|
141
|
+
type TimeInput = HrTime | number | Date;
|
|
142
|
+
//#region src/common/Exception.d.ts
|
|
90
143
|
interface ExceptionWithCode {
|
|
91
144
|
code: string | number;
|
|
92
145
|
name?: string;
|
|
@@ -113,29 +166,7 @@ interface ExceptionWithName {
|
|
|
113
166
|
* @since 1.0.0
|
|
114
167
|
*/
|
|
115
168
|
type Exception = ExceptionWithCode | ExceptionWithMessage | ExceptionWithName | string;
|
|
116
|
-
|
|
117
|
-
* Defines High-Resolution Time.
|
|
118
|
-
*
|
|
119
|
-
* The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
|
|
120
|
-
* The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
|
|
121
|
-
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
|
|
122
|
-
* The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds:
|
|
123
|
-
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
|
|
124
|
-
* The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
|
|
125
|
-
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
|
|
126
|
-
* This is represented in HrTime format as [1609504210, 150000000].
|
|
127
|
-
*
|
|
128
|
-
* @since 1.0.0
|
|
129
|
-
*/
|
|
130
|
-
type HrTime = [number, number];
|
|
131
|
-
/**
|
|
132
|
-
* Defines TimeInput.
|
|
133
|
-
*
|
|
134
|
-
* hrtime, epoch milliseconds, performance.now() or Date
|
|
135
|
-
*
|
|
136
|
-
* @since 1.0.0
|
|
137
|
-
*/
|
|
138
|
-
type TimeInput = HrTime | number | Date;
|
|
169
|
+
//#region src/trace/attributes.d.ts
|
|
139
170
|
/**
|
|
140
171
|
* @deprecated please use {@link Attributes}
|
|
141
172
|
* @since 1.0.0
|
|
@@ -146,6 +177,7 @@ type SpanAttributes = Attributes;
|
|
|
146
177
|
* @since 1.0.0
|
|
147
178
|
*/
|
|
148
179
|
type SpanAttributeValue = AttributeValue;
|
|
180
|
+
//#region src/trace/trace_state.d.ts
|
|
149
181
|
/**
|
|
150
182
|
* @since 1.0.0
|
|
151
183
|
*/
|
|
@@ -186,6 +218,7 @@ interface TraceState {
|
|
|
186
218
|
*/
|
|
187
219
|
serialize(): string;
|
|
188
220
|
}
|
|
221
|
+
//#region src/trace/span_context.d.ts
|
|
189
222
|
/**
|
|
190
223
|
* A SpanContext represents the portion of a {@link Span} which must be
|
|
191
224
|
* serialized and propagated along side of a {@link Baggage}.
|
|
@@ -239,6 +272,7 @@ interface SpanContext {
|
|
|
239
272
|
*/
|
|
240
273
|
traceState?: TraceState;
|
|
241
274
|
}
|
|
275
|
+
//#region src/trace/status.d.ts
|
|
242
276
|
/**
|
|
243
277
|
* @since 1.0.0
|
|
244
278
|
*/
|
|
@@ -268,6 +302,7 @@ declare enum SpanStatusCode {
|
|
|
268
302
|
*/
|
|
269
303
|
ERROR = 2
|
|
270
304
|
}
|
|
305
|
+
//#region src/trace/link.d.ts
|
|
271
306
|
/**
|
|
272
307
|
* A pointer from the current {@link Span} to another span in the same trace or
|
|
273
308
|
* in a different trace.
|
|
@@ -290,9 +325,14 @@ interface Link {
|
|
|
290
325
|
context: SpanContext;
|
|
291
326
|
/** A set of {@link SpanAttributes} on the link. */
|
|
292
327
|
attributes?: SpanAttributes;
|
|
293
|
-
/**
|
|
328
|
+
/**
|
|
329
|
+
* Count of attributes of the link that were dropped due to collection limits
|
|
330
|
+
*
|
|
331
|
+
* @since 1.4.1
|
|
332
|
+
*/
|
|
294
333
|
droppedAttributesCount?: number;
|
|
295
334
|
}
|
|
335
|
+
//#region src/trace/span.d.ts
|
|
296
336
|
/**
|
|
297
337
|
* An interface that represents a span. A span represents a single operation
|
|
298
338
|
* within a trace. Examples of span might include remote procedure calls or a
|
|
@@ -350,6 +390,8 @@ interface Span {
|
|
|
350
390
|
* It is preferred span links be added at span creation.
|
|
351
391
|
*
|
|
352
392
|
* @param link the link to add.
|
|
393
|
+
*
|
|
394
|
+
* @since 1.9.0
|
|
353
395
|
*/
|
|
354
396
|
addLink(link: Link): this;
|
|
355
397
|
/**
|
|
@@ -359,6 +401,8 @@ interface Span {
|
|
|
359
401
|
* It is preferred span links be added at span creation.
|
|
360
402
|
*
|
|
361
403
|
* @param links the links to add.
|
|
404
|
+
*
|
|
405
|
+
* @since 1.9.0
|
|
362
406
|
*/
|
|
363
407
|
addLinks(links: Link[]): this;
|
|
364
408
|
/**
|
|
@@ -418,6 +462,7 @@ interface Span {
|
|
|
418
462
|
*/
|
|
419
463
|
recordException(exception: Exception, time?: TimeInput): void;
|
|
420
464
|
}
|
|
465
|
+
//#region src/trace/span_kind.d.ts
|
|
421
466
|
/**
|
|
422
467
|
* @since 1.0.0
|
|
423
468
|
*/
|
|
@@ -447,6 +492,7 @@ declare enum SpanKind {
|
|
|
447
492
|
*/
|
|
448
493
|
CONSUMER = 4
|
|
449
494
|
}
|
|
495
|
+
//#region src/trace/SpanOptions.d.ts
|
|
450
496
|
/**
|
|
451
497
|
* Options needed for span creation
|
|
452
498
|
*
|
|
@@ -467,6 +513,7 @@ interface SpanOptions {
|
|
|
467
513
|
/** The new span should be a root span. (Ignore parent from context). */
|
|
468
514
|
root?: boolean;
|
|
469
515
|
}
|
|
516
|
+
//#region src/trace/tracer.d.ts
|
|
470
517
|
/**
|
|
471
518
|
* Tracer provides an interface for creating {@link Span}s.
|
|
472
519
|
*
|
|
@@ -494,6 +541,11 @@ interface Tracer {
|
|
|
494
541
|
* Additionally the new span gets set in context and this context is activated
|
|
495
542
|
* for the duration of the function call.
|
|
496
543
|
*
|
|
544
|
+
* **Important**: The callback function is responsible for calling `span.end()`
|
|
545
|
+
* to finish the span. Unlike some other OpenTelemetry implementations, the span
|
|
546
|
+
* is NOT automatically ended when the callback returns. If `span.end()` is not
|
|
547
|
+
* called, the span will never be exported and will be silently lost.
|
|
548
|
+
*
|
|
497
549
|
* @param name The name of the span
|
|
498
550
|
* @param [options] SpanOptions used for span creation
|
|
499
551
|
* @param [context] Context to use to extract parent
|
package/dist/otel.d.ts
CHANGED
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d--zaGh3rX.js";
|
|
45
45
|
import '@lunora/values';
|
|
46
|
+
//#region src/context/types.d.ts
|
|
46
47
|
/**
|
|
47
48
|
* @since 1.0.0
|
|
48
49
|
*/
|
|
@@ -69,24 +70,76 @@ interface Context {
|
|
|
69
70
|
*/
|
|
70
71
|
deleteValue(key: symbol): Context;
|
|
71
72
|
}
|
|
73
|
+
//#region src/common/AnyValue.d.ts
|
|
72
74
|
/**
|
|
73
|
-
*
|
|
75
|
+
* AnyValue can be:
|
|
76
|
+
* - a string, number, boolean value
|
|
77
|
+
* - a byte array (Uint8Array)
|
|
78
|
+
* - array of any value
|
|
79
|
+
* - map from string to any value (a plain Object)
|
|
80
|
+
* - null (an empty value)
|
|
74
81
|
*
|
|
75
|
-
*
|
|
82
|
+
* https://opentelemetry.io/docs/specs/otel/common/#anyvalue
|
|
76
83
|
*
|
|
77
|
-
*
|
|
84
|
+
* Notable JavaScript types that are excluded:
|
|
85
|
+
* - `undefined` - Excluding this means the common practice in instrumentations,
|
|
86
|
+
* using `undefined` to mean "no value for this optional attribute", can
|
|
87
|
+
* remain supported.
|
|
88
|
+
* - `BigInt`
|
|
89
|
+
* - TypedArrays other than `Uint8Array`
|
|
90
|
+
* - subclasses of Object, e.g. Date, Error
|
|
91
|
+
*
|
|
92
|
+
* The TypeScript type `unknown` is used for `AnyValue`. This has some
|
|
93
|
+
* implications:
|
|
94
|
+
* - Callers of `@opentelemetry/api` APIs using `AnyValue` can pass in
|
|
95
|
+
* whatever type. This was always the case for (untyped) JavaScript usage.
|
|
96
|
+
* - SDK implementations of `@opentelemetry/api` need to document if/when they
|
|
97
|
+
* support a subset of AnyValue types.
|
|
98
|
+
* - Using `unknown` allows future changes to support more types (e.g. BigInt).
|
|
99
|
+
*
|
|
100
|
+
* @since 1.10.0
|
|
101
|
+
*/
|
|
102
|
+
type AnyValue = unknown;
|
|
103
|
+
//#region src/common/Attributes.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* Attributes is a mapping from string to attribute values.
|
|
106
|
+
* https://opentelemetry.io/docs/specs/otel/common/#attribute-collections
|
|
107
|
+
*
|
|
108
|
+
* @since 1.1.0
|
|
78
109
|
*/
|
|
79
110
|
interface Attributes {
|
|
80
|
-
[attributeKey: string]:
|
|
111
|
+
[attributeKey: string]: AnyValue;
|
|
81
112
|
}
|
|
82
113
|
/**
|
|
83
|
-
*
|
|
114
|
+
* @since 1.1.0
|
|
115
|
+
* @deprecated use AnyValue
|
|
116
|
+
*/
|
|
117
|
+
type AttributeValue = AnyValue;
|
|
118
|
+
//#region src/common/Time.d.ts
|
|
119
|
+
/**
|
|
120
|
+
* Defines High-Resolution Time.
|
|
121
|
+
*
|
|
122
|
+
* The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
|
|
123
|
+
* The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
|
|
124
|
+
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
|
|
125
|
+
* The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds:
|
|
126
|
+
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
|
|
127
|
+
* The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
|
|
128
|
+
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
|
|
129
|
+
* This is represented in HrTime format as [1609504210, 150000000].
|
|
130
|
+
*
|
|
131
|
+
* @since 1.0.0
|
|
132
|
+
*/
|
|
133
|
+
type HrTime = [number, number];
|
|
134
|
+
/**
|
|
135
|
+
* Defines TimeInput.
|
|
84
136
|
*
|
|
85
|
-
*
|
|
137
|
+
* hrtime, epoch milliseconds, performance.now() or Date
|
|
86
138
|
*
|
|
87
|
-
* @since 1.
|
|
139
|
+
* @since 1.0.0
|
|
88
140
|
*/
|
|
89
|
-
type
|
|
141
|
+
type TimeInput = HrTime | number | Date;
|
|
142
|
+
//#region src/common/Exception.d.ts
|
|
90
143
|
interface ExceptionWithCode {
|
|
91
144
|
code: string | number;
|
|
92
145
|
name?: string;
|
|
@@ -113,29 +166,7 @@ interface ExceptionWithName {
|
|
|
113
166
|
* @since 1.0.0
|
|
114
167
|
*/
|
|
115
168
|
type Exception = ExceptionWithCode | ExceptionWithMessage | ExceptionWithName | string;
|
|
116
|
-
|
|
117
|
-
* Defines High-Resolution Time.
|
|
118
|
-
*
|
|
119
|
-
* The first number, HrTime[0], is UNIX Epoch time in seconds since 00:00:00 UTC on 1 January 1970.
|
|
120
|
-
* The second number, HrTime[1], represents the partial second elapsed since Unix Epoch time represented by first number in nanoseconds.
|
|
121
|
-
* For example, 2021-01-01T12:30:10.150Z in UNIX Epoch time in milliseconds is represented as 1609504210150.
|
|
122
|
-
* The first number is calculated by converting and truncating the Epoch time in milliseconds to seconds:
|
|
123
|
-
* HrTime[0] = Math.trunc(1609504210150 / 1000) = 1609504210.
|
|
124
|
-
* The second number is calculated by converting the digits after the decimal point of the subtraction, (1609504210150 / 1000) - HrTime[0], to nanoseconds:
|
|
125
|
-
* HrTime[1] = Number((1609504210.150 - HrTime[0]).toFixed(9)) * 1e9 = 150000000.
|
|
126
|
-
* This is represented in HrTime format as [1609504210, 150000000].
|
|
127
|
-
*
|
|
128
|
-
* @since 1.0.0
|
|
129
|
-
*/
|
|
130
|
-
type HrTime = [number, number];
|
|
131
|
-
/**
|
|
132
|
-
* Defines TimeInput.
|
|
133
|
-
*
|
|
134
|
-
* hrtime, epoch milliseconds, performance.now() or Date
|
|
135
|
-
*
|
|
136
|
-
* @since 1.0.0
|
|
137
|
-
*/
|
|
138
|
-
type TimeInput = HrTime | number | Date;
|
|
169
|
+
//#region src/trace/attributes.d.ts
|
|
139
170
|
/**
|
|
140
171
|
* @deprecated please use {@link Attributes}
|
|
141
172
|
* @since 1.0.0
|
|
@@ -146,6 +177,7 @@ type SpanAttributes = Attributes;
|
|
|
146
177
|
* @since 1.0.0
|
|
147
178
|
*/
|
|
148
179
|
type SpanAttributeValue = AttributeValue;
|
|
180
|
+
//#region src/trace/trace_state.d.ts
|
|
149
181
|
/**
|
|
150
182
|
* @since 1.0.0
|
|
151
183
|
*/
|
|
@@ -186,6 +218,7 @@ interface TraceState {
|
|
|
186
218
|
*/
|
|
187
219
|
serialize(): string;
|
|
188
220
|
}
|
|
221
|
+
//#region src/trace/span_context.d.ts
|
|
189
222
|
/**
|
|
190
223
|
* A SpanContext represents the portion of a {@link Span} which must be
|
|
191
224
|
* serialized and propagated along side of a {@link Baggage}.
|
|
@@ -239,6 +272,7 @@ interface SpanContext {
|
|
|
239
272
|
*/
|
|
240
273
|
traceState?: TraceState;
|
|
241
274
|
}
|
|
275
|
+
//#region src/trace/status.d.ts
|
|
242
276
|
/**
|
|
243
277
|
* @since 1.0.0
|
|
244
278
|
*/
|
|
@@ -268,6 +302,7 @@ declare enum SpanStatusCode {
|
|
|
268
302
|
*/
|
|
269
303
|
ERROR = 2
|
|
270
304
|
}
|
|
305
|
+
//#region src/trace/link.d.ts
|
|
271
306
|
/**
|
|
272
307
|
* A pointer from the current {@link Span} to another span in the same trace or
|
|
273
308
|
* in a different trace.
|
|
@@ -290,9 +325,14 @@ interface Link {
|
|
|
290
325
|
context: SpanContext;
|
|
291
326
|
/** A set of {@link SpanAttributes} on the link. */
|
|
292
327
|
attributes?: SpanAttributes;
|
|
293
|
-
/**
|
|
328
|
+
/**
|
|
329
|
+
* Count of attributes of the link that were dropped due to collection limits
|
|
330
|
+
*
|
|
331
|
+
* @since 1.4.1
|
|
332
|
+
*/
|
|
294
333
|
droppedAttributesCount?: number;
|
|
295
334
|
}
|
|
335
|
+
//#region src/trace/span.d.ts
|
|
296
336
|
/**
|
|
297
337
|
* An interface that represents a span. A span represents a single operation
|
|
298
338
|
* within a trace. Examples of span might include remote procedure calls or a
|
|
@@ -350,6 +390,8 @@ interface Span {
|
|
|
350
390
|
* It is preferred span links be added at span creation.
|
|
351
391
|
*
|
|
352
392
|
* @param link the link to add.
|
|
393
|
+
*
|
|
394
|
+
* @since 1.9.0
|
|
353
395
|
*/
|
|
354
396
|
addLink(link: Link): this;
|
|
355
397
|
/**
|
|
@@ -359,6 +401,8 @@ interface Span {
|
|
|
359
401
|
* It is preferred span links be added at span creation.
|
|
360
402
|
*
|
|
361
403
|
* @param links the links to add.
|
|
404
|
+
*
|
|
405
|
+
* @since 1.9.0
|
|
362
406
|
*/
|
|
363
407
|
addLinks(links: Link[]): this;
|
|
364
408
|
/**
|
|
@@ -418,6 +462,7 @@ interface Span {
|
|
|
418
462
|
*/
|
|
419
463
|
recordException(exception: Exception, time?: TimeInput): void;
|
|
420
464
|
}
|
|
465
|
+
//#region src/trace/span_kind.d.ts
|
|
421
466
|
/**
|
|
422
467
|
* @since 1.0.0
|
|
423
468
|
*/
|
|
@@ -447,6 +492,7 @@ declare enum SpanKind {
|
|
|
447
492
|
*/
|
|
448
493
|
CONSUMER = 4
|
|
449
494
|
}
|
|
495
|
+
//#region src/trace/SpanOptions.d.ts
|
|
450
496
|
/**
|
|
451
497
|
* Options needed for span creation
|
|
452
498
|
*
|
|
@@ -467,6 +513,7 @@ interface SpanOptions {
|
|
|
467
513
|
/** The new span should be a root span. (Ignore parent from context). */
|
|
468
514
|
root?: boolean;
|
|
469
515
|
}
|
|
516
|
+
//#region src/trace/tracer.d.ts
|
|
470
517
|
/**
|
|
471
518
|
* Tracer provides an interface for creating {@link Span}s.
|
|
472
519
|
*
|
|
@@ -494,6 +541,11 @@ interface Tracer {
|
|
|
494
541
|
* Additionally the new span gets set in context and this context is activated
|
|
495
542
|
* for the duration of the function call.
|
|
496
543
|
*
|
|
544
|
+
* **Important**: The callback function is responsible for calling `span.end()`
|
|
545
|
+
* to finish the span. Unlike some other OpenTelemetry implementations, the span
|
|
546
|
+
* is NOT automatically ended when the callback returns. If `span.end()` is not
|
|
547
|
+
* called, the span will never be exported and will be silently lost.
|
|
548
|
+
*
|
|
497
549
|
* @param name The name of the span
|
|
498
550
|
* @param [options] SpanOptions used for span creation
|
|
499
551
|
* @param [context] Context to use to extract parent
|
package/dist/otel.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SpanKind as
|
|
1
|
+
import{SpanKind as d,trace as l,TraceFlags as g,SpanStatusCode as k}from"@opentelemetry/api";const N=r=>{let t="";for(let e=0;e<r.length;e+=32768)t+=String.fromCharCode(...r.subarray(e,e+32768));return btoa(t)},R={[d.CLIENT]:"client",[d.CONSUMER]:"consumer",[d.INTERNAL]:"internal",[d.PRODUCER]:"producer",[d.SERVER]:"server"},C=r=>{const t=new Uint8Array(r);crypto.getRandomValues(t);let n="";for(const e of t)n+=e.toString(16).padStart(2,"0");return n},S=r=>r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string",p=(r,t)=>{if(typeof r=="bigint")return r.toString();if(r instanceof Uint8Array)return N(r);if(typeof r!="object"||r===null)return r;if(t.has(r))return"[Circular]";t.add(r);try{return Array.isArray(r)?r.map(n=>p(n,t)):typeof r.toJSON=="function"?r:Object.fromEntries(Object.entries(r).map(([n,e])=>[n,p(e,t)]))}finally{t.delete(r)}},w=r=>{if(S(r))return r;if(Array.isArray(r)&&r.every(t=>S(t)))return r.map(String).join(",");if(typeof r=="bigint"||r instanceof Uint8Array)return p(r,new Set);if(typeof r=="function"||typeof r=="symbol")return r.toString();try{return JSON.stringify(p(r,new Set))}catch{return"[unserializable]"}},c=r=>{const t={};for(const[n,e]of Object.entries(r??{}))e!==void 0&&(t[n]=w(e));return t};class x{ended=!1;finish;handle;ids;pending=[];thrown;constructor(t){this.ids=t}get failure(){return this.thrown}addEvent(t,n,e){return this.write(s=>{s.addEvent(t,c(n))}),this}addLink(t){return this.write(n=>{n.addLink({attributes:c(t.attributes),spanId:t.context.spanId,traceId:t.context.traceId})}),this}addLinks(t){for(const n of t)this.addLink(n);return this}attach(t,n){this.handle=t,this.finish=n;for(const e of this.pending)e(t);this.pending.length=0,this.ended&&n()}end(t){this.ended||(this.ended=!0,this.finish?.())}isRecording(){return!this.ended}recordException(t,n){this.write(e=>{if(t instanceof Error||typeof t=="string"){e.recordException(t);return}const s=new Error(t.message??String(t.code??"exception"));t.name!==void 0&&(s.name=t.name),t.stack!==void 0&&(s.stack=t.stack),e.recordException(s)})}setAttribute(t,n){return this.write(e=>{e.setAttribute(t,w(n))}),this}setAttributes(t){return this.write(n=>{n.setAttributes(c(t))}),this}setStatus(t){return t.code===k.ERROR&&(this.thrown=new Error(t.message??"span reported an error status")),this}spanContext(){return this.ids}updateName(t){return this.write(n=>{n.setAttribute("otel.updated_name",t)}),this}write(t){if(this.handle===void 0){this.pending.push(t);return}t(this.handle)}}const j=(r,t={})=>{const{namePrefix:n=""}=t,e=(s,i,f)=>{const o=r.span.spanContext(),h=f===void 0?void 0:l.getSpanContext(f),b=h?.traceId===o.traceId?h.spanId:o.spanId,y=C(8),E={spanId:y,traceFlags:o.sampled??!0?g.SAMPLED:g.NONE,traceId:o.traceId},u=new x(E);let m=()=>{};const I=new Promise(a=>{m=a});return r.trace(`${n}${s}`,async(a,A)=>{if(u.attach(A,m),await I,u.failure!==void 0)throw u.failure},{...i?.attributes===void 0?{}:{attributes:c(i.attributes)},...i?.kind===void 0?{}:{kind:R[i.kind]??"internal"},...i?.links===void 0?{}:{links:i.links.map(a=>({attributes:c(a.attributes),spanId:a.context.spanId,traceId:a.context.traceId}))}},{parentSpanId:b,spanId:y}).catch(()=>{}),u};return{startActiveSpan:(s,...i)=>{const f=i.at(-1),o=typeof i[0]=="object"&&i[0]!==null?i[0]:void 0,h=i.length>2?i[1]:void 0,b=e(s,o,h);return f(b)},startSpan:e}};export{j as createOtelTracer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.290",
|
|
4
4
|
"description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backend",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@lunora/errors": ">=1.0.0-alpha.77 <2.0.0-0",
|
|
76
76
|
"@lunora/scheduler": "^1.0.0-alpha.175",
|
|
77
|
-
"@lunora/shard-engine": "^1.0.0-alpha.
|
|
77
|
+
"@lunora/shard-engine": "^1.0.0-alpha.215",
|
|
78
78
|
"@lunora/values": "^1.0.0-alpha.95",
|
|
79
79
|
"@lunora/wire": "1.0.0-alpha.6",
|
|
80
80
|
"drizzle-orm": "1.0.0-rc.5",
|