arvo-event-handler 1.0.4 → 1.0.5

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.
@@ -38,9 +38,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  var arvo_core_1 = require("arvo-core");
40
40
  var schema_1 = require("arvo-core/dist/ArvoEvent/schema");
41
- var OpenTelemetry_1 = require("../OpenTelemetry");
42
41
  var api_1 = require("@opentelemetry/api");
43
42
  var utils_1 = require("../utils");
43
+ var utils_2 = require("../OpenTelemetry/utils");
44
44
  /**
45
45
  * Represents an event handler for Arvo contracts.
46
46
  *
@@ -136,27 +136,16 @@ var ArvoEventHandler = /** @class */ (function () {
136
136
  */
137
137
  ArvoEventHandler.prototype.execute = function (event) {
138
138
  return __awaiter(this, void 0, void 0, function () {
139
- var spanName, spanOptions, span, inheritedContext, eventFactory;
140
- var _a;
139
+ var span, eventFactory;
141
140
  var _this = this;
142
- return __generator(this, function (_b) {
143
- switch (_b.label) {
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
144
143
  case 0:
145
- spanName = "ArvoEventHandler<".concat(this.contract.uri, ">.execute<").concat(event.type, ">");
146
- spanOptions = {
144
+ span = (0, utils_2.createSpanFromEvent)("ArvoEventHandler<".concat(this.contract.uri, ">.execute<").concat(event.type, ">"), event, {
147
145
  kind: this.openTelemetrySpanKind,
148
- attributes: (_a = {},
149
- _a[arvo_core_1.OpenInference.ATTR_SPAN_KIND] = this.openInferenceSpanKind,
150
- _a[arvo_core_1.ArvoExecution.ATTR_SPAN_KIND] = this.arvoExecutionSpanKind,
151
- _a),
152
- };
153
- if (event.traceparent) {
154
- inheritedContext = (0, OpenTelemetry_1.extractContext)(event.traceparent, event.tracestate);
155
- span = OpenTelemetry_1.ArvoEventHandlerTracer.startSpan(spanName, spanOptions, inheritedContext);
156
- }
157
- else {
158
- span = OpenTelemetry_1.ArvoEventHandlerTracer.startSpan(spanName, spanOptions);
159
- }
146
+ openInference: this.openInferenceSpanKind,
147
+ arvoExecution: this.arvoExecutionSpanKind
148
+ });
160
149
  eventFactory = (0, arvo_core_1.createArvoEventFactory)(this.contract);
161
150
  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 () {
162
151
  var otelSpanHeaders, inputEventValidation, _handleOutput, outputs, error_1, result;
@@ -228,7 +217,7 @@ var ArvoEventHandler = /** @class */ (function () {
228
217
  }
229
218
  });
230
219
  }); })];
231
- case 1: return [2 /*return*/, _b.sent()];
220
+ case 1: return [2 /*return*/, _a.sent()];
232
221
  }
233
222
  });
234
223
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arvo-event-handler",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
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": {