arvo-core 1.1.16 → 1.1.18
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/ArvoContract/helpers.js +2 -2
- package/dist/ArvoEvent/helpers.d.ts +2 -1
- package/dist/ArvoEvent/helpers.js +5 -2
- package/dist/ArvoEventFactory/index.d.ts +5 -4
- package/dist/ArvoEventFactory/index.js +18 -9
- package/dist/ArvoOrchestratorContract/schema.js +1 -2
- package/dist/ArvoOrchestratorContract/typegen.d.ts +61 -6
- package/dist/ArvoOrchestratorContract/typegen.js +71 -12
- package/dist/OpenTelemetry/index.d.ts +1 -1
- package/dist/OpenTelemetry/index.js +6 -3
- package/dist/OpenTelemetry/utils.d.ts +1 -1
- package/dist/OpenTelemetry/utils.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
@@ -35,10 +35,10 @@ var utils_1 = require("../utils");
|
|
35
35
|
*/
|
36
36
|
var createArvoContract = function (contract) {
|
37
37
|
var createErrorMessage = function (source, type) {
|
38
|
-
return (0, utils_1.cleanString)("\n In contract (uri=".concat(contract.uri, "), the '").concat(source, "' event (type=").concat(type, ") must not start \n with '").concat(typegen_1.ArvoOrchestratorEventTypeGen.
|
38
|
+
return (0, utils_1.cleanString)("\n In contract (uri=".concat(contract.uri, "), the '").concat(source, "' event (type=").concat(type, ") must not start \n with '").concat(typegen_1.ArvoOrchestratorEventTypeGen.prefix, "' becuase this a reserved pattern \n for Arvo orchestrators.\n "));
|
39
39
|
};
|
40
40
|
var validator = function (value) {
|
41
|
-
return value.startsWith(typegen_1.ArvoOrchestratorEventTypeGen.
|
41
|
+
return value.startsWith(typegen_1.ArvoOrchestratorEventTypeGen.prefix);
|
42
42
|
};
|
43
43
|
if (validator(contract.accepts.type)) {
|
44
44
|
throw new Error(createErrorMessage('accepts', contract.accepts.type));
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import ArvoEvent from '.';
|
2
2
|
import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
|
3
|
+
import { ExecutionOpenTelemetryConfiguration } from '../types';
|
3
4
|
/**
|
4
5
|
* Creates an ArvoEvent with the provided data and extensions.
|
5
6
|
*
|
@@ -35,4 +36,4 @@ import { ArvoEventData, CloudEventExtension, CreateArvoEvent } from './types';
|
|
35
36
|
* { customextension: 'value' },
|
36
37
|
* );
|
37
38
|
*/
|
38
|
-
export declare const createArvoEvent: <TData extends ArvoEventData, TExtension extends CloudEventExtension, TType extends string>(event: CreateArvoEvent<TData, TType>, extensions?: TExtension) => ArvoEvent<TData, TExtension, TType>;
|
39
|
+
export declare const createArvoEvent: <TData extends ArvoEventData, TExtension extends CloudEventExtension, TType extends string>(event: CreateArvoEvent<TData, TType>, extensions?: TExtension, opentelemetry?: ExecutionOpenTelemetryConfiguration) => ArvoEvent<TData, TExtension, TType>;
|
@@ -45,8 +45,11 @@ var uuid_1 = require("uuid");
|
|
45
45
|
* { customextension: 'value' },
|
46
46
|
* );
|
47
47
|
*/
|
48
|
-
var createArvoEvent = function (event, extensions) {
|
49
|
-
|
48
|
+
var createArvoEvent = function (event, extensions, opentelemetry) {
|
49
|
+
if (opentelemetry === void 0) { opentelemetry = {
|
50
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
51
|
+
}; }
|
52
|
+
var span = opentelemetry.tracer.startSpan("createArvoEvent<".concat(event.type, ">"), {});
|
50
53
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
51
54
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
52
55
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import ArvoContract from '../ArvoContract';
|
2
2
|
import { z } from 'zod';
|
3
3
|
import { CreateArvoEvent } from '../ArvoEvent/types';
|
4
|
+
import { ExecutionOpenTelemetryConfiguration } from '../types';
|
4
5
|
/**
|
5
6
|
* A factory class for creating contractual ArvoEvents based on a given ArvoContract.
|
6
7
|
*
|
@@ -10,7 +11,7 @@ import { CreateArvoEvent } from '../ArvoEvent/types';
|
|
10
11
|
* @template TEmits - The type of records the contract bound handler emits.
|
11
12
|
*/
|
12
13
|
export default class ArvoEventFactory<TUri extends string = string, TType extends string = string, TAcceptSchema extends z.ZodTypeAny = z.ZodTypeAny, TEmits extends Record<string, z.ZodTypeAny> = Record<string, z.ZodTypeAny>> {
|
13
|
-
private contract;
|
14
|
+
private readonly contract;
|
14
15
|
/**
|
15
16
|
* Creates an instance of ArvoEventFactory.
|
16
17
|
*
|
@@ -26,7 +27,7 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
|
|
26
27
|
* @returns The created ArvoEvent as per the accept record of the contract.
|
27
28
|
* @throws If the event data fails validation against the contract.
|
28
29
|
*/
|
29
|
-
accepts<TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<z.input<TAcceptSchema>, TType>, 'type' | 'datacontenttype' | 'dataschema'>, extensions?: TExtension): import("..").ArvoEvent<z.TypeOf<TAcceptSchema>, TExtension, TType>;
|
30
|
+
accepts<TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<z.input<TAcceptSchema>, TType>, 'type' | 'datacontenttype' | 'dataschema'>, extensions?: TExtension, opentelemetry?: ExecutionOpenTelemetryConfiguration): import("..").ArvoEvent<z.TypeOf<TAcceptSchema>, TExtension, TType>;
|
30
31
|
/**
|
31
32
|
* Creates an ArvoEvent as per one of the emits record in the contract.
|
32
33
|
*
|
@@ -37,7 +38,7 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
|
|
37
38
|
* @returns The created ArvoEvent as per one of the emits records of the contract.
|
38
39
|
* @throws If the event data fails validation against the contract.
|
39
40
|
*/
|
40
|
-
emits<U extends keyof TEmits & string, TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<z.input<TEmits[U]>, U>, 'datacontenttype' | 'dataschema'>, extensions?: TExtension): import("..").ArvoEvent<z.TypeOf<TEmits[U]>, TExtension, U>;
|
41
|
+
emits<U extends keyof TEmits & string, TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<z.input<TEmits[U]>, U>, 'datacontenttype' | 'dataschema'>, extensions?: TExtension, opentelemetry?: ExecutionOpenTelemetryConfiguration): import("..").ArvoEvent<z.TypeOf<TEmits[U]>, TExtension, U>;
|
41
42
|
/**
|
42
43
|
* Creates a system error ArvoEvent.
|
43
44
|
*
|
@@ -48,7 +49,7 @@ export default class ArvoEventFactory<TUri extends string = string, TType extend
|
|
48
49
|
*/
|
49
50
|
systemError<TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<any, any>, 'data' | 'type' | 'datacontenttype' | 'dataschema'> & {
|
50
51
|
error: Error;
|
51
|
-
}, extensions?: TExtension): import("..").ArvoEvent<{
|
52
|
+
}, extensions?: TExtension, opentelemetry?: ExecutionOpenTelemetryConfiguration): import("..").ArvoEvent<{
|
52
53
|
errorMessage: string;
|
53
54
|
errorName: string;
|
54
55
|
errorStack: string | null;
|
@@ -52,9 +52,12 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
52
52
|
* @returns The created ArvoEvent as per the accept record of the contract.
|
53
53
|
* @throws If the event data fails validation against the contract.
|
54
54
|
*/
|
55
|
-
ArvoEventFactory.prototype.accepts = function (event, extensions) {
|
55
|
+
ArvoEventFactory.prototype.accepts = function (event, extensions, opentelemetry) {
|
56
56
|
var _this = this;
|
57
|
-
|
57
|
+
if (opentelemetry === void 0) { opentelemetry = {
|
58
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
59
|
+
}; }
|
60
|
+
var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.accepts<").concat(this.contract.accepts.type, ">.create"));
|
58
61
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
59
62
|
var _a, _b, _c, _d;
|
60
63
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
@@ -64,7 +67,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
64
67
|
if (!validationResult.success) {
|
65
68
|
throw new Error("Accept Event data validation failed: ".concat(validationResult.error.message));
|
66
69
|
}
|
67
|
-
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { traceparent: (_b = (_a = event.traceparent) !== null && _a !== void 0 ? _a : otelHeaders.traceparent) !== null && _b !== void 0 ? _b : undefined, tracestate: (_d = (_c = event.tracestate) !== null && _c !== void 0 ? _c : otelHeaders.tracestate) !== null && _d !== void 0 ? _d : undefined, type: _this.contract.accepts.type, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions);
|
70
|
+
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { traceparent: (_b = (_a = event.traceparent) !== null && _a !== void 0 ? _a : otelHeaders.traceparent) !== null && _b !== void 0 ? _b : undefined, tracestate: (_d = (_c = event.tracestate) !== null && _c !== void 0 ? _c : otelHeaders.tracestate) !== null && _d !== void 0 ? _d : undefined, type: _this.contract.accepts.type, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions, opentelemetry);
|
68
71
|
}
|
69
72
|
catch (error) {
|
70
73
|
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
@@ -89,9 +92,12 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
89
92
|
* @returns The created ArvoEvent as per one of the emits records of the contract.
|
90
93
|
* @throws If the event data fails validation against the contract.
|
91
94
|
*/
|
92
|
-
ArvoEventFactory.prototype.emits = function (event, extensions) {
|
95
|
+
ArvoEventFactory.prototype.emits = function (event, extensions, opentelemetry) {
|
93
96
|
var _this = this;
|
94
|
-
|
97
|
+
if (opentelemetry === void 0) { opentelemetry = {
|
98
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
99
|
+
}; }
|
100
|
+
var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.emits<").concat(event.type, ">.create"));
|
95
101
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
96
102
|
var _a, _b, _c, _d;
|
97
103
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
@@ -101,7 +107,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
101
107
|
if (!validationResult.success) {
|
102
108
|
throw new Error("Emit Event data validation failed: ".concat(validationResult.error.message));
|
103
109
|
}
|
104
|
-
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { traceparent: (_b = (_a = event.traceparent) !== null && _a !== void 0 ? _a : otelHeaders.traceparent) !== null && _b !== void 0 ? _b : undefined, tracestate: (_d = (_c = event.tracestate) !== null && _c !== void 0 ? _c : otelHeaders.tracestate) !== null && _d !== void 0 ? _d : undefined, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions);
|
110
|
+
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { traceparent: (_b = (_a = event.traceparent) !== null && _a !== void 0 ? _a : otelHeaders.traceparent) !== null && _b !== void 0 ? _b : undefined, tracestate: (_d = (_c = event.tracestate) !== null && _c !== void 0 ? _c : otelHeaders.tracestate) !== null && _d !== void 0 ? _d : undefined, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions, opentelemetry);
|
105
111
|
}
|
106
112
|
catch (error) {
|
107
113
|
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
@@ -124,9 +130,12 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
124
130
|
* @param [extensions] - Optional extensions to add to the event.
|
125
131
|
* @returns The created system error ArvoEvent.
|
126
132
|
*/
|
127
|
-
ArvoEventFactory.prototype.systemError = function (event, extensions) {
|
133
|
+
ArvoEventFactory.prototype.systemError = function (event, extensions, opentelemetry) {
|
128
134
|
var _this = this;
|
129
|
-
|
135
|
+
if (opentelemetry === void 0) { opentelemetry = {
|
136
|
+
tracer: (0, OpenTelemetry_1.fetchOpenTelemetryTracer)(),
|
137
|
+
}; }
|
138
|
+
var span = opentelemetry.tracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.systemError<sys.").concat(this.contract.accepts.type, ".error>.create"));
|
130
139
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
131
140
|
var _a, _b, _c, _d, _e;
|
132
141
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
@@ -137,7 +146,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
137
146
|
errorName: error.name,
|
138
147
|
errorMessage: error.message,
|
139
148
|
errorStack: (_e = error.stack) !== null && _e !== void 0 ? _e : null,
|
140
|
-
}, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri }), extensions);
|
149
|
+
}, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri }), extensions, opentelemetry);
|
141
150
|
}
|
142
151
|
catch (error) {
|
143
152
|
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
@@ -8,8 +8,7 @@ var utils_1 = require("../utils");
|
|
8
8
|
* This schema is used to validate and type-check the minimal required fields
|
9
9
|
* for an orchestrator to accept a task or event.
|
10
10
|
*/
|
11
|
-
exports.OrchestrationInitEventBaseSchema = zod_1.z
|
12
|
-
.object({
|
11
|
+
exports.OrchestrationInitEventBaseSchema = zod_1.z.object({
|
13
12
|
parentSubject$$: zod_1.z
|
14
13
|
.string()
|
15
14
|
.min(1, 'The parent subject must not be an empty string')
|
@@ -1,6 +1,61 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
/**
|
2
|
+
* Utility class for generating standardized event type strings for the Arvo orchestrator.
|
3
|
+
* This class provides methods to create consistent event type identifiers with predefined prefixes
|
4
|
+
* and suffixes for different event states (init, complete, error).
|
5
|
+
*
|
6
|
+
* @example
|
7
|
+
* ```typescript
|
8
|
+
* // Generate event types for a 'payment' event
|
9
|
+
* const initEvent = ArvoOrchestratorEventTypeGen.init('payment') // 'arvo.orc.payment'
|
10
|
+
* const doneEvent = ArvoOrchestratorEventTypeGen.complete('payment') // 'arvo.orc.payment.done'
|
11
|
+
* const errorEvent = ArvoOrchestratorEventTypeGen.systemError('payment') // 'sys.arvo.orc.payment.error'
|
12
|
+
* ```
|
13
|
+
*/
|
14
|
+
export declare class ArvoOrchestratorEventTypeGen {
|
15
|
+
/**
|
16
|
+
* The standard prefix used for all Arvo orchestrator events.
|
17
|
+
* This prefix helps identify events that belong to the Arvo orchestrator system.
|
18
|
+
*/
|
19
|
+
static readonly prefix: 'arvo.orc';
|
20
|
+
/**
|
21
|
+
* Generates an initialization event type string for a given event name.
|
22
|
+
*
|
23
|
+
* @param name - The base name of the event
|
24
|
+
* @returns A type-safe string combining the standard prefix with the provided name
|
25
|
+
* @typeParam T - String literal type for the event name
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```typescript
|
29
|
+
* ArvoOrchestratorEventTypeGen.init('userRegistration') // Returns: 'arvo.orc.userRegistration'
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
static init<T extends string>(name: T): `${typeof ArvoOrchestratorEventTypeGen.prefix}.${T}`;
|
33
|
+
/**
|
34
|
+
* Generates a completion event type string for a given event name.
|
35
|
+
* Appends '.done' to the initialization event type.
|
36
|
+
*
|
37
|
+
* @param name - The base name of the event
|
38
|
+
* @returns A type-safe string for the completion event
|
39
|
+
* @typeParam T - String literal type for the event name
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
* ```typescript
|
43
|
+
* ArvoOrchestratorEventTypeGen.complete('userRegistration') // Returns: 'arvo.orc.userRegistration.done'
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
static complete<T extends string>(name: T): `${ReturnType<typeof ArvoOrchestratorEventTypeGen.init<T>>}.done`;
|
47
|
+
/**
|
48
|
+
* Generates a system error event type string for a given event name.
|
49
|
+
* Prepends 'sys.' and appends '.error' to the initialization event type.
|
50
|
+
*
|
51
|
+
* @param name - The base name of the event
|
52
|
+
* @returns A type-safe string for the system error event
|
53
|
+
* @typeParam T - String literal type for the event name
|
54
|
+
*
|
55
|
+
* @example
|
56
|
+
* ```typescript
|
57
|
+
* ArvoOrchestratorEventTypeGen.systemError('userRegistration') // Returns: 'sys.arvo.orc.userRegistration.error'
|
58
|
+
* ```
|
59
|
+
*/
|
60
|
+
static systemError<T extends string>(name: T): `sys.${ReturnType<typeof ArvoOrchestratorEventTypeGen.init<T>>}.error`;
|
61
|
+
}
|
@@ -1,15 +1,74 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.ArvoOrchestratorEventTypeGen = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
/**
|
5
|
+
* Utility class for generating standardized event type strings for the Arvo orchestrator.
|
6
|
+
* This class provides methods to create consistent event type identifiers with predefined prefixes
|
7
|
+
* and suffixes for different event states (init, complete, error).
|
8
|
+
*
|
9
|
+
* @example
|
10
|
+
* ```typescript
|
11
|
+
* // Generate event types for a 'payment' event
|
12
|
+
* const initEvent = ArvoOrchestratorEventTypeGen.init('payment') // 'arvo.orc.payment'
|
13
|
+
* const doneEvent = ArvoOrchestratorEventTypeGen.complete('payment') // 'arvo.orc.payment.done'
|
14
|
+
* const errorEvent = ArvoOrchestratorEventTypeGen.systemError('payment') // 'sys.arvo.orc.payment.error'
|
15
|
+
* ```
|
16
|
+
*/
|
17
|
+
var ArvoOrchestratorEventTypeGen = /** @class */ (function () {
|
18
|
+
function ArvoOrchestratorEventTypeGen() {
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Generates an initialization event type string for a given event name.
|
22
|
+
*
|
23
|
+
* @param name - The base name of the event
|
24
|
+
* @returns A type-safe string combining the standard prefix with the provided name
|
25
|
+
* @typeParam T - String literal type for the event name
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* ```typescript
|
29
|
+
* ArvoOrchestratorEventTypeGen.init('userRegistration') // Returns: 'arvo.orc.userRegistration'
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
ArvoOrchestratorEventTypeGen.init = function (name) {
|
33
|
+
return "".concat(ArvoOrchestratorEventTypeGen.prefix, ".").concat(name);
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* Generates a completion event type string for a given event name.
|
37
|
+
* Appends '.done' to the initialization event type.
|
38
|
+
*
|
39
|
+
* @param name - The base name of the event
|
40
|
+
* @returns A type-safe string for the completion event
|
41
|
+
* @typeParam T - String literal type for the event name
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* ```typescript
|
45
|
+
* ArvoOrchestratorEventTypeGen.complete('userRegistration') // Returns: 'arvo.orc.userRegistration.done'
|
46
|
+
* ```
|
47
|
+
*/
|
48
|
+
ArvoOrchestratorEventTypeGen.complete = function (name) {
|
49
|
+
return "".concat(ArvoOrchestratorEventTypeGen.init(name), ".done");
|
50
|
+
};
|
51
|
+
/**
|
52
|
+
* Generates a system error event type string for a given event name.
|
53
|
+
* Prepends 'sys.' and appends '.error' to the initialization event type.
|
54
|
+
*
|
55
|
+
* @param name - The base name of the event
|
56
|
+
* @returns A type-safe string for the system error event
|
57
|
+
* @typeParam T - String literal type for the event name
|
58
|
+
*
|
59
|
+
* @example
|
60
|
+
* ```typescript
|
61
|
+
* ArvoOrchestratorEventTypeGen.systemError('userRegistration') // Returns: 'sys.arvo.orc.userRegistration.error'
|
62
|
+
* ```
|
63
|
+
*/
|
64
|
+
ArvoOrchestratorEventTypeGen.systemError = function (name) {
|
65
|
+
return "sys.".concat(ArvoOrchestratorEventTypeGen.init(name), ".error");
|
66
|
+
};
|
67
|
+
/**
|
68
|
+
* The standard prefix used for all Arvo orchestrator events.
|
69
|
+
* This prefix helps identify events that belong to the Arvo orchestrator system.
|
70
|
+
*/
|
71
|
+
ArvoOrchestratorEventTypeGen.prefix = 'arvo.orc';
|
72
|
+
return ArvoOrchestratorEventTypeGen;
|
73
|
+
}());
|
74
|
+
exports.ArvoOrchestratorEventTypeGen = ArvoOrchestratorEventTypeGen;
|
@@ -3,7 +3,7 @@ import { TelemetryLogLevel, OpenTelemetryHeaders } from './types';
|
|
3
3
|
/**
|
4
4
|
* A tracer instance for the ArvoCore package.
|
5
5
|
*/
|
6
|
-
export declare const
|
6
|
+
export declare const fetchOpenTelemetryTracer: () => import("@opentelemetry/api").Tracer;
|
7
7
|
/**
|
8
8
|
* Logs a message to a span with additional parameters.
|
9
9
|
* @param params - The parameters for the log message.
|
@@ -11,16 +11,19 @@ var __assign = (this && this.__assign) || function () {
|
|
11
11
|
return __assign.apply(this, arguments);
|
12
12
|
};
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
exports.OTelNull = exports.exceptionToSpan = exports.logToSpan = exports.
|
14
|
+
exports.OTelNull = exports.exceptionToSpan = exports.logToSpan = exports.fetchOpenTelemetryTracer = void 0;
|
15
15
|
exports.currentOpenTelemetryHeaders = currentOpenTelemetryHeaders;
|
16
16
|
var api_1 = require("@opentelemetry/api");
|
17
17
|
var utils_1 = require("./utils");
|
18
18
|
var core_1 = require("@opentelemetry/core");
|
19
|
-
var pkg = (0, utils_1.getPackageInfo)();
|
20
19
|
/**
|
21
20
|
* A tracer instance for the ArvoCore package.
|
22
21
|
*/
|
23
|
-
|
22
|
+
var fetchOpenTelemetryTracer = function () {
|
23
|
+
var pkg = (0, utils_1.getPackageInfo)('arvo-core');
|
24
|
+
return api_1.trace.getTracer(pkg.name, pkg.version);
|
25
|
+
};
|
26
|
+
exports.fetchOpenTelemetryTracer = fetchOpenTelemetryTracer;
|
24
27
|
/**
|
25
28
|
* Logs a message to a span with additional parameters.
|
26
29
|
* @param params - The parameters for the log message.
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getPackageInfo = getPackageInfo;
|
27
27
|
var fs = __importStar(require("fs"));
|
28
28
|
var path = __importStar(require("path"));
|
29
|
-
function getPackageInfo() {
|
29
|
+
function getPackageInfo(defaultName) {
|
30
30
|
try {
|
31
31
|
// Read the package.json file
|
32
32
|
var packageJsonPath = path.resolve(__dirname, '../../package.json');
|
@@ -39,6 +39,6 @@ function getPackageInfo() {
|
|
39
39
|
}
|
40
40
|
catch (error) {
|
41
41
|
console.error('Error reading package.json:', error);
|
42
|
-
return { name:
|
42
|
+
return { name: defaultName, version: 'Unknown' };
|
43
43
|
}
|
44
44
|
}
|
package/dist/index.d.ts
CHANGED
@@ -23,7 +23,7 @@ import { ArvoOrchestrationSubjectContentSchema, ArvoOrchestratorVersionSchema }
|
|
23
23
|
import { ArvoOrchestrationSubjectContent, ArvoOrchestratorVersion } from './ArvoOrchestrationSubject/type';
|
24
24
|
import ArvoEventHttp from './ArvoEventHttp';
|
25
25
|
import { ArvoEventHttpConfig } from './ArvoEventHttp/types';
|
26
|
-
import { InferArvoContract, InferArvoEvent, InferArvoOrchestratorContract } from './types';
|
26
|
+
import { InferArvoContract, InferArvoEvent, InferArvoOrchestratorContract, ExecutionOpenTelemetryConfiguration } from './types';
|
27
27
|
import { createArvoOrchestratorContract } from './ArvoOrchestratorContract/helpers';
|
28
28
|
import ArvoOrchestratorContract from './ArvoOrchestratorContract';
|
29
29
|
import { ICreateArvoOrchestratorContract, IArvoOrchestratorContract } from './ArvoOrchestratorContract/types';
|
@@ -102,4 +102,4 @@ declare const ArvoEventSchemas: {
|
|
102
102
|
parentSubject$$: string | null;
|
103
103
|
}>;
|
104
104
|
};
|
105
|
-
export { ArvoEventHttpConfig, ArvoEventHttp, ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchemas, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, IArvoContract, ResolveArvoContractRecord, ArvoContractLibrary, createArvoContractLibrary, ArvoEventFactory, createArvoEventFactory, ArvoErrorSchema, currentOpenTelemetryHeaders, OpenInference, OpenInferenceSpanKind, ArvoExecution, ArvoExecutionSpanKind, ArvoContractJSONSchema, ArvoOrchestrationSubject, ArvoOrchestrationSubjectContentSchema, ArvoOrchestratorVersionSchema, ArvoOrchestrationSubjectContent, ArvoOrchestratorVersion, InferArvoEvent, InferArvoContract, InferArvoContractType, createArvoOrchestratorContract, ArvoOrchestratorContract, ICreateArvoOrchestratorContract, IArvoOrchestratorContract, InferArvoOrchestratorContract, ArvoOrchestratorEventTypeGen, };
|
105
|
+
export { ArvoEventHttpConfig, ArvoEventHttp, ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchemas, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, IArvoContract, ResolveArvoContractRecord, ArvoContractLibrary, createArvoContractLibrary, ArvoEventFactory, createArvoEventFactory, ArvoErrorSchema, currentOpenTelemetryHeaders, OpenInference, OpenInferenceSpanKind, ArvoExecution, ArvoExecutionSpanKind, ArvoContractJSONSchema, ArvoOrchestrationSubject, ArvoOrchestrationSubjectContentSchema, ArvoOrchestratorVersionSchema, ArvoOrchestrationSubjectContent, ArvoOrchestratorVersion, InferArvoEvent, InferArvoContract, InferArvoContractType, createArvoOrchestratorContract, ArvoOrchestratorContract, ICreateArvoOrchestratorContract, IArvoOrchestratorContract, InferArvoOrchestratorContract, ArvoOrchestratorEventTypeGen, ExecutionOpenTelemetryConfiguration, };
|
package/dist/types.d.ts
CHANGED
@@ -3,6 +3,20 @@ import ArvoContract from './ArvoContract';
|
|
3
3
|
import ArvoEvent from './ArvoEvent';
|
4
4
|
import { ArvoExtension, OpenTelemetryExtension } from './ArvoEvent/types';
|
5
5
|
import ArvoOrchestratorContract from './ArvoOrchestratorContract';
|
6
|
+
import { Tracer } from '@opentelemetry/api';
|
7
|
+
/**
|
8
|
+
* Configuration options for OpenTelemetry integration in execution context.
|
9
|
+
*
|
10
|
+
* This type defines how tracing should be configured and inherited within
|
11
|
+
* the execution pipeline.
|
12
|
+
*/
|
13
|
+
export type ExecutionOpenTelemetryConfiguration = {
|
14
|
+
/**
|
15
|
+
* OpenTelemetry tracer instance to use for creating spans.
|
16
|
+
* If not provided, a default tracer may be used depending on the implementation.
|
17
|
+
*/
|
18
|
+
tracer: Tracer;
|
19
|
+
};
|
6
20
|
/**
|
7
21
|
* A type utility that infers the structure of an ArvoEvent.
|
8
22
|
*
|