arvo-event-handler 1.1.16 → 1.1.18
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/AbstractArvoEventHandler/index.d.ts +15 -3
- package/dist/ArvoEventHandler/index.d.ts +2 -2
- package/dist/ArvoEventHandler/index.js +2 -2
- package/dist/ArvoEventRouter/index.d.ts +2 -2
- package/dist/ArvoEventRouter/index.js +2 -2
- package/dist/MultiArvoEventHandler/index.d.ts +2 -2
- package/dist/MultiArvoEventHandler/index.js +2 -2
- package/dist/OpenTelemetry/index.d.ts +0 -2
- package/dist/OpenTelemetry/index.js +1 -10
- package/dist/OpenTelemetry/types.d.ts +48 -0
- package/dist/OpenTelemetry/utils.d.ts +20 -2
- package/dist/OpenTelemetry/utils.js +48 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/dist/AbstractArvoEventHandler/types.d.ts +0 -20
- package/dist/AbstractArvoEventHandler/utils.d.ts +0 -42
- package/dist/AbstractArvoEventHandler/utils.js +0 -41
- /package/dist/{AbstractArvoEventHandler → OpenTelemetry}/types.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArvoContractRecord, ArvoEvent } from 'arvo-core';
|
|
2
|
-
import {
|
|
2
|
+
import { OpenTelemetryConfig } from '../OpenTelemetry/types';
|
|
3
3
|
/**
|
|
4
4
|
* Abstract base class for Arvo event handlers.
|
|
5
5
|
*
|
|
@@ -11,13 +11,25 @@ import { ExecutionOpenTelemetryConfiguration } from './types';
|
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
13
|
export default abstract class AbstractArvoEventHandler {
|
|
14
|
+
/**
|
|
15
|
+
* The source identifier for the event handler.
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* Uniquely identifies the '<ArvoEvent>.type' of events processed by this handler.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* - Should be unique across all event handlers in the system
|
|
22
|
+
* - Typically follows a dotted notation pattern (e.g., 'domain.entity.action')
|
|
23
|
+
* - Used for routing, logging, and observability purposes
|
|
24
|
+
*/
|
|
25
|
+
abstract readonly source: string;
|
|
14
26
|
/**
|
|
15
27
|
* Executes the event handling logic for a given Arvo event.
|
|
16
28
|
*
|
|
17
29
|
* @abstract
|
|
18
30
|
* @param {ArvoEvent} event - The Arvo event to be processed. This event should conform
|
|
19
31
|
* to the expected schema for the specific handler implementation.
|
|
20
|
-
* @param {
|
|
32
|
+
* @param {OpenTelemetryConfig} opentelemetry - Configuration for OpenTelemetry
|
|
21
33
|
* integration, including tracing options
|
|
22
34
|
* and context inheritance settings.
|
|
23
35
|
* @returns {Promise<ArvoEvent[]>} A promise that resolves to an array of resulting Arvo events.
|
|
@@ -52,7 +64,7 @@ export default abstract class AbstractArvoEventHandler {
|
|
|
52
64
|
* - Properly handling span lifecycle (creation and completion)
|
|
53
65
|
* - Propagating context appropriately
|
|
54
66
|
*/
|
|
55
|
-
abstract execute(event: ArvoEvent, opentelemetry
|
|
67
|
+
abstract execute(event: ArvoEvent, opentelemetry?: OpenTelemetryConfig): Promise<ArvoEvent[]>;
|
|
56
68
|
/**
|
|
57
69
|
* Provides the schema for system error events.
|
|
58
70
|
*
|
|
@@ -2,7 +2,7 @@ import { ArvoContract, ArvoEvent, ArvoExecutionSpanKind, OpenInferenceSpanKind,
|
|
|
2
2
|
import { IArvoEventHandler } from './types';
|
|
3
3
|
import { SpanKind } from '@opentelemetry/api';
|
|
4
4
|
import AbstractArvoEventHandler from '../AbstractArvoEventHandler';
|
|
5
|
-
import {
|
|
5
|
+
import { OpenTelemetryConfig } from '../OpenTelemetry/types';
|
|
6
6
|
/**
|
|
7
7
|
* Represents an event handler for Arvo contracts.
|
|
8
8
|
*
|
|
@@ -91,7 +91,7 @@ export default class ArvoEventHandler<TContract extends ArvoContract> extends Ab
|
|
|
91
91
|
* - Propagates trace context to output events
|
|
92
92
|
* - Handles error cases and sets appropriate span status
|
|
93
93
|
*/
|
|
94
|
-
execute(event: ArvoEvent<ResolveArvoContractRecord<TContract['accepts']>, Record<string, any>, TContract['accepts']['type']>, opentelemetry?:
|
|
94
|
+
execute(event: ArvoEvent<ResolveArvoContractRecord<TContract['accepts']>, Record<string, any>, TContract['accepts']['type']>, opentelemetry?: OpenTelemetryConfig): Promise<ArvoEvent[]>;
|
|
95
95
|
/**
|
|
96
96
|
* Provides the schema for system error events.
|
|
97
97
|
*
|
|
@@ -60,7 +60,7 @@ var api_1 = require("@opentelemetry/api");
|
|
|
60
60
|
var utils_1 = require("../utils");
|
|
61
61
|
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
62
62
|
var OpenTelemetry_1 = require("../OpenTelemetry");
|
|
63
|
-
var utils_2 = require("../
|
|
63
|
+
var utils_2 = require("../OpenTelemetry/utils");
|
|
64
64
|
/**
|
|
65
65
|
* Represents an event handler for Arvo contracts.
|
|
66
66
|
*
|
|
@@ -166,7 +166,7 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
166
166
|
return __generator(this, function (_a) {
|
|
167
167
|
switch (_a.label) {
|
|
168
168
|
case 0:
|
|
169
|
-
span = (0, utils_2.
|
|
169
|
+
span = (0, utils_2.createOtelSpan)({
|
|
170
170
|
spanName: "ArvoEventHandler<".concat(this.contract.uri, ">.execute<").concat(event.type, ">"),
|
|
171
171
|
spanKinds: {
|
|
172
172
|
kind: this.openTelemetrySpanKind,
|
|
@@ -3,7 +3,7 @@ import ArvoEventHandler from '../ArvoEventHandler';
|
|
|
3
3
|
import { IArvoEventRouter } from './types';
|
|
4
4
|
import { SpanKind } from '@opentelemetry/api';
|
|
5
5
|
import AbstractArvoEventHandler from '../AbstractArvoEventHandler';
|
|
6
|
-
import {
|
|
6
|
+
import { OpenTelemetryConfig } from '../OpenTelemetry/types';
|
|
7
7
|
/**
|
|
8
8
|
* ArvoEventRouter class handles routing of ArvoEvents to appropriate event handlers.
|
|
9
9
|
*/
|
|
@@ -92,7 +92,7 @@ export declare class ArvoEventRouter extends AbstractArvoEventHandler {
|
|
|
92
92
|
* - Execution units are tracked for both successful executions and errors.
|
|
93
93
|
* - The router's default execution units are used for error events.
|
|
94
94
|
*/
|
|
95
|
-
execute(event: ArvoEvent, opentelemetry?:
|
|
95
|
+
execute(event: ArvoEvent, opentelemetry?: OpenTelemetryConfig): Promise<ArvoEvent[]>;
|
|
96
96
|
/**
|
|
97
97
|
* Provides the schema for system error events.
|
|
98
98
|
*
|
|
@@ -61,7 +61,7 @@ var api_1 = require("@opentelemetry/api");
|
|
|
61
61
|
var utils_2 = require("./utils");
|
|
62
62
|
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
63
63
|
var OpenTelemetry_1 = require("../OpenTelemetry");
|
|
64
|
-
var utils_3 = require("../
|
|
64
|
+
var utils_3 = require("../OpenTelemetry/utils");
|
|
65
65
|
/**
|
|
66
66
|
* ArvoEventRouter class handles routing of ArvoEvents to appropriate event handlers.
|
|
67
67
|
*/
|
|
@@ -174,7 +174,7 @@ var ArvoEventRouter = /** @class */ (function (_super) {
|
|
|
174
174
|
return __generator(this, function (_b) {
|
|
175
175
|
switch (_b.label) {
|
|
176
176
|
case 0:
|
|
177
|
-
span = (0, utils_3.
|
|
177
|
+
span = (0, utils_3.createOtelSpan)({
|
|
178
178
|
spanName: "ArvoEventRouter.source<".concat((_a = this._source) !== null && _a !== void 0 ? _a : 'arvo.event.router', ">.execute<").concat(event.type, ">"),
|
|
179
179
|
spanKinds: {
|
|
180
180
|
kind: this.openTelemetrySpanKind,
|
|
@@ -2,7 +2,7 @@ import { SpanKind } from '@opentelemetry/api';
|
|
|
2
2
|
import { ArvoEvent, ArvoExecutionSpanKind, OpenInferenceSpanKind } from 'arvo-core';
|
|
3
3
|
import { IMultiArvoEventHandler } from './types';
|
|
4
4
|
import AbstractArvoEventHandler from '../AbstractArvoEventHandler';
|
|
5
|
-
import {
|
|
5
|
+
import { OpenTelemetryConfig } from '../OpenTelemetry/types';
|
|
6
6
|
/**
|
|
7
7
|
* Represents a Multi ArvoEvent handler that can process multiple event types.
|
|
8
8
|
*
|
|
@@ -93,7 +93,7 @@ export default class MultiArvoEventHandler extends AbstractArvoEventHandler {
|
|
|
93
93
|
* - If they don't match, an error is thrown with a descriptive message.
|
|
94
94
|
* - This ensures that the handler only processes events intended for it.
|
|
95
95
|
*/
|
|
96
|
-
execute(event: ArvoEvent, opentelemetry?:
|
|
96
|
+
execute(event: ArvoEvent, opentelemetry?: OpenTelemetryConfig): Promise<ArvoEvent[]>;
|
|
97
97
|
/**
|
|
98
98
|
* Provides the schema for system error events.
|
|
99
99
|
*
|
|
@@ -59,7 +59,7 @@ var arvo_core_1 = require("arvo-core");
|
|
|
59
59
|
var utils_1 = require("../utils");
|
|
60
60
|
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
61
61
|
var OpenTelemetry_1 = require("../OpenTelemetry");
|
|
62
|
-
var utils_2 = require("../
|
|
62
|
+
var utils_2 = require("../OpenTelemetry/utils");
|
|
63
63
|
/**
|
|
64
64
|
* Represents a Multi ArvoEvent handler that can process multiple event types.
|
|
65
65
|
*
|
|
@@ -159,7 +159,7 @@ var MultiArvoEventHandler = /** @class */ (function (_super) {
|
|
|
159
159
|
return __generator(this, function (_a) {
|
|
160
160
|
switch (_a.label) {
|
|
161
161
|
case 0:
|
|
162
|
-
span = (0, utils_2.
|
|
162
|
+
span = (0, utils_2.createOtelSpan)({
|
|
163
163
|
spanName: "MutliArvoEventHandler.source<".concat(this.source, ">.execute<").concat(event.type, ">"),
|
|
164
164
|
spanKinds: {
|
|
165
165
|
kind: this.openTelemetrySpanKind,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Context } from '@opentelemetry/api';
|
|
2
1
|
/**
|
|
3
2
|
* Returns a tracer instance for the ArvoEventHandler package.
|
|
4
3
|
*/
|
|
5
4
|
export declare const fetchOpenTelemetryTracer: () => import("@opentelemetry/api").Tracer;
|
|
6
|
-
export declare const extractContext: (traceparent: string, tracestate: string | null) => Context;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchOpenTelemetryTracer = void 0;
|
|
4
4
|
var api_1 = require("@opentelemetry/api");
|
|
5
5
|
var utils_1 = require("./utils");
|
|
6
6
|
/**
|
|
@@ -11,12 +11,3 @@ var fetchOpenTelemetryTracer = function () {
|
|
|
11
11
|
return api_1.trace.getTracer(pkg.name, pkg.version);
|
|
12
12
|
};
|
|
13
13
|
exports.fetchOpenTelemetryTracer = fetchOpenTelemetryTracer;
|
|
14
|
-
// Helper function to extract context from traceparent and tracestate
|
|
15
|
-
var extractContext = function (traceparent, tracestate) {
|
|
16
|
-
var extractedContext = api_1.propagation.extract(api_1.context.active(), {
|
|
17
|
-
traceparent: traceparent,
|
|
18
|
-
tracestate: tracestate !== null && tracestate !== void 0 ? tracestate : undefined,
|
|
19
|
-
});
|
|
20
|
-
return extractedContext;
|
|
21
|
-
};
|
|
22
|
-
exports.extractContext = extractContext;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SpanKind, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { ArvoEvent, ArvoExecutionSpanKind, OpenInferenceSpanKind } from 'arvo-core';
|
|
3
|
+
export type PackageJson = {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for OpenTelemetry integration in execution context.
|
|
10
|
+
*
|
|
11
|
+
* This type defines how tracing should be configured and inherited within
|
|
12
|
+
* the execution pipeline.
|
|
13
|
+
*/
|
|
14
|
+
export type OpenTelemetryConfig = {
|
|
15
|
+
/**
|
|
16
|
+
* Specifies the context from which to inherit OpenTelemetry context.
|
|
17
|
+
* - 'event': Inherits context from the event that triggered the execution
|
|
18
|
+
* - 'execution': Inherits context from the parent execution context
|
|
19
|
+
*/
|
|
20
|
+
inheritFrom: 'event' | 'execution';
|
|
21
|
+
/**
|
|
22
|
+
* Optional OpenTelemetry tracer instance to use for creating spans.
|
|
23
|
+
* If not provided, a default tracer may be used depending on the implementation.
|
|
24
|
+
*/
|
|
25
|
+
tracer: Tracer | null;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Interface defining the required parameters for creating a handler execution span.
|
|
29
|
+
*
|
|
30
|
+
* @interface ICreateHandlerExecutionSpan
|
|
31
|
+
* @property {string} spanName - The name to be assigned to the created span
|
|
32
|
+
* @property {Object} spanKinds - Object containing different span kind classifications
|
|
33
|
+
* @property {SpanKind} spanKinds.kind - OpenTelemetry span kind
|
|
34
|
+
* @property {OpenInferenceSpanKind} spanKinds.openInference - OpenInference-specific span classification
|
|
35
|
+
* @property {ArvoExecutionSpanKind} spanKinds.arvoExecution - Arvo execution-specific span classification
|
|
36
|
+
* @property {ArvoEvent} event - The Arvo event associated with this span
|
|
37
|
+
* @property {EventHandlerExecutionOtelConfiguration} opentelemetryConfig - Configuration for OpenTelemetry behavior
|
|
38
|
+
*/
|
|
39
|
+
export interface ICreateOtelSpan {
|
|
40
|
+
spanName: string;
|
|
41
|
+
spanKinds: {
|
|
42
|
+
kind: SpanKind;
|
|
43
|
+
openInference: OpenInferenceSpanKind;
|
|
44
|
+
arvoExecution: ArvoExecutionSpanKind;
|
|
45
|
+
};
|
|
46
|
+
event: ArvoEvent;
|
|
47
|
+
opentelemetryConfig?: OpenTelemetryConfig;
|
|
48
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Span, SpanKind, Tracer } from '@opentelemetry/api';
|
|
1
|
+
import { Span, SpanKind, Tracer, Context } from '@opentelemetry/api';
|
|
2
2
|
import { ArvoEvent, ArvoExecutionSpanKind, OpenInferenceSpanKind } from 'arvo-core';
|
|
3
|
+
import { ICreateOtelSpan } from './types';
|
|
3
4
|
export declare function getPackageInfo(defaultName: string): {
|
|
4
5
|
name: string;
|
|
5
6
|
version: string;
|
|
6
7
|
};
|
|
8
|
+
export declare const extractContext: (traceparent: string, tracestate: string | null) => Context;
|
|
7
9
|
/**
|
|
8
10
|
* Creates an OpenTelemetry span from an ArvoEvent, facilitating distributed tracing in the Arvo system.
|
|
9
11
|
*
|
|
@@ -70,4 +72,20 @@ export declare const createSpanFromEvent: (spanName: string, event: ArvoEvent, s
|
|
|
70
72
|
kind: SpanKind;
|
|
71
73
|
openInference: OpenInferenceSpanKind;
|
|
72
74
|
arvoExecution: ArvoExecutionSpanKind;
|
|
73
|
-
}, tracer
|
|
75
|
+
}, tracer: Tracer) => Span;
|
|
76
|
+
/**
|
|
77
|
+
* Creates an OpenTelemetry span for tracking handler execution.
|
|
78
|
+
*
|
|
79
|
+
* This function creates a span either from an existing event or as a new span,
|
|
80
|
+
* depending on the configuration. It includes attributes for both OpenInference
|
|
81
|
+
* and Arvo execution span kinds.
|
|
82
|
+
*
|
|
83
|
+
* @param params - Parameters for creating the handler execution span
|
|
84
|
+
* @param params.spanName - Name of the span to be created
|
|
85
|
+
* @param params.spanKinds - Object containing different span kind classifications
|
|
86
|
+
* @param params.event - The Arvo event associated with this span
|
|
87
|
+
* @param params.opentelemetryConfig - OpenTelemetry configuration
|
|
88
|
+
*
|
|
89
|
+
* @returns A new OpenTelemetry span configured according to the parameters
|
|
90
|
+
*/
|
|
91
|
+
export declare const createOtelSpan: ({ spanName, spanKinds, event, opentelemetryConfig, }: ICreateOtelSpan) => Span;
|
|
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createSpanFromEvent = void 0;
|
|
26
|
+
exports.createOtelSpan = exports.createSpanFromEvent = exports.extractContext = void 0;
|
|
27
27
|
exports.getPackageInfo = getPackageInfo;
|
|
28
|
+
var api_1 = require("@opentelemetry/api");
|
|
28
29
|
var arvo_core_1 = require("arvo-core");
|
|
29
30
|
var fs = __importStar(require("fs"));
|
|
30
31
|
var path = __importStar(require("path"));
|
|
@@ -45,6 +46,15 @@ function getPackageInfo(defaultName) {
|
|
|
45
46
|
return { name: defaultName, version: 'Unknown' };
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
// Helper function to extract context from traceparent and tracestate
|
|
50
|
+
var extractContext = function (traceparent, tracestate) {
|
|
51
|
+
var extractedContext = api_1.propagation.extract(api_1.context.active(), {
|
|
52
|
+
traceparent: traceparent,
|
|
53
|
+
tracestate: tracestate !== null && tracestate !== void 0 ? tracestate : undefined,
|
|
54
|
+
});
|
|
55
|
+
return extractedContext;
|
|
56
|
+
};
|
|
57
|
+
exports.extractContext = extractContext;
|
|
48
58
|
/**
|
|
49
59
|
* Creates an OpenTelemetry span from an ArvoEvent, facilitating distributed tracing in the Arvo system.
|
|
50
60
|
*
|
|
@@ -109,7 +119,6 @@ function getPackageInfo(defaultName) {
|
|
|
109
119
|
*/
|
|
110
120
|
var createSpanFromEvent = function (spanName, event, spanKinds, tracer) {
|
|
111
121
|
var _a;
|
|
112
|
-
if (tracer === void 0) { tracer = (0, _1.fetchOpenTelemetryTracer)(); }
|
|
113
122
|
var spanOptions = {
|
|
114
123
|
kind: spanKinds.kind,
|
|
115
124
|
attributes: (_a = {},
|
|
@@ -119,7 +128,7 @@ var createSpanFromEvent = function (spanName, event, spanKinds, tracer) {
|
|
|
119
128
|
};
|
|
120
129
|
var span;
|
|
121
130
|
if (event.traceparent) {
|
|
122
|
-
var inheritedContext = (0,
|
|
131
|
+
var inheritedContext = (0, exports.extractContext)(event.traceparent, event.tracestate);
|
|
123
132
|
span = tracer.startSpan(spanName, spanOptions, inheritedContext);
|
|
124
133
|
}
|
|
125
134
|
else {
|
|
@@ -128,3 +137,39 @@ var createSpanFromEvent = function (spanName, event, spanKinds, tracer) {
|
|
|
128
137
|
return span;
|
|
129
138
|
};
|
|
130
139
|
exports.createSpanFromEvent = createSpanFromEvent;
|
|
140
|
+
/**
|
|
141
|
+
* Creates an OpenTelemetry span for tracking handler execution.
|
|
142
|
+
*
|
|
143
|
+
* This function creates a span either from an existing event or as a new span,
|
|
144
|
+
* depending on the configuration. It includes attributes for both OpenInference
|
|
145
|
+
* and Arvo execution span kinds.
|
|
146
|
+
*
|
|
147
|
+
* @param params - Parameters for creating the handler execution span
|
|
148
|
+
* @param params.spanName - Name of the span to be created
|
|
149
|
+
* @param params.spanKinds - Object containing different span kind classifications
|
|
150
|
+
* @param params.event - The Arvo event associated with this span
|
|
151
|
+
* @param params.opentelemetryConfig - OpenTelemetry configuration
|
|
152
|
+
*
|
|
153
|
+
* @returns A new OpenTelemetry span configured according to the parameters
|
|
154
|
+
*/
|
|
155
|
+
var createOtelSpan = function (_a) {
|
|
156
|
+
var _b;
|
|
157
|
+
var _c;
|
|
158
|
+
var spanName = _a.spanName, spanKinds = _a.spanKinds, event = _a.event, opentelemetryConfig = _a.opentelemetryConfig;
|
|
159
|
+
opentelemetryConfig = opentelemetryConfig !== null && opentelemetryConfig !== void 0 ? opentelemetryConfig : {
|
|
160
|
+
inheritFrom: 'event',
|
|
161
|
+
tracer: null
|
|
162
|
+
};
|
|
163
|
+
var spanOptions = {
|
|
164
|
+
kind: spanKinds.kind,
|
|
165
|
+
attributes: (_b = {},
|
|
166
|
+
_b[arvo_core_1.OpenInference.ATTR_SPAN_KIND] = spanKinds.openInference,
|
|
167
|
+
_b[arvo_core_1.ArvoExecution.ATTR_SPAN_KIND] = spanKinds.arvoExecution,
|
|
168
|
+
_b),
|
|
169
|
+
};
|
|
170
|
+
var tracer = (_c = opentelemetryConfig.tracer) !== null && _c !== void 0 ? _c : (0, _1.fetchOpenTelemetryTracer)();
|
|
171
|
+
return opentelemetryConfig.inheritFrom === "event" ?
|
|
172
|
+
(0, exports.createSpanFromEvent)(spanName, event, spanKinds, tracer) :
|
|
173
|
+
tracer.startSpan(spanName, spanOptions);
|
|
174
|
+
};
|
|
175
|
+
exports.createOtelSpan = createOtelSpan;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ import { IArvoEventRouter } from './ArvoEventRouter/types';
|
|
|
10
10
|
import { ArvoEventRouter } from './ArvoEventRouter';
|
|
11
11
|
import { createArvoEventRouter } from './ArvoEventRouter/helpers';
|
|
12
12
|
import AbstractArvoEventHandler from './AbstractArvoEventHandler';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
export { ArvoEventHandler, createArvoEventHandler, IArvoEventHandler, ArvoEventHandlerFunctionOutput, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunction, PartialExcept, MultiArvoEventHandler, MultiArvoEventHandlerFunctionInput, MultiArvoEventHandlerFunctionOutput, MultiArvoEventHandlerFunction, IMultiArvoEventHandler, createMultiArvoEventHandler, isNullOrUndefined, getValueOrDefault, coalesce, coalesceOrDefault, IArvoEventRouter, ArvoEventRouter, createArvoEventRouter, AbstractArvoEventHandler,
|
|
13
|
+
import { createOtelSpan } from './OpenTelemetry/utils';
|
|
14
|
+
import { OpenTelemetryConfig } from './OpenTelemetry/types';
|
|
15
|
+
export { ArvoEventHandler, createArvoEventHandler, IArvoEventHandler, ArvoEventHandlerFunctionOutput, ArvoEventHandlerFunctionInput, ArvoEventHandlerFunction, PartialExcept, MultiArvoEventHandler, MultiArvoEventHandlerFunctionInput, MultiArvoEventHandlerFunctionOutput, MultiArvoEventHandlerFunction, IMultiArvoEventHandler, createMultiArvoEventHandler, isNullOrUndefined, getValueOrDefault, coalesce, coalesceOrDefault, IArvoEventRouter, ArvoEventRouter, createArvoEventRouter, AbstractArvoEventHandler, OpenTelemetryConfig as EventHandlerExecutionOtelConfiguration, createOtelSpan as createOtelSpan, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createOtelSpan = exports.AbstractArvoEventHandler = exports.createArvoEventRouter = exports.ArvoEventRouter = exports.coalesceOrDefault = exports.coalesce = exports.getValueOrDefault = exports.isNullOrUndefined = exports.createMultiArvoEventHandler = exports.MultiArvoEventHandler = exports.createArvoEventHandler = exports.ArvoEventHandler = void 0;
|
|
7
7
|
var ArvoEventHandler_1 = __importDefault(require("./ArvoEventHandler"));
|
|
8
8
|
exports.ArvoEventHandler = ArvoEventHandler_1.default;
|
|
9
9
|
var helpers_1 = require("./ArvoEventHandler/helpers");
|
|
@@ -24,4 +24,4 @@ Object.defineProperty(exports, "createArvoEventRouter", { enumerable: true, get:
|
|
|
24
24
|
var AbstractArvoEventHandler_1 = __importDefault(require("./AbstractArvoEventHandler"));
|
|
25
25
|
exports.AbstractArvoEventHandler = AbstractArvoEventHandler_1.default;
|
|
26
26
|
var utils_2 = require("./OpenTelemetry/utils");
|
|
27
|
-
Object.defineProperty(exports, "
|
|
27
|
+
Object.defineProperty(exports, "createOtelSpan", { enumerable: true, get: function () { return utils_2.createOtelSpan; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arvo-event-handler",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "This package contains class and function for event handlers in an Arvo Event Driven system",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@opentelemetry/api": "^1.9.0",
|
|
52
52
|
"@opentelemetry/core": "^1.27.0",
|
|
53
|
-
"arvo-core": "^1.1.
|
|
53
|
+
"arvo-core": "^1.1.21",
|
|
54
54
|
"uuid": "^10.0.0",
|
|
55
55
|
"zod": "^3.23.8"
|
|
56
56
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Tracer } from '@opentelemetry/api';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration options for OpenTelemetry integration in execution context.
|
|
4
|
-
*
|
|
5
|
-
* This type defines how tracing should be configured and inherited within
|
|
6
|
-
* the execution pipeline.
|
|
7
|
-
*/
|
|
8
|
-
export type ExecutionOpenTelemetryConfiguration = {
|
|
9
|
-
/**
|
|
10
|
-
* Specifies the context from which to inherit OpenTelemetry context.
|
|
11
|
-
* - 'event': Inherits context from the event that triggered the execution
|
|
12
|
-
* - 'execution': Inherits context from the parent execution context
|
|
13
|
-
*/
|
|
14
|
-
inheritFrom: 'event' | 'execution';
|
|
15
|
-
/**
|
|
16
|
-
* Optional OpenTelemetry tracer instance to use for creating spans.
|
|
17
|
-
* If not provided, a default tracer may be used depending on the implementation.
|
|
18
|
-
*/
|
|
19
|
-
tracer: Tracer | null;
|
|
20
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { SpanKind } from "@opentelemetry/api";
|
|
2
|
-
import { ArvoEvent, ArvoExecutionSpanKind, OpenInferenceSpanKind } from "arvo-core";
|
|
3
|
-
import { ExecutionOpenTelemetryConfiguration } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* Interface defining the required parameters for creating a handler execution span.
|
|
6
|
-
*
|
|
7
|
-
* @interface ICreateHandlerExecutionSpan
|
|
8
|
-
* @property {string} spanName - The name to be assigned to the created span
|
|
9
|
-
* @property {Object} spanKinds - Object containing different span kind classifications
|
|
10
|
-
* @property {SpanKind} spanKinds.kind - OpenTelemetry span kind
|
|
11
|
-
* @property {OpenInferenceSpanKind} spanKinds.openInference - OpenInference-specific span classification
|
|
12
|
-
* @property {ArvoExecutionSpanKind} spanKinds.arvoExecution - Arvo execution-specific span classification
|
|
13
|
-
* @property {ArvoEvent} event - The Arvo event associated with this span
|
|
14
|
-
* @property {ExecutionOpenTelemetryConfiguration} opentelemetryConfig - Configuration for OpenTelemetry behavior
|
|
15
|
-
*/
|
|
16
|
-
interface ICreateHandlerExecutionSpan {
|
|
17
|
-
spanName: string;
|
|
18
|
-
spanKinds: {
|
|
19
|
-
kind: SpanKind;
|
|
20
|
-
openInference: OpenInferenceSpanKind;
|
|
21
|
-
arvoExecution: ArvoExecutionSpanKind;
|
|
22
|
-
};
|
|
23
|
-
event: ArvoEvent;
|
|
24
|
-
opentelemetryConfig?: ExecutionOpenTelemetryConfiguration;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Creates an OpenTelemetry span for tracking handler execution.
|
|
28
|
-
*
|
|
29
|
-
* This function creates a span either from an existing event or as a new span,
|
|
30
|
-
* depending on the configuration. It includes attributes for both OpenInference
|
|
31
|
-
* and Arvo execution span kinds.
|
|
32
|
-
*
|
|
33
|
-
* @param params - Parameters for creating the handler execution span
|
|
34
|
-
* @param params.spanName - Name of the span to be created
|
|
35
|
-
* @param params.spanKinds - Object containing different span kind classifications
|
|
36
|
-
* @param params.event - The Arvo event associated with this span
|
|
37
|
-
* @param params.opentelemetryConfig - OpenTelemetry configuration
|
|
38
|
-
*
|
|
39
|
-
* @returns A new OpenTelemetry span configured according to the parameters
|
|
40
|
-
*/
|
|
41
|
-
export declare const createHandlerExecutionSpan: ({ spanName, spanKinds, event, opentelemetryConfig, }: ICreateHandlerExecutionSpan) => import("@opentelemetry/api").Span;
|
|
42
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createHandlerExecutionSpan = void 0;
|
|
4
|
-
var utils_1 = require("../OpenTelemetry/utils");
|
|
5
|
-
var arvo_core_1 = require("arvo-core");
|
|
6
|
-
var OpenTelemetry_1 = require("../OpenTelemetry");
|
|
7
|
-
/**
|
|
8
|
-
* Creates an OpenTelemetry span for tracking handler execution.
|
|
9
|
-
*
|
|
10
|
-
* This function creates a span either from an existing event or as a new span,
|
|
11
|
-
* depending on the configuration. It includes attributes for both OpenInference
|
|
12
|
-
* and Arvo execution span kinds.
|
|
13
|
-
*
|
|
14
|
-
* @param params - Parameters for creating the handler execution span
|
|
15
|
-
* @param params.spanName - Name of the span to be created
|
|
16
|
-
* @param params.spanKinds - Object containing different span kind classifications
|
|
17
|
-
* @param params.event - The Arvo event associated with this span
|
|
18
|
-
* @param params.opentelemetryConfig - OpenTelemetry configuration
|
|
19
|
-
*
|
|
20
|
-
* @returns A new OpenTelemetry span configured according to the parameters
|
|
21
|
-
*/
|
|
22
|
-
var createHandlerExecutionSpan = function (_a) {
|
|
23
|
-
var _b;
|
|
24
|
-
var _c;
|
|
25
|
-
var spanName = _a.spanName, spanKinds = _a.spanKinds, event = _a.event, _d = _a.opentelemetryConfig, opentelemetryConfig = _d === void 0 ? {
|
|
26
|
-
inheritFrom: 'event',
|
|
27
|
-
tracer: null
|
|
28
|
-
} : _d;
|
|
29
|
-
var spanOptions = {
|
|
30
|
-
kind: spanKinds.kind,
|
|
31
|
-
attributes: (_b = {},
|
|
32
|
-
_b[arvo_core_1.OpenInference.ATTR_SPAN_KIND] = spanKinds.openInference,
|
|
33
|
-
_b[arvo_core_1.ArvoExecution.ATTR_SPAN_KIND] = spanKinds.arvoExecution,
|
|
34
|
-
_b),
|
|
35
|
-
};
|
|
36
|
-
var tracer = (_c = opentelemetryConfig.tracer) !== null && _c !== void 0 ? _c : (0, OpenTelemetry_1.fetchOpenTelemetryTracer)();
|
|
37
|
-
return opentelemetryConfig.inheritFrom === "event" ?
|
|
38
|
-
(0, utils_1.createSpanFromEvent)(spanName, event, spanKinds, tracer) :
|
|
39
|
-
tracer.startSpan(spanName, spanOptions);
|
|
40
|
-
};
|
|
41
|
-
exports.createHandlerExecutionSpan = createHandlerExecutionSpan;
|
|
File without changes
|