@clayroach/effect 3.19.14-source-capture.1 → 3.19.14-source-capture.3
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/cjs/RuntimeFlags.js +29 -1
- package/dist/cjs/RuntimeFlags.js.map +1 -1
- package/dist/cjs/Utils.js +1 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/clock.js +1 -1
- package/dist/cjs/internal/clock.js.map +1 -1
- package/dist/cjs/internal/core.js +28 -3
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +27 -11
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/layer/circular.js +5 -1
- package/dist/cjs/internal/layer/circular.js.map +1 -1
- package/dist/cjs/internal/runtimeFlags.js +11 -2
- package/dist/cjs/internal/runtimeFlags.js.map +1 -1
- package/dist/dts/RuntimeFlags.d.ts +28 -0
- package/dist/dts/RuntimeFlags.d.ts.map +1 -1
- package/dist/dts/internal/runtimeFlags.d.ts.map +1 -1
- package/dist/esm/RuntimeFlags.js +28 -0
- package/dist/esm/RuntimeFlags.js.map +1 -1
- package/dist/esm/Utils.js +1 -1
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/clock.js +1 -1
- package/dist/esm/internal/clock.js.map +1 -1
- package/dist/esm/internal/core.js +24 -0
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +27 -11
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/layer/circular.js +4 -0
- package/dist/esm/internal/layer/circular.js.map +1 -1
- package/dist/esm/internal/runtimeFlags.js +9 -1
- package/dist/esm/internal/runtimeFlags.js.map +1 -1
- package/package.json +1 -3
- package/src/RuntimeFlags.ts +32 -0
- package/src/internal/core.ts +55 -0
- package/src/internal/fiberRuntime.ts +32 -11
- package/src/internal/layer/circular.ts +14 -0
- package/src/internal/runtimeFlags.ts +11 -1
|
@@ -14,7 +14,9 @@ export const WindDown = 1 << 4;
|
|
|
14
14
|
/** @internal */
|
|
15
15
|
export const CooperativeYielding = 1 << 5;
|
|
16
16
|
/** @internal */
|
|
17
|
-
export const
|
|
17
|
+
export const OperationTracing = 1 << 6;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export const allFlags = [None, Interruption, OpSupervision, RuntimeMetrics, WindDown, CooperativeYielding, OperationTracing];
|
|
18
20
|
const print = flag => {
|
|
19
21
|
switch (flag) {
|
|
20
22
|
case CooperativeYielding:
|
|
@@ -33,6 +35,10 @@ const print = flag => {
|
|
|
33
35
|
{
|
|
34
36
|
return "OpSupervision";
|
|
35
37
|
}
|
|
38
|
+
case OperationTracing:
|
|
39
|
+
{
|
|
40
|
+
return "OperationTracing";
|
|
41
|
+
}
|
|
36
42
|
case Interruption:
|
|
37
43
|
{
|
|
38
44
|
return "Interruption";
|
|
@@ -68,6 +74,8 @@ export const none = /*#__PURE__*/make(None);
|
|
|
68
74
|
/** @internal */
|
|
69
75
|
export const opSupervision = self => isEnabled(self, OpSupervision);
|
|
70
76
|
/** @internal */
|
|
77
|
+
export const operationTracing = self => isEnabled(self, OperationTracing);
|
|
78
|
+
/** @internal */
|
|
71
79
|
export const render = self => {
|
|
72
80
|
const active = [];
|
|
73
81
|
allFlags.forEach(flag => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeFlags.js","names":["dual","internalDiffer","runtimeFlagsPatch","None","Interruption","OpSupervision","RuntimeMetrics","WindDown","CooperativeYielding","allFlags","print","flag","cooperativeYielding","self","isEnabled","disable","disableAll","flags","enable","enableAll","interruptible","interruption","windDown","isDisabled","make","reduce","a","b","none","opSupervision","render","active","forEach","push","join","runtimeMetrics","toSet","Set","filter","enabledSet","enabled","disabledSet","diff","that","patch","invert","renderPatch","Array","from","map","disabled","differ","empty","oldValue","newValue","combine","first","second","andThen","_patch"],"sources":["../../../src/internal/runtimeFlags.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,IAAI,QAAQ,gBAAgB;AAGrC,OAAO,KAAKC,cAAc,MAAM,aAAa;AAC7C,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB;AAE3D;AACA,OAAO,MAAMC,IAAI,GAA6B,CAA6B;AAE3E;AACA,OAAO,MAAMC,YAAY,GAA6B,CAAC,IAAI,CAA6B;AAExF;AACA,OAAO,MAAMC,aAAa,GAA6B,CAAC,IAAI,CAA6B;AAEzF;AACA,OAAO,MAAMC,cAAc,GAA6B,CAAC,IAAI,CAA6B;AAE1F;AACA,OAAO,MAAMC,QAAQ,GAA6B,CAAC,IAAI,CAA6B;AAEpF;AACA,OAAO,MAAMC,mBAAmB,GAA6B,CAAC,IAAI,CAA6B;AAE/F;AACA,OAAO,MAAMC,QAAQ,GAA4C,CAC/
|
|
1
|
+
{"version":3,"file":"runtimeFlags.js","names":["dual","internalDiffer","runtimeFlagsPatch","None","Interruption","OpSupervision","RuntimeMetrics","WindDown","CooperativeYielding","OperationTracing","allFlags","print","flag","cooperativeYielding","self","isEnabled","disable","disableAll","flags","enable","enableAll","interruptible","interruption","windDown","isDisabled","make","reduce","a","b","none","opSupervision","operationTracing","render","active","forEach","push","join","runtimeMetrics","toSet","Set","filter","enabledSet","enabled","disabledSet","diff","that","patch","invert","renderPatch","Array","from","map","disabled","differ","empty","oldValue","newValue","combine","first","second","andThen","_patch"],"sources":["../../../src/internal/runtimeFlags.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,IAAI,QAAQ,gBAAgB;AAGrC,OAAO,KAAKC,cAAc,MAAM,aAAa;AAC7C,OAAO,KAAKC,iBAAiB,MAAM,wBAAwB;AAE3D;AACA,OAAO,MAAMC,IAAI,GAA6B,CAA6B;AAE3E;AACA,OAAO,MAAMC,YAAY,GAA6B,CAAC,IAAI,CAA6B;AAExF;AACA,OAAO,MAAMC,aAAa,GAA6B,CAAC,IAAI,CAA6B;AAEzF;AACA,OAAO,MAAMC,cAAc,GAA6B,CAAC,IAAI,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,CAAC,GAAG5C,iBAAiB,CAACwC,OAAO,CAACI,KAAK,CAAC,CAAC,GACrG5C,iBAAiB,CAAC+B,MAAM,CAACa,KAAK,CAAC,GAAG5C,iBAAiB,CAACwC,OAAO,CAACI,KAAK,CACtC,CAAC;AAEjC;AACA,OAAO,MAAME,WAAW,GAAIlC,IAAyC,IAAY;EAC/E,MAAM4B,OAAO,GAAGO,KAAK,CAACC,IAAI,CAACT,UAAU,CAAC3B,IAAI,CAAC,CAAC,CACzCqC,GAAG,CAAEvC,IAAI,IAAKD,KAAK,CAACC,IAAI,CAAC,CAAC,CAC1BwB,IAAI,CAAC,IAAI,CAAC;EACb,MAAMgB,QAAQ,GAAGH,KAAK,CAACC,IAAI,CAACP,WAAW,CAAC7B,IAAI,CAAC,CAAC,CAC3CqC,GAAG,CAAEvC,IAAI,IAAKD,KAAK,CAACC,IAAI,CAAC,CAAC,CAC1BwB,IAAI,CAAC,IAAI,CAAC;EACb,OAAO,gCAAgCM,OAAO,kBAAkBU,QAAQ,IAAI;AAC9E,CAAC;AAED;AACA,OAAO,MAAMC,MAAM,gBAAkFpD,cAAc,CAChHwB,IAAI,CAAC;EACJ6B,KAAK,EAAEpD,iBAAiB,CAACoD,KAAK;EAC9BV,IAAI,EAAEA,CAACW,QAAQ,EAAEC,QAAQ,KAAKZ,IAAI,CAACW,QAAQ,EAAEC,QAAQ,CAAC;EACtDC,OAAO,EAAEA,CAACC,KAAK,EAAEC,MAAM,KAAKzD,iBAAiB,CAAC0D,OAAO,CAACD,MAAM,CAAC,CAACD,KAAK,CAAC;EACpEZ,KAAK,EAAEA,CAACe,MAAM,EAAEN,QAAQ,KAAKT,KAAK,CAACS,QAAQ,EAAEM,MAAM;CACpD,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clayroach/effect",
|
|
3
|
-
"version": "3.19.14-source-capture.
|
|
3
|
+
"version": "3.19.14-source-capture.3",
|
|
4
4
|
"description": "The missing standard library for TypeScript, for writing production-grade software.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
"@standard-schema/spec": "^1.0.0",
|
|
15
15
|
"fast-check": "^3.23.1"
|
|
16
16
|
},
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
},
|
|
19
17
|
"main": "./dist/cjs/index.js",
|
|
20
18
|
"module": "./dist/esm/index.js",
|
|
21
19
|
"types": "./dist/dts/index.d.ts",
|
package/src/RuntimeFlags.ts
CHANGED
|
@@ -59,6 +59,17 @@ export const Interruption: RuntimeFlag = internal.Interruption
|
|
|
59
59
|
*/
|
|
60
60
|
export const OpSupervision: RuntimeFlag = internal.OpSupervision
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The operation tracing flag determines whether or not the Effect runtime system
|
|
64
|
+
* will capture metadata for high-level operations (such as Effect.all, Effect.forEach)
|
|
65
|
+
* in the trace field. This metadata can be consumed by supervisors via OpSupervision
|
|
66
|
+
* to enable automatic span creation without manual instrumentation.
|
|
67
|
+
*
|
|
68
|
+
* @since 3.10.0
|
|
69
|
+
* @category constructors
|
|
70
|
+
*/
|
|
71
|
+
export const OperationTracing: RuntimeFlag = internal.OperationTracing
|
|
72
|
+
|
|
62
73
|
/**
|
|
63
74
|
* The runtime metrics flag determines whether or not the Effect runtime system
|
|
64
75
|
* will collect metrics about the Effect runtime. Use of this flag will have a
|
|
@@ -160,6 +171,12 @@ export const disableInterruption: Layer.Layer<never> = circular.disableInterrupt
|
|
|
160
171
|
*/
|
|
161
172
|
export const disableOpSupervision: Layer.Layer<never> = circular.disableOpSupervision
|
|
162
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @since 3.10.0
|
|
176
|
+
* @category context
|
|
177
|
+
*/
|
|
178
|
+
export const disableOperationTracing: Layer.Layer<never> = circular.disableOperationTracing
|
|
179
|
+
|
|
163
180
|
/**
|
|
164
181
|
* @since 2.0.0
|
|
165
182
|
* @category context
|
|
@@ -212,6 +229,12 @@ export const enableInterruption: Layer.Layer<never> = circular.enableInterruptio
|
|
|
212
229
|
*/
|
|
213
230
|
export const enableOpSupervision: Layer.Layer<never> = circular.enableOpSupervision
|
|
214
231
|
|
|
232
|
+
/**
|
|
233
|
+
* @since 3.10.0
|
|
234
|
+
* @category context
|
|
235
|
+
*/
|
|
236
|
+
export const enableOperationTracing: Layer.Layer<never> = circular.enableOperationTracing
|
|
237
|
+
|
|
215
238
|
/**
|
|
216
239
|
* @since 2.0.0
|
|
217
240
|
* @category context
|
|
@@ -289,6 +312,15 @@ export const none: RuntimeFlags = internal.none
|
|
|
289
312
|
*/
|
|
290
313
|
export const opSupervision: (self: RuntimeFlags) => boolean = internal.opSupervision
|
|
291
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Returns `true` if the `OperationTracing` `RuntimeFlag` is enabled, `false`
|
|
317
|
+
* otherwise.
|
|
318
|
+
*
|
|
319
|
+
* @since 3.10.0
|
|
320
|
+
* @category getters
|
|
321
|
+
*/
|
|
322
|
+
export const operationTracing: (self: RuntimeFlags) => boolean = internal.operationTracing
|
|
323
|
+
|
|
292
324
|
/**
|
|
293
325
|
* Patches a set of `RuntimeFlag`s with a `RuntimeFlagsPatch`, returning the
|
|
294
326
|
* patched set of `RuntimeFlag`s.
|
package/src/internal/core.ts
CHANGED
|
@@ -1495,6 +1495,17 @@ export const withCaptureStackTraces = dual<
|
|
|
1495
1495
|
enabled
|
|
1496
1496
|
))
|
|
1497
1497
|
|
|
1498
|
+
/** @internal */
|
|
1499
|
+
export const withCaptureOperations = dual<
|
|
1500
|
+
(enabled: boolean) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
|
|
1501
|
+
<A, E, R>(effect: Effect.Effect<A, E, R>, enabled: boolean) => Effect.Effect<A, E, R>
|
|
1502
|
+
>(2, (effect, enabled) =>
|
|
1503
|
+
fiberRefLocally(
|
|
1504
|
+
effect,
|
|
1505
|
+
currentCaptureOperations,
|
|
1506
|
+
enabled
|
|
1507
|
+
))
|
|
1508
|
+
|
|
1498
1509
|
/* @internal */
|
|
1499
1510
|
export const yieldNow = (options?: {
|
|
1500
1511
|
readonly priority?: number | undefined
|
|
@@ -2175,6 +2186,50 @@ export interface SourceLocation {
|
|
|
2175
2186
|
readonly functionName?: string
|
|
2176
2187
|
}
|
|
2177
2188
|
|
|
2189
|
+
/**
|
|
2190
|
+
* Represents metadata for a high-level Effect operation.
|
|
2191
|
+
* Stored in the `trace` field of Effect primitives when operation tracing is enabled.
|
|
2192
|
+
* The `_tag` field identifies this as operation metadata for use by supervisors.
|
|
2193
|
+
* @internal
|
|
2194
|
+
*/
|
|
2195
|
+
export interface OperationMeta {
|
|
2196
|
+
readonly _tag: "OperationMeta" // Tag to identify operation metadata
|
|
2197
|
+
readonly op: string // Operation name: 'all', 'forEach', 'retry', etc.
|
|
2198
|
+
readonly count?: number // Item count for all/forEach
|
|
2199
|
+
readonly capturedAt: string // Stack trace captured at creation time
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/**
|
|
2203
|
+
* Creates operation metadata for tracing high-level Effect operations.
|
|
2204
|
+
* @internal
|
|
2205
|
+
*/
|
|
2206
|
+
export const makeOperationMeta = (
|
|
2207
|
+
op: string,
|
|
2208
|
+
capturedAt: string,
|
|
2209
|
+
count?: number
|
|
2210
|
+
): OperationMeta => {
|
|
2211
|
+
const meta: OperationMeta = {
|
|
2212
|
+
_tag: "OperationMeta",
|
|
2213
|
+
op,
|
|
2214
|
+
capturedAt
|
|
2215
|
+
}
|
|
2216
|
+
if (count !== undefined) {
|
|
2217
|
+
(meta as { count?: number }).count = count
|
|
2218
|
+
}
|
|
2219
|
+
return meta
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* FiberRef that controls whether operation tracing is enabled.
|
|
2224
|
+
* When enabled, high-level operations like Effect.all, Effect.forEach
|
|
2225
|
+
* capture their call site and store metadata in the trace field.
|
|
2226
|
+
* @internal
|
|
2227
|
+
*/
|
|
2228
|
+
export const currentCaptureOperations: FiberRef.FiberRef<boolean> = globalValue(
|
|
2229
|
+
Symbol.for("effect/FiberRef/currentCaptureOperations"),
|
|
2230
|
+
() => fiberRefUnsafeMake(false)
|
|
2231
|
+
)
|
|
2232
|
+
|
|
2178
2233
|
/**
|
|
2179
2234
|
* FiberRef that controls whether source location capture is enabled.
|
|
2180
2235
|
* When enabled, `Effect.fork` captures the call site and stores it
|
|
@@ -1969,20 +1969,31 @@ export const all = <
|
|
|
1969
1969
|
arg: Arg,
|
|
1970
1970
|
options?: O
|
|
1971
1971
|
): Effect.All.Return<Arg, O> => {
|
|
1972
|
+
// Capture stack trace early (while user code is on stack)
|
|
1973
|
+
const rawStack = new Error().stack ?? ""
|
|
1974
|
+
|
|
1972
1975
|
const [effects, reconcile] = allResolveInput(arg)
|
|
1976
|
+
const count = Array.isArray(effects) ? effects.length : undefined
|
|
1977
|
+
|
|
1978
|
+
let result: Effect.Effect<any, any, any>
|
|
1973
1979
|
|
|
1974
1980
|
if (options?.mode === "validate") {
|
|
1975
|
-
|
|
1981
|
+
result = allValidate(effects, reconcile, options) as any
|
|
1976
1982
|
} else if (options?.mode === "either") {
|
|
1977
|
-
|
|
1983
|
+
result = allEither(effects, reconcile, options) as any
|
|
1984
|
+
} else {
|
|
1985
|
+
result = options?.discard !== true && reconcile._tag === "Some"
|
|
1986
|
+
? core.map(
|
|
1987
|
+
forEach(effects, identity, options as any),
|
|
1988
|
+
reconcile.value
|
|
1989
|
+
) as any
|
|
1990
|
+
: forEach(effects, identity, options as any) as any
|
|
1978
1991
|
}
|
|
1979
1992
|
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
) as any
|
|
1985
|
-
: forEach(effects, identity, options as any) as any
|
|
1993
|
+
// Set operation metadata in trace field for OpSupervision
|
|
1994
|
+
;(result as any).trace = core.makeOperationMeta("all", rawStack, count)
|
|
1995
|
+
|
|
1996
|
+
return result as Effect.All.Return<Arg, O>
|
|
1986
1997
|
}
|
|
1987
1998
|
|
|
1988
1999
|
/* @internal */
|
|
@@ -2125,8 +2136,12 @@ export const forEach: {
|
|
|
2125
2136
|
readonly discard?: boolean | undefined
|
|
2126
2137
|
readonly concurrentFinalizers?: boolean | undefined
|
|
2127
2138
|
}
|
|
2128
|
-
) =>
|
|
2129
|
-
|
|
2139
|
+
) => {
|
|
2140
|
+
// Capture stack trace early (while user code is on stack)
|
|
2141
|
+
const rawStack = new Error().stack ?? ""
|
|
2142
|
+
const count = Array.isArray(self) ? self.length : undefined
|
|
2143
|
+
|
|
2144
|
+
const result = core.withFiberRuntime<A | void, E, R>((r) => {
|
|
2130
2145
|
const isRequestBatchingEnabled = options?.batching === true ||
|
|
2131
2146
|
(options?.batching === "inherit" && r.getFiberRef(core.currentRequestBatching))
|
|
2132
2147
|
|
|
@@ -2167,7 +2182,13 @@ export const forEach: {
|
|
|
2167
2182
|
forEachParN(self, n, (a, i) => restore(f(a, i)), isRequestBatchingEnabled)
|
|
2168
2183
|
)
|
|
2169
2184
|
)
|
|
2170
|
-
})
|
|
2185
|
+
})
|
|
2186
|
+
|
|
2187
|
+
// Set operation metadata in trace field for OpSupervision
|
|
2188
|
+
;(result as any).trace = core.makeOperationMeta("forEach", rawStack, count)
|
|
2189
|
+
|
|
2190
|
+
return result
|
|
2191
|
+
})
|
|
2171
2192
|
|
|
2172
2193
|
/* @internal */
|
|
2173
2194
|
export const forEachParUnbounded = <A, B, E, R>(
|
|
@@ -131,6 +131,13 @@ export const enableOpSupervision: Layer.Layer<never> = layer.scopedDiscard(
|
|
|
131
131
|
)
|
|
132
132
|
)
|
|
133
133
|
|
|
134
|
+
/** @internal */
|
|
135
|
+
export const enableOperationTracing: Layer.Layer<never> = layer.scopedDiscard(
|
|
136
|
+
fiberRuntime.withRuntimeFlagsScoped(
|
|
137
|
+
runtimeFlagsPatch.enable(runtimeFlags.OperationTracing)
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
|
|
134
141
|
/** @internal */
|
|
135
142
|
export const enableRuntimeMetrics: Layer.Layer<never> = layer.scopedDiscard(
|
|
136
143
|
fiberRuntime.withRuntimeFlagsScoped(
|
|
@@ -166,6 +173,13 @@ export const disableOpSupervision: Layer.Layer<never> = layer.scopedDiscard(
|
|
|
166
173
|
)
|
|
167
174
|
)
|
|
168
175
|
|
|
176
|
+
/** @internal */
|
|
177
|
+
export const disableOperationTracing: Layer.Layer<never> = layer.scopedDiscard(
|
|
178
|
+
fiberRuntime.withRuntimeFlagsScoped(
|
|
179
|
+
runtimeFlagsPatch.disable(runtimeFlags.OperationTracing)
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
|
|
169
183
|
/** @internal */
|
|
170
184
|
export const disableRuntimeMetrics: Layer.Layer<never> = layer.scopedDiscard(
|
|
171
185
|
fiberRuntime.withRuntimeFlagsScoped(
|
|
@@ -23,6 +23,9 @@ export const WindDown: RuntimeFlags.RuntimeFlag = 1 << 4 as RuntimeFlags.Runtime
|
|
|
23
23
|
/** @internal */
|
|
24
24
|
export const CooperativeYielding: RuntimeFlags.RuntimeFlag = 1 << 5 as RuntimeFlags.RuntimeFlag
|
|
25
25
|
|
|
26
|
+
/** @internal */
|
|
27
|
+
export const OperationTracing: RuntimeFlags.RuntimeFlag = 1 << 6 as RuntimeFlags.RuntimeFlag
|
|
28
|
+
|
|
26
29
|
/** @internal */
|
|
27
30
|
export const allFlags: ReadonlyArray<RuntimeFlags.RuntimeFlag> = [
|
|
28
31
|
None,
|
|
@@ -30,7 +33,8 @@ export const allFlags: ReadonlyArray<RuntimeFlags.RuntimeFlag> = [
|
|
|
30
33
|
OpSupervision,
|
|
31
34
|
RuntimeMetrics,
|
|
32
35
|
WindDown,
|
|
33
|
-
CooperativeYielding
|
|
36
|
+
CooperativeYielding,
|
|
37
|
+
OperationTracing
|
|
34
38
|
]
|
|
35
39
|
|
|
36
40
|
const print = (flag: RuntimeFlags.RuntimeFlag) => {
|
|
@@ -47,6 +51,9 @@ const print = (flag: RuntimeFlags.RuntimeFlag) => {
|
|
|
47
51
|
case OpSupervision: {
|
|
48
52
|
return "OpSupervision"
|
|
49
53
|
}
|
|
54
|
+
case OperationTracing: {
|
|
55
|
+
return "OperationTracing"
|
|
56
|
+
}
|
|
50
57
|
case Interruption: {
|
|
51
58
|
return "Interruption"
|
|
52
59
|
}
|
|
@@ -111,6 +118,9 @@ export const none: RuntimeFlags.RuntimeFlags = make(None)
|
|
|
111
118
|
/** @internal */
|
|
112
119
|
export const opSupervision = (self: RuntimeFlags.RuntimeFlags): boolean => isEnabled(self, OpSupervision)
|
|
113
120
|
|
|
121
|
+
/** @internal */
|
|
122
|
+
export const operationTracing = (self: RuntimeFlags.RuntimeFlags): boolean => isEnabled(self, OperationTracing)
|
|
123
|
+
|
|
114
124
|
/** @internal */
|
|
115
125
|
export const render = (self: RuntimeFlags.RuntimeFlags): string => {
|
|
116
126
|
const active: Array<string> = []
|