arvo-event-handler 2.1.0 → 2.1.2
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/CHANGELOG.md +4 -0
- package/dist/ArvoEventHandler/index.js +109 -120
- package/dist/MultiArvoEventHandler/index.js +57 -70
- package/dist/utils.d.ts +18 -0
- package/dist/utils.js +18 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -27,3 +27,7 @@
|
|
|
27
27
|
## [2.0.0] - 2024-11-26
|
|
28
28
|
|
|
29
29
|
- Added support for versioned contracts in event handler for better versioning support
|
|
30
|
+
## [2.1.1] - 2024-12-10
|
|
31
|
+
|
|
32
|
+
- Updated the telemetry implementation to be more streamlined, fixed some minor bugs and added better telemetry logging
|
|
33
|
+
|
|
@@ -104,7 +104,7 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
104
104
|
throw new Error("Contract ".concat(_this.contract.uri, " requires handler implementation for version ").concat(contractVersions));
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
_this.spanOptions = __assign(__assign({ kind: api_1.SpanKind.CONSUMER }, param.spanOptions), { attributes: __assign(__assign((_a = {}, _a[arvo_core_1.ArvoExecution.ATTR_SPAN_KIND] = arvo_core_1.ArvoExecutionSpanKind.EVENT_HANDLER, _a[arvo_core_1.OpenInference.ATTR_SPAN_KIND] = arvo_core_1.OpenInferenceSpanKind.CHAIN, _a), ((_c = (_b = param.spanOptions) === null || _b === void 0 ? void 0 : _b.attributes) !== null && _c !== void 0 ? _c : {})), { 'arvo.
|
|
107
|
+
_this.spanOptions = __assign(__assign({ kind: api_1.SpanKind.CONSUMER }, param.spanOptions), { attributes: __assign(__assign((_a = {}, _a[arvo_core_1.ArvoExecution.ATTR_SPAN_KIND] = arvo_core_1.ArvoExecutionSpanKind.EVENT_HANDLER, _a[arvo_core_1.OpenInference.ATTR_SPAN_KIND] = arvo_core_1.OpenInferenceSpanKind.CHAIN, _a), ((_c = (_b = param.spanOptions) === null || _b === void 0 ? void 0 : _b.attributes) !== null && _c !== void 0 ? _c : {})), { 'arvo.handler.source': _this.source, 'arvo.contract.uri': _this.contract.uri }) });
|
|
108
108
|
return _this;
|
|
109
109
|
}
|
|
110
110
|
Object.defineProperty(ArvoEventHandler.prototype, "source", {
|
|
@@ -144,134 +144,123 @@ var ArvoEventHandler = /** @class */ (function (_super) {
|
|
|
144
144
|
*/
|
|
145
145
|
ArvoEventHandler.prototype.execute = function (event_1) {
|
|
146
146
|
return __awaiter(this, arguments, void 0, function (event, opentelemetry) {
|
|
147
|
+
var otelConfig;
|
|
147
148
|
var _this = this;
|
|
148
149
|
if (opentelemetry === void 0) { opentelemetry = {
|
|
149
150
|
inheritFrom: 'EVENT',
|
|
150
151
|
}; }
|
|
151
152
|
return __generator(this, function (_a) {
|
|
152
153
|
switch (_a.label) {
|
|
153
|
-
case 0:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
154
|
+
case 0:
|
|
155
|
+
otelConfig = (0, utils_1.createEventHandlerTelemetryConfig)('ArvoEventHandler', this.spanOptions, opentelemetry, event);
|
|
156
|
+
return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan(__assign(__assign({}, otelConfig), { fn: function (span) { return __awaiter(_this, void 0, void 0, function () {
|
|
157
|
+
var otelSpanHeaders, parsedDataSchema, handlerContract, inputEventValidation, _handleOutput, outputs, eventFactory_1, result, error_1, eventFactory, result;
|
|
158
|
+
var _a, _b, _c, _d;
|
|
159
|
+
return __generator(this, function (_e) {
|
|
160
|
+
switch (_e.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
otelSpanHeaders = (0, arvo_core_1.currentOpenTelemetryHeaders)();
|
|
163
|
+
_e.label = 1;
|
|
164
|
+
case 1:
|
|
165
|
+
_e.trys.push([1, 3, 4, 5]);
|
|
166
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
167
|
+
Object.entries(event.otelAttributes).forEach(function (_a) {
|
|
168
|
+
var key = _a[0], value = _a[1];
|
|
169
|
+
return span.setAttribute("to_process.0.".concat(key), value);
|
|
170
|
+
});
|
|
171
|
+
if (this.contract.type !== event.type) {
|
|
172
|
+
throw new Error("Event type mismatch: Received '".concat(event.type, "', expected '").concat(this.contract.type, "'"));
|
|
173
|
+
}
|
|
174
|
+
(0, arvo_core_1.logToSpan)({
|
|
175
|
+
level: 'INFO',
|
|
176
|
+
message: "Event type '".concat(event.type, "' validated against contract '").concat(this.contract.uri, "'"),
|
|
177
|
+
});
|
|
178
|
+
parsedDataSchema = arvo_core_1.EventDataschemaUtil.parse(event);
|
|
179
|
+
if ((parsedDataSchema === null || parsedDataSchema === void 0 ? void 0 : parsedDataSchema.uri) && (parsedDataSchema === null || parsedDataSchema === void 0 ? void 0 : parsedDataSchema.uri) !== this.contract.uri) {
|
|
180
|
+
throw new Error("Contract URI mismatch: Handler expects '".concat(this.contract.uri, "' but event dataschema specifies '").concat(event.dataschema, "'. Events must reference the same contract URI as their handler."));
|
|
181
|
+
}
|
|
182
|
+
if (!(parsedDataSchema === null || parsedDataSchema === void 0 ? void 0 : parsedDataSchema.version)) {
|
|
183
|
+
(0, arvo_core_1.logToSpan)({
|
|
184
|
+
level: 'WARNING',
|
|
185
|
+
message: "Version resolution failed for event with dataschema '".concat(event.dataschema, "'. Defaulting to latest version (=").concat(this.contract.version('latest').version, ") of contract (uri=").concat(this.contract.uri, ")"),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
handlerContract = this.contract.version((_a = parsedDataSchema === null || parsedDataSchema === void 0 ? void 0 : parsedDataSchema.version) !== null && _a !== void 0 ? _a : 'latest');
|
|
189
|
+
(0, arvo_core_1.logToSpan)({
|
|
190
|
+
level: 'INFO',
|
|
191
|
+
message: "Processing event with contract version ".concat(handlerContract.version),
|
|
192
|
+
});
|
|
193
|
+
inputEventValidation = handlerContract.accepts.schema.safeParse(event.data);
|
|
194
|
+
if (inputEventValidation.error) {
|
|
195
|
+
throw new Error("Event payload validation failed: ".concat(inputEventValidation.error));
|
|
196
|
+
}
|
|
197
|
+
(0, arvo_core_1.logToSpan)({
|
|
198
|
+
level: 'INFO',
|
|
199
|
+
message: "Event payload validated successfully against contract ".concat(arvo_core_1.EventDataschemaUtil.create(handlerContract)),
|
|
200
|
+
});
|
|
193
201
|
(0, arvo_core_1.logToSpan)({
|
|
194
|
-
level: '
|
|
195
|
-
message: "
|
|
202
|
+
level: 'INFO',
|
|
203
|
+
message: "Executing handler for event type '".concat(event.type, "'"),
|
|
196
204
|
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
205
|
+
return [4 /*yield*/, this.handler[handlerContract.version]({
|
|
206
|
+
event: event,
|
|
207
|
+
source: this.source,
|
|
208
|
+
span: span,
|
|
209
|
+
})];
|
|
210
|
+
case 2:
|
|
211
|
+
_handleOutput = _e.sent();
|
|
212
|
+
if (!_handleOutput)
|
|
213
|
+
return [2 /*return*/, []];
|
|
214
|
+
outputs = [];
|
|
215
|
+
if (Array.isArray(_handleOutput)) {
|
|
216
|
+
outputs = _handleOutput;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
outputs = [_handleOutput];
|
|
220
|
+
}
|
|
221
|
+
eventFactory_1 = (0, arvo_core_1.createArvoEventFactory)(handlerContract);
|
|
222
|
+
result = (0, utils_1.eventHandlerOutputEventCreator)(outputs, otelSpanHeaders, this.source, event, this.executionunits, function (param, extensions) { return eventFactory_1.emits(param, extensions); });
|
|
223
|
+
(0, arvo_core_1.logToSpan)({
|
|
224
|
+
level: 'INFO',
|
|
225
|
+
message: "Event processing completed successfully. Generated ".concat(result.length, " event(s)"),
|
|
226
|
+
});
|
|
227
|
+
(0, arvo_core_1.logToSpan)({
|
|
228
|
+
level: 'INFO',
|
|
229
|
+
message: 'Event handled successfully',
|
|
230
|
+
});
|
|
231
|
+
return [2 /*return*/, result];
|
|
232
|
+
case 3:
|
|
233
|
+
error_1 = _e.sent();
|
|
234
|
+
eventFactory = (0, arvo_core_1.createArvoEventFactory)(this.contract.version('latest'));
|
|
235
|
+
(0, arvo_core_1.exceptionToSpan)(error_1);
|
|
236
|
+
span.setStatus({
|
|
237
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
238
|
+
message: "Event processing failed: ".concat(error_1.message),
|
|
239
|
+
});
|
|
240
|
+
result = eventFactory.systemError({
|
|
217
241
|
source: this.source,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
});
|
|
241
|
-
return [2 /*return*/, result];
|
|
242
|
-
case 3:
|
|
243
|
-
error_1 = _e.sent();
|
|
244
|
-
eventFactory = (0, arvo_core_1.createArvoEventFactory)(this.contract.version('latest'));
|
|
245
|
-
(0, arvo_core_1.exceptionToSpan)(error_1);
|
|
246
|
-
span.setStatus({
|
|
247
|
-
code: api_1.SpanStatusCode.ERROR,
|
|
248
|
-
message: "Event processing failed: ".concat(error_1.message),
|
|
249
|
-
});
|
|
250
|
-
result = eventFactory.systemError({
|
|
251
|
-
source: this.source,
|
|
252
|
-
subject: event.subject,
|
|
253
|
-
// The system error must always got back to
|
|
254
|
-
// the source
|
|
255
|
-
to: event.source,
|
|
256
|
-
error: error_1,
|
|
257
|
-
executionunits: this.executionunits,
|
|
258
|
-
traceparent: (_b = otelSpanHeaders.traceparent) !== null && _b !== void 0 ? _b : undefined,
|
|
259
|
-
tracestate: (_c = otelSpanHeaders.tracestate) !== null && _c !== void 0 ? _c : undefined,
|
|
260
|
-
accesscontrol: (_d = event.accesscontrol) !== null && _d !== void 0 ? _d : undefined,
|
|
261
|
-
}, {});
|
|
262
|
-
Object.entries(result.otelAttributes).forEach(function (_a) {
|
|
263
|
-
var key = _a[0], value = _a[1];
|
|
264
|
-
return span.setAttribute("to_emit.0.".concat(key), value);
|
|
265
|
-
});
|
|
266
|
-
return [2 /*return*/, [result]];
|
|
267
|
-
case 4:
|
|
268
|
-
span.end();
|
|
269
|
-
return [7 /*endfinally*/];
|
|
270
|
-
case 5: return [2 /*return*/];
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}); },
|
|
274
|
-
})];
|
|
242
|
+
subject: event.subject,
|
|
243
|
+
// The system error must always got back to
|
|
244
|
+
// the source
|
|
245
|
+
to: event.source,
|
|
246
|
+
error: error_1,
|
|
247
|
+
executionunits: this.executionunits,
|
|
248
|
+
traceparent: (_b = otelSpanHeaders.traceparent) !== null && _b !== void 0 ? _b : undefined,
|
|
249
|
+
tracestate: (_c = otelSpanHeaders.tracestate) !== null && _c !== void 0 ? _c : undefined,
|
|
250
|
+
accesscontrol: (_d = event.accesscontrol) !== null && _d !== void 0 ? _d : undefined,
|
|
251
|
+
}, {});
|
|
252
|
+
Object.entries(result.otelAttributes).forEach(function (_a) {
|
|
253
|
+
var key = _a[0], value = _a[1];
|
|
254
|
+
return span.setAttribute("to_emit.0.".concat(key), value);
|
|
255
|
+
});
|
|
256
|
+
return [2 /*return*/, [result]];
|
|
257
|
+
case 4:
|
|
258
|
+
span.end();
|
|
259
|
+
return [7 /*endfinally*/];
|
|
260
|
+
case 5: return [2 /*return*/];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}); } }))];
|
|
275
264
|
case 1: return [2 /*return*/, _a.sent()];
|
|
276
265
|
}
|
|
277
266
|
});
|
|
@@ -69,6 +69,7 @@ var api_1 = require("@opentelemetry/api");
|
|
|
69
69
|
var arvo_core_1 = require("arvo-core");
|
|
70
70
|
var utils_1 = require("../utils");
|
|
71
71
|
var AbstractArvoEventHandler_1 = __importDefault(require("../AbstractArvoEventHandler"));
|
|
72
|
+
var utils_2 = require("../utils");
|
|
72
73
|
/**
|
|
73
74
|
* MultiArvoEventHandler processes multiple event types without being bound to specific contracts.
|
|
74
75
|
* Manages event execution, telemetry tracking, and error handling for diverse event streams.
|
|
@@ -112,82 +113,68 @@ var MultiArvoEventHandler = /** @class */ (function (_super) {
|
|
|
112
113
|
*/
|
|
113
114
|
MultiArvoEventHandler.prototype.execute = function (event_1) {
|
|
114
115
|
return __awaiter(this, arguments, void 0, function (event, opentelemetry) {
|
|
116
|
+
var otelConfig;
|
|
115
117
|
var _this = this;
|
|
116
118
|
if (opentelemetry === void 0) { opentelemetry = {
|
|
117
119
|
inheritFrom: 'EVENT',
|
|
118
120
|
}; }
|
|
119
121
|
return __generator(this, function (_a) {
|
|
120
122
|
switch (_a.label) {
|
|
121
|
-
case 0:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
level: 'INFO',
|
|
177
|
-
message: "Event processing completed successfully - Generated ".concat(resultingEvents.length, " new event(s)"),
|
|
178
|
-
});
|
|
179
|
-
return [2 /*return*/, resultingEvents];
|
|
180
|
-
case 3:
|
|
181
|
-
error_1 = _a.sent();
|
|
182
|
-
return [2 /*return*/, (0, utils_1.createHandlerErrorOutputEvent)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); })];
|
|
183
|
-
case 4:
|
|
184
|
-
span.end();
|
|
185
|
-
return [7 /*endfinally*/];
|
|
186
|
-
case 5: return [2 /*return*/];
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}); },
|
|
190
|
-
})];
|
|
123
|
+
case 0:
|
|
124
|
+
otelConfig = (0, utils_2.createEventHandlerTelemetryConfig)('MutliArvoEventHandler', this.spanOptions, opentelemetry, event);
|
|
125
|
+
return [4 /*yield*/, arvo_core_1.ArvoOpenTelemetry.getInstance().startActiveSpan(__assign(__assign({}, otelConfig), { fn: function (span) { return __awaiter(_this, void 0, void 0, function () {
|
|
126
|
+
var otelSpanHeaders, _handlerOutput, outputs, resultingEvents, error_1;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
otelSpanHeaders = (0, arvo_core_1.currentOpenTelemetryHeaders)();
|
|
131
|
+
_a.label = 1;
|
|
132
|
+
case 1:
|
|
133
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
134
|
+
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
135
|
+
Object.entries(event.otelAttributes).forEach(function (_a) {
|
|
136
|
+
var key = _a[0], value = _a[1];
|
|
137
|
+
return span.setAttribute("to_process.0.".concat(key), value);
|
|
138
|
+
});
|
|
139
|
+
(0, arvo_core_1.logToSpan)({
|
|
140
|
+
level: 'INFO',
|
|
141
|
+
message: "Initiating event resolution - Type: ".concat(event.type, ", Source: ").concat(event.source, ", Destination: ").concat(event.to),
|
|
142
|
+
});
|
|
143
|
+
if (event.to !== this.source) {
|
|
144
|
+
throw new Error("Event destination mismatch: Expected '".concat(this.source, "', received '").concat(event.to, "'"));
|
|
145
|
+
}
|
|
146
|
+
return [4 /*yield*/, this.handler({
|
|
147
|
+
event: event,
|
|
148
|
+
source: this.source,
|
|
149
|
+
span: span
|
|
150
|
+
})];
|
|
151
|
+
case 2:
|
|
152
|
+
_handlerOutput = _a.sent();
|
|
153
|
+
if (!_handlerOutput)
|
|
154
|
+
return [2 /*return*/, []];
|
|
155
|
+
outputs = [];
|
|
156
|
+
if (Array.isArray(_handlerOutput)) {
|
|
157
|
+
outputs = _handlerOutput;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
outputs = [_handlerOutput];
|
|
161
|
+
}
|
|
162
|
+
resultingEvents = (0, utils_1.eventHandlerOutputEventCreator)(outputs, otelSpanHeaders, this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); });
|
|
163
|
+
(0, arvo_core_1.logToSpan)({
|
|
164
|
+
level: 'INFO',
|
|
165
|
+
message: "Event processing completed successfully - Generated ".concat(resultingEvents.length, " new event(s)"),
|
|
166
|
+
});
|
|
167
|
+
return [2 /*return*/, resultingEvents];
|
|
168
|
+
case 3:
|
|
169
|
+
error_1 = _a.sent();
|
|
170
|
+
return [2 /*return*/, (0, utils_1.createHandlerErrorOutputEvent)(error_1, otelSpanHeaders, "sys.".concat(this.source, ".error"), this.source, event, this.executionunits, function (param, extensions) { return (0, arvo_core_1.createArvoEvent)(param, extensions); })];
|
|
171
|
+
case 4:
|
|
172
|
+
span.end();
|
|
173
|
+
return [7 /*endfinally*/];
|
|
174
|
+
case 5: return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}); } }))];
|
|
191
178
|
case 1: return [2 /*return*/, _a.sent()];
|
|
192
179
|
}
|
|
193
180
|
});
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ArvoEvent, CreateArvoEvent, OpenTelemetryHeaders } from 'arvo-core';
|
|
2
2
|
import { ArvoEventHandlerFunctionOutput } from './ArvoEventHandler/types';
|
|
3
3
|
import { MultiArvoEventHandlerFunctionOutput } from './MultiArvoEventHandler/types';
|
|
4
|
+
import { SpanOptions } from '@opentelemetry/api';
|
|
5
|
+
import { ArvoEventHandlerOpenTelemetryOptions } from './types';
|
|
4
6
|
/**
|
|
5
7
|
* Checks if the item is null or undefined.
|
|
6
8
|
*
|
|
@@ -76,3 +78,19 @@ export declare const createHandlerErrorOutputEvent: (error: Error, otelSpanHeade
|
|
|
76
78
|
* @returns True if the string contains only alphanumeric characters, false otherwise.
|
|
77
79
|
*/
|
|
78
80
|
export declare function isLowerAlphanumeric(input: string): boolean;
|
|
81
|
+
export declare const createEventHandlerTelemetryConfig: (name: string, options: SpanOptions, contextConfig: ArvoEventHandlerOpenTelemetryOptions, event: ArvoEvent) => {
|
|
82
|
+
name: string;
|
|
83
|
+
disableSpanManagement: boolean;
|
|
84
|
+
context: {
|
|
85
|
+
inheritFrom: "TRACE_HEADERS";
|
|
86
|
+
traceHeaders: {
|
|
87
|
+
traceparent: string | null;
|
|
88
|
+
tracestate: string | null;
|
|
89
|
+
};
|
|
90
|
+
context?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
inheritFrom: "CONTEXT";
|
|
93
|
+
context: import("@opentelemetry/api").Context;
|
|
94
|
+
traceHeaders?: undefined;
|
|
95
|
+
};
|
|
96
|
+
};
|
package/dist/utils.js
CHANGED
|
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
return t;
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.createHandlerErrorOutputEvent = exports.eventHandlerOutputEventCreator = void 0;
|
|
25
|
+
exports.createEventHandlerTelemetryConfig = exports.createHandlerErrorOutputEvent = exports.eventHandlerOutputEventCreator = void 0;
|
|
26
26
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
27
27
|
exports.getValueOrDefault = getValueOrDefault;
|
|
28
28
|
exports.coalesce = coalesce;
|
|
@@ -167,3 +167,20 @@ function isLowerAlphanumeric(input) {
|
|
|
167
167
|
var alphanumericRegex = /^[a-z0-9.]+$/;
|
|
168
168
|
return alphanumericRegex.test(input);
|
|
169
169
|
}
|
|
170
|
+
var createEventHandlerTelemetryConfig = function (name, options, contextConfig, event) { return ({
|
|
171
|
+
name: name,
|
|
172
|
+
disableSpanManagement: true,
|
|
173
|
+
context: contextConfig.inheritFrom === 'EVENT'
|
|
174
|
+
? {
|
|
175
|
+
inheritFrom: 'TRACE_HEADERS',
|
|
176
|
+
traceHeaders: {
|
|
177
|
+
traceparent: event.traceparent,
|
|
178
|
+
tracestate: event.tracestate,
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
: {
|
|
182
|
+
inheritFrom: 'CONTEXT',
|
|
183
|
+
context: api_1.context.active(),
|
|
184
|
+
},
|
|
185
|
+
}); };
|
|
186
|
+
exports.createEventHandlerTelemetryConfig = createEventHandlerTelemetryConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arvo-event-handler",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Type-safe event handler system with versioning, telemetry, and contract validation for distributed Arvo event-driven architectures, featuring routing and multi-handler support.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|