arvo-core 1.0.13 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/dist/ArvoEvent/index.d.ts +67 -1
- package/dist/ArvoEvent/index.js +102 -0
- package/dist/OpenTelemetry/index.d.ts +4 -4
- package/dist/OpenTelemetry/index.js +7 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -15,7 +15,7 @@ export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExt
|
|
15
15
|
readonly dataschema: string | null;
|
16
16
|
readonly data: TData;
|
17
17
|
readonly time: string;
|
18
|
-
extensions: TExtension & ArvoExtension & OpenTelemetryExtension;
|
18
|
+
readonly extensions: TExtension & ArvoExtension & OpenTelemetryExtension;
|
19
19
|
/**
|
20
20
|
* Creates an instance of ArvoEvent.
|
21
21
|
* @param context - The CloudEvent context along with Arvo and OpenTelemetry extensions.
|
@@ -86,4 +86,70 @@ export default class ArvoEvent<TData extends ArvoEventData = ArvoEventData, TExt
|
|
86
86
|
'cloudevents.arvo.event_to': string;
|
87
87
|
'cloudevents.arvo.event_executionunits': string | number;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* Gets the 'to' field from the ArvoExtension.
|
91
|
+
* This field represents the intended recipient or destination of the event.
|
92
|
+
* @returns The value of the 'to' field.
|
93
|
+
*
|
94
|
+
* @remark
|
95
|
+
* This is a convenience getter for the data in `this.extensions.to` as this
|
96
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
97
|
+
* spec.
|
98
|
+
*/
|
99
|
+
get to(): string | null;
|
100
|
+
/**
|
101
|
+
* Gets the 'accesscontrol' field from the ArvoExtension.
|
102
|
+
* This field contains access control information for the event.
|
103
|
+
* @returns The value of the 'accesscontrol' field.
|
104
|
+
*
|
105
|
+
* @remark
|
106
|
+
* This is a convenience getter for the data in `this.extensions.accesscontrol` as this
|
107
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
108
|
+
* spec.
|
109
|
+
*/
|
110
|
+
get accesscontrol(): string | null;
|
111
|
+
/**
|
112
|
+
* Gets the 'redirectto' field from the ArvoExtension.
|
113
|
+
* This field indicate an alternative destination for the event.
|
114
|
+
* @returns The value of the 'redirectto' field.
|
115
|
+
*
|
116
|
+
* @remark
|
117
|
+
* This is a convenience getter for the data in `this.extensions.redirectto` as this
|
118
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
119
|
+
* spec.
|
120
|
+
*/
|
121
|
+
get redirectto(): string | null;
|
122
|
+
/**
|
123
|
+
* Gets the 'executionunits' field from the ArvoExtension.
|
124
|
+
* This field contains information about the execution units associated with the event.
|
125
|
+
* @returns The value of the 'executionunits' field.
|
126
|
+
*
|
127
|
+
* @remark
|
128
|
+
* This is a convenience getter for the data in `this.extensions.executionunits` as this
|
129
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
130
|
+
* spec.
|
131
|
+
*/
|
132
|
+
get executionunits(): number | null;
|
133
|
+
/**
|
134
|
+
* Gets the 'traceparent' field from the OpenTelemetryExtension.
|
135
|
+
* This field contains the W3C Trace Context traceparent header.
|
136
|
+
* @returns The value of the 'traceparent' field.
|
137
|
+
*
|
138
|
+
* @remark
|
139
|
+
* This is a convenience getter for the data in `this.extensions.traceparent` as this
|
140
|
+
* is an ArvoEvent object which natively defined this extension on the CloudEvent
|
141
|
+
* spec.
|
142
|
+
*/
|
143
|
+
get traceparent(): string | null;
|
144
|
+
/**
|
145
|
+
* Gets the 'tracestate' field from the OpenTelemetryExtension.
|
146
|
+
* This field contains the W3C Trace Context tracestate header.
|
147
|
+
* @returns The value of the 'tracestate' field, or undefined if not set.
|
148
|
+
*
|
149
|
+
* @remark
|
150
|
+
* This is a convenience getter for the data in `this.extensions.tracestate` as this
|
151
|
+
* is an ArvoEvent object which natively defined this extension on the CloudEvent
|
152
|
+
* spec.
|
153
|
+
*/
|
154
|
+
get tracestate(): string | null;
|
89
155
|
}
|
package/dist/ArvoEvent/index.js
CHANGED
@@ -122,6 +122,108 @@ var ArvoEvent = /** @class */ (function () {
|
|
122
122
|
enumerable: false,
|
123
123
|
configurable: true
|
124
124
|
});
|
125
|
+
Object.defineProperty(ArvoEvent.prototype, "to", {
|
126
|
+
/**
|
127
|
+
* Gets the 'to' field from the ArvoExtension.
|
128
|
+
* This field represents the intended recipient or destination of the event.
|
129
|
+
* @returns The value of the 'to' field.
|
130
|
+
*
|
131
|
+
* @remark
|
132
|
+
* This is a convenience getter for the data in `this.extensions.to` as this
|
133
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
134
|
+
* spec.
|
135
|
+
*/
|
136
|
+
get: function () {
|
137
|
+
return this.extensions.to;
|
138
|
+
},
|
139
|
+
enumerable: false,
|
140
|
+
configurable: true
|
141
|
+
});
|
142
|
+
Object.defineProperty(ArvoEvent.prototype, "accesscontrol", {
|
143
|
+
/**
|
144
|
+
* Gets the 'accesscontrol' field from the ArvoExtension.
|
145
|
+
* This field contains access control information for the event.
|
146
|
+
* @returns The value of the 'accesscontrol' field.
|
147
|
+
*
|
148
|
+
* @remark
|
149
|
+
* This is a convenience getter for the data in `this.extensions.accesscontrol` as this
|
150
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
151
|
+
* spec.
|
152
|
+
*/
|
153
|
+
get: function () {
|
154
|
+
return this.extensions.accesscontrol;
|
155
|
+
},
|
156
|
+
enumerable: false,
|
157
|
+
configurable: true
|
158
|
+
});
|
159
|
+
Object.defineProperty(ArvoEvent.prototype, "redirectto", {
|
160
|
+
/**
|
161
|
+
* Gets the 'redirectto' field from the ArvoExtension.
|
162
|
+
* This field indicate an alternative destination for the event.
|
163
|
+
* @returns The value of the 'redirectto' field.
|
164
|
+
*
|
165
|
+
* @remark
|
166
|
+
* This is a convenience getter for the data in `this.extensions.redirectto` as this
|
167
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
168
|
+
* spec.
|
169
|
+
*/
|
170
|
+
get: function () {
|
171
|
+
return this.extensions.redirectto;
|
172
|
+
},
|
173
|
+
enumerable: false,
|
174
|
+
configurable: true
|
175
|
+
});
|
176
|
+
Object.defineProperty(ArvoEvent.prototype, "executionunits", {
|
177
|
+
/**
|
178
|
+
* Gets the 'executionunits' field from the ArvoExtension.
|
179
|
+
* This field contains information about the execution units associated with the event.
|
180
|
+
* @returns The value of the 'executionunits' field.
|
181
|
+
*
|
182
|
+
* @remark
|
183
|
+
* This is a convenience getter for the data in `this.extensions.executionunits` as this
|
184
|
+
* is an ArvoEvent object which natively defines this extension on the CloudEvent
|
185
|
+
* spec.
|
186
|
+
*/
|
187
|
+
get: function () {
|
188
|
+
return this.extensions.executionunits;
|
189
|
+
},
|
190
|
+
enumerable: false,
|
191
|
+
configurable: true
|
192
|
+
});
|
193
|
+
Object.defineProperty(ArvoEvent.prototype, "traceparent", {
|
194
|
+
/**
|
195
|
+
* Gets the 'traceparent' field from the OpenTelemetryExtension.
|
196
|
+
* This field contains the W3C Trace Context traceparent header.
|
197
|
+
* @returns The value of the 'traceparent' field.
|
198
|
+
*
|
199
|
+
* @remark
|
200
|
+
* This is a convenience getter for the data in `this.extensions.traceparent` as this
|
201
|
+
* is an ArvoEvent object which natively defined this extension on the CloudEvent
|
202
|
+
* spec.
|
203
|
+
*/
|
204
|
+
get: function () {
|
205
|
+
return this.extensions.traceparent;
|
206
|
+
},
|
207
|
+
enumerable: false,
|
208
|
+
configurable: true
|
209
|
+
});
|
210
|
+
Object.defineProperty(ArvoEvent.prototype, "tracestate", {
|
211
|
+
/**
|
212
|
+
* Gets the 'tracestate' field from the OpenTelemetryExtension.
|
213
|
+
* This field contains the W3C Trace Context tracestate header.
|
214
|
+
* @returns The value of the 'tracestate' field, or undefined if not set.
|
215
|
+
*
|
216
|
+
* @remark
|
217
|
+
* This is a convenience getter for the data in `this.extensions.tracestate` as this
|
218
|
+
* is an ArvoEvent object which natively defined this extension on the CloudEvent
|
219
|
+
* spec.
|
220
|
+
*/
|
221
|
+
get: function () {
|
222
|
+
return this.extensions.tracestate;
|
223
|
+
},
|
224
|
+
enumerable: false,
|
225
|
+
configurable: true
|
226
|
+
});
|
125
227
|
return ArvoEvent;
|
126
228
|
}());
|
127
229
|
exports.default = ArvoEvent;
|
@@ -64,8 +64,8 @@ export declare const exceptionToSpan: (span: Span, level: TelemetryLogLevel, err
|
|
64
64
|
* telemetryContext,
|
65
65
|
* 'ProcessOrder',
|
66
66
|
* { attributes: { orderId: '12345' } },
|
67
|
-
* (
|
68
|
-
* span.addEvent('Processing order');
|
67
|
+
* (telemetryContext, orderId) => {
|
68
|
+
* telemetryContext.span.addEvent('Processing order');
|
69
69
|
* return processOrder(orderId);
|
70
70
|
* },
|
71
71
|
* null,
|
@@ -78,8 +78,8 @@ export declare const exceptionToSpan: (span: Span, level: TelemetryLogLevel, err
|
|
78
78
|
* 'OrderService',
|
79
79
|
* 'FetchOrderDetails',
|
80
80
|
* undefined,
|
81
|
-
* (
|
82
|
-
* span.setAttribute('orderId', orderId);
|
81
|
+
* (telemetryContext, orderId) => {
|
82
|
+
* telemetryContext.span.setAttribute('orderId', orderId);
|
83
83
|
* return fetchOrderDetails(orderId);
|
84
84
|
* },
|
85
85
|
* null,
|
@@ -115,8 +115,8 @@ exports.exceptionToSpan = exceptionToSpan;
|
|
115
115
|
* telemetryContext,
|
116
116
|
* 'ProcessOrder',
|
117
117
|
* { attributes: { orderId: '12345' } },
|
118
|
-
* (
|
119
|
-
* span.addEvent('Processing order');
|
118
|
+
* (telemetryContext, orderId) => {
|
119
|
+
* telemetryContext.span.addEvent('Processing order');
|
120
120
|
* return processOrder(orderId);
|
121
121
|
* },
|
122
122
|
* null,
|
@@ -129,8 +129,8 @@ exports.exceptionToSpan = exceptionToSpan;
|
|
129
129
|
* 'OrderService',
|
130
130
|
* 'FetchOrderDetails',
|
131
131
|
* undefined,
|
132
|
-
* (
|
133
|
-
* span.setAttribute('orderId', orderId);
|
132
|
+
* (telemetryContext, orderId) => {
|
133
|
+
* telemetryContext.span.setAttribute('orderId', orderId);
|
134
134
|
* return fetchOrderDetails(orderId);
|
135
135
|
* },
|
136
136
|
* null,
|
@@ -152,6 +152,9 @@ var createOtelSpan = function (telemetryContext, spanName, spanOptions, wrappedF
|
|
152
152
|
activeTracer = telemetryContext.tracer;
|
153
153
|
}
|
154
154
|
var newSpan = activeTracer.startSpan(spanName, spanOptions, activeContext);
|
155
|
+
newSpan.setStatus({
|
156
|
+
code: api_1.SpanStatusCode.OK,
|
157
|
+
});
|
155
158
|
try {
|
156
159
|
var result = api_1.context.with(api_1.trace.setSpan(activeContext, newSpan), function () {
|
157
160
|
return wrappedFunction.call.apply(wrappedFunction, __spreadArray([thisArg,
|
@@ -161,9 +164,6 @@ var createOtelSpan = function (telemetryContext, spanName, spanOptions, wrappedF
|
|
161
164
|
carrier: (0, exports.getTelemetryCarrier)(newSpan, activeContext),
|
162
165
|
}], args, false));
|
163
166
|
});
|
164
|
-
newSpan.setStatus({
|
165
|
-
code: api_1.SpanStatusCode.OK,
|
166
|
-
});
|
167
167
|
newSpan.end();
|
168
168
|
return result;
|
169
169
|
}
|