arvo-core 1.1.14 → 1.1.15
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.
@@ -48,8 +48,9 @@ var uuid_1 = require("uuid");
|
|
48
48
|
var createArvoEvent = function (event, extensions) {
|
49
49
|
var span = OpenTelemetry_1.ArvoCoreTracer.startSpan("createArvoEvent<".concat(event.type, ">"), {});
|
50
50
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
51
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
52
52
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
53
|
+
var otelHeaders = (0, OpenTelemetry_1.currentOpenTelemetryHeaders)();
|
53
54
|
try {
|
54
55
|
if (event.datacontenttype &&
|
55
56
|
event.datacontenttype !== schema_1.ArvoDataContentType) {
|
@@ -64,11 +65,11 @@ var createArvoEvent = function (event, extensions) {
|
|
64
65
|
type: event.type,
|
65
66
|
accesscontrol: (_b = event.accesscontrol) !== null && _b !== void 0 ? _b : null,
|
66
67
|
executionunits: (_c = event.executionunits) !== null && _c !== void 0 ? _c : null,
|
67
|
-
traceparent: (_d = event.traceparent) !== null && _d !== void 0 ? _d : null,
|
68
|
-
tracestate: (
|
69
|
-
datacontenttype: (
|
70
|
-
specversion: (
|
71
|
-
time: (
|
68
|
+
traceparent: (_e = (_d = event.traceparent) !== null && _d !== void 0 ? _d : otelHeaders.traceparent) !== null && _e !== void 0 ? _e : null,
|
69
|
+
tracestate: (_g = (_f = event.tracestate) !== null && _f !== void 0 ? _f : otelHeaders.tracestate) !== null && _g !== void 0 ? _g : null,
|
70
|
+
datacontenttype: (_h = event.datacontenttype) !== null && _h !== void 0 ? _h : schema_1.ArvoDataContentType,
|
71
|
+
specversion: (_j = event.specversion) !== null && _j !== void 0 ? _j : '1.0',
|
72
|
+
time: (_k = event.time) !== null && _k !== void 0 ? _k : (0, utils_1.createTimestamp)(),
|
72
73
|
source: encodeURI(event.source),
|
73
74
|
subject: encodeURI(event.subject),
|
74
75
|
to: event.to ? encodeURI(event.to) : encodeURI(event.type),
|
@@ -56,13 +56,15 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
56
56
|
var _this = this;
|
57
57
|
var span = OpenTelemetry_1.ArvoCoreTracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.accepts<").concat(this.contract.accepts.type, ">.create"));
|
58
58
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
59
|
+
var _a, _b, _c, _d;
|
59
60
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
61
|
+
var otelHeaders = (0, OpenTelemetry_1.currentOpenTelemetryHeaders)();
|
60
62
|
try {
|
61
63
|
var validationResult = _this.contract.validateAccepts(_this.contract.accepts.type, event.data);
|
62
64
|
if (!validationResult.success) {
|
63
65
|
throw new Error("Accept Event data validation failed: ".concat(validationResult.error.message));
|
64
66
|
}
|
65
|
-
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { type: _this.contract.accepts.type, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions);
|
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);
|
66
68
|
}
|
67
69
|
catch (error) {
|
68
70
|
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
@@ -91,13 +93,15 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
91
93
|
var _this = this;
|
92
94
|
var span = OpenTelemetry_1.ArvoCoreTracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.emits<").concat(event.type, ">.create"));
|
93
95
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
96
|
+
var _a, _b, _c, _d;
|
94
97
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
98
|
+
var otelHeaders = (0, OpenTelemetry_1.currentOpenTelemetryHeaders)();
|
95
99
|
try {
|
96
100
|
var validationResult = _this.contract.validateEmits(event.type, event.data);
|
97
101
|
if (!validationResult.success) {
|
98
102
|
throw new Error("Emit Event data validation failed: ".concat(validationResult.error.message));
|
99
103
|
}
|
100
|
-
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions);
|
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);
|
101
105
|
}
|
102
106
|
catch (error) {
|
103
107
|
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
@@ -124,14 +128,15 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
124
128
|
var _this = this;
|
125
129
|
var span = OpenTelemetry_1.ArvoCoreTracer.startSpan("ArvoEventFactory<".concat(this.contract.uri, ">.systemError<sys.").concat(this.contract.accepts.type, ".error>.create"));
|
126
130
|
return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), function () {
|
127
|
-
var _a;
|
131
|
+
var _a, _b, _c, _d, _e;
|
128
132
|
span.setStatus({ code: api_1.SpanStatusCode.OK });
|
133
|
+
var otelHeaders = (0, OpenTelemetry_1.currentOpenTelemetryHeaders)();
|
129
134
|
try {
|
130
135
|
var error = event.error, _event = __rest(event, ["error"]);
|
131
|
-
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, _event), { type: "sys.".concat(_this.contract.accepts.type, ".error"), data: {
|
136
|
+
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: "sys.".concat(_this.contract.accepts.type, ".error"), data: {
|
132
137
|
errorName: error.name,
|
133
138
|
errorMessage: error.message,
|
134
|
-
errorStack: (
|
139
|
+
errorStack: (_e = error.stack) !== null && _e !== void 0 ? _e : null,
|
135
140
|
}, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri }), extensions);
|
136
141
|
}
|
137
142
|
catch (error) {
|