arvo-event-handler 1.1.9 → 1.1.11
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.
|
@@ -4,20 +4,10 @@ import { Tracer } from '@opentelemetry/api';
|
|
|
4
4
|
*
|
|
5
5
|
* This type defines how tracing should be configured and inherited within
|
|
6
6
|
* the execution pipeline.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const config: ExecutionOpenTelemetryConfiguration = {
|
|
11
|
-
* inheritFrom: 'event',
|
|
12
|
-
* tracer: new OpenTelemetry.Tracer('service-name')
|
|
13
|
-
* };
|
|
14
|
-
* ```
|
|
15
7
|
*/
|
|
16
8
|
export type ExecutionOpenTelemetryConfiguration = {
|
|
17
9
|
/**
|
|
18
10
|
* Specifies the context from which to inherit OpenTelemetry context.
|
|
19
|
-
*
|
|
20
|
-
* @property {('event' | 'execution')} inheritFrom
|
|
21
11
|
* - 'event': Inherits context from the event that triggered the execution
|
|
22
12
|
* - 'execution': Inherits context from the parent execution context
|
|
23
13
|
*/
|
|
@@ -25,9 +15,6 @@ export type ExecutionOpenTelemetryConfiguration = {
|
|
|
25
15
|
/**
|
|
26
16
|
* Optional OpenTelemetry tracer instance to use for creating spans.
|
|
27
17
|
* If not provided, a default tracer may be used depending on the implementation.
|
|
28
|
-
*
|
|
29
|
-
* @property {Tracer} [tracer]
|
|
30
|
-
* @see {@link https://open-telemetry.github.io/opentelemetry-js/classes/_opentelemetry_api.Tracer.html OpenTelemetry Tracer}
|
|
31
18
|
*/
|
|
32
19
|
tracer?: Tracer;
|
|
33
20
|
};
|
|
@@ -191,14 +191,14 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
191
191
|
eventFactory = (0, arvo_core_1.createArvoEventFactory)(this.contract);
|
|
192
192
|
return [4 /*yield*/, api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () { return __awaiter(_this, void 0, void 0, function () {
|
|
193
193
|
var otelSpanHeaders, inputEventValidation, _handleOutput, outputs, error_1, result;
|
|
194
|
-
var _a, _b, _c;
|
|
195
|
-
return __generator(this, function (
|
|
196
|
-
switch (
|
|
194
|
+
var _a, _b, _c, _d;
|
|
195
|
+
return __generator(this, function (_e) {
|
|
196
|
+
switch (_e.label) {
|
|
197
197
|
case 0:
|
|
198
198
|
otelSpanHeaders = (0, arvo_core_1.currentOpenTelemetryHeaders)();
|
|
199
|
-
|
|
199
|
+
_e.label = 1;
|
|
200
200
|
case 1:
|
|
201
|
-
|
|
201
|
+
_e.trys.push([1, 3, 4, 5]);
|
|
202
202
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
203
203
|
Object.entries(event.otelAttributes).forEach(function (_a) {
|
|
204
204
|
var key = _a[0], value = _a[1];
|
|
@@ -213,7 +213,7 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
213
213
|
source: this.source,
|
|
214
214
|
})];
|
|
215
215
|
case 2:
|
|
216
|
-
_handleOutput =
|
|
216
|
+
_handleOutput = _e.sent();
|
|
217
217
|
if (!_handleOutput)
|
|
218
218
|
return [2 /*return*/, []];
|
|
219
219
|
outputs = [];
|
|
@@ -223,15 +223,14 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
223
223
|
else {
|
|
224
224
|
outputs = [_handleOutput];
|
|
225
225
|
}
|
|
226
|
-
return [2 /*return*/, (0, utils_1.eventHandlerOutputEventCreator)(outputs, otelSpanHeaders, this.source, event, this.executionunits, function () {
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
return eventFactory.emits.apply(eventFactory, args);
|
|
226
|
+
return [2 /*return*/, (0, utils_1.eventHandlerOutputEventCreator)(outputs, otelSpanHeaders, this.source, event, this.executionunits, function (param, extension) {
|
|
227
|
+
var _a;
|
|
228
|
+
return eventFactory.emits(param, extension, {
|
|
229
|
+
tracer: (_a = opentelemetry.tracer) !== null && _a !== void 0 ? _a : OpenTelemetry_1.ArvoEventHandlerTracer,
|
|
230
|
+
});
|
|
232
231
|
})];
|
|
233
232
|
case 3:
|
|
234
|
-
error_1 =
|
|
233
|
+
error_1 = _e.sent();
|
|
235
234
|
(0, arvo_core_1.exceptionToSpan)(error_1);
|
|
236
235
|
span.setStatus({
|
|
237
236
|
code: api_1.SpanStatusCode.ERROR,
|
|
@@ -248,7 +247,7 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
248
247
|
traceparent: (_a = otelSpanHeaders.traceparent) !== null && _a !== void 0 ? _a : undefined,
|
|
249
248
|
tracestate: (_b = otelSpanHeaders.tracestate) !== null && _b !== void 0 ? _b : undefined,
|
|
250
249
|
accesscontrol: (_c = event.accesscontrol) !== null && _c !== void 0 ? _c : undefined,
|
|
251
|
-
}, {});
|
|
250
|
+
}, {}, { tracer: (_d = opentelemetry.tracer) !== null && _d !== void 0 ? _d : OpenTelemetry_1.ArvoEventHandlerTracer });
|
|
252
251
|
Object.entries(result.otelAttributes).forEach(function (_a) {
|
|
253
252
|
var key = _a[0], value = _a[1];
|
|
254
253
|
return span.setAttribute("to_emit.0.".concat(key), value);
|
|
@@ -238,12 +238,11 @@ var ArvoEventRouter = /** @class */ (function (_super) {
|
|
|
238
238
|
})];
|
|
239
239
|
case 3:
|
|
240
240
|
error_1 = _a.sent();
|
|
241
|
-
return [2 /*return*/, (0, utils_1.createHandlerErrorOutputEvent)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function () {
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
return arvo_core_1.createArvoEvent.apply(void 0, args);
|
|
241
|
+
return [2 /*return*/, (0, utils_1.createHandlerErrorOutputEvent)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function (param, extension) {
|
|
242
|
+
var _a;
|
|
243
|
+
return (0, arvo_core_1.createArvoEvent)(param, extension, {
|
|
244
|
+
tracer: (_a = opentelemetry.tracer) !== null && _a !== void 0 ? _a : OpenTelemetry_1.ArvoEventHandlerTracer,
|
|
245
|
+
});
|
|
247
246
|
})];
|
|
248
247
|
case 4:
|
|
249
248
|
span.end();
|
|
@@ -213,21 +213,19 @@ var MultiArvoEventHandler = /** @class */ (function (_super) {
|
|
|
213
213
|
else {
|
|
214
214
|
outputs = [_handlerOutput];
|
|
215
215
|
}
|
|
216
|
-
return [2 /*return*/, (0, utils_1.eventHandlerOutputEventCreator)(outputs, otelSpanHeaders, this.source, event, this.executionunits, function () {
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
return arvo_core_1.createArvoEvent.apply(void 0, args);
|
|
216
|
+
return [2 /*return*/, (0, utils_1.eventHandlerOutputEventCreator)(outputs, otelSpanHeaders, this.source, event, this.executionunits, function (param, extension) {
|
|
217
|
+
var _a;
|
|
218
|
+
return (0, arvo_core_1.createArvoEvent)(param, extension, {
|
|
219
|
+
tracer: (_a = opentelemetry.tracer) !== null && _a !== void 0 ? _a : OpenTelemetry_1.ArvoEventHandlerTracer,
|
|
220
|
+
});
|
|
222
221
|
})];
|
|
223
222
|
case 3:
|
|
224
223
|
error_1 = _a.sent();
|
|
225
|
-
return [2 /*return*/, (0, utils_1.createHandlerErrorOutputEvent)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function () {
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
return arvo_core_1.createArvoEvent.apply(void 0, args);
|
|
224
|
+
return [2 /*return*/, (0, utils_1.createHandlerErrorOutputEvent)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function (param, extension) {
|
|
225
|
+
var _a;
|
|
226
|
+
return (0, arvo_core_1.createArvoEvent)(param, extension, {
|
|
227
|
+
tracer: (_a = opentelemetry.tracer) !== null && _a !== void 0 ? _a : OpenTelemetry_1.ArvoEventHandlerTracer,
|
|
228
|
+
});
|
|
231
229
|
})];
|
|
232
230
|
case 4:
|
|
233
231
|
span.end();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arvo-event-handler",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
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": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@opentelemetry/api": "^1.9.0",
|
|
52
|
-
"arvo-core": "^1.1.
|
|
52
|
+
"arvo-core": "^1.1.17",
|
|
53
53
|
"uuid": "^10.0.0",
|
|
54
54
|
"zod": "^3.23.8"
|
|
55
55
|
}
|