@interopio/browser 4.2.4 → 4.2.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.
- package/dist/browser.es.js +2621 -321
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +2625 -321
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +14 -1
- package/package.json +30 -6
package/dist/browser.umd.js
CHANGED
|
@@ -8,56 +8,56 @@
|
|
|
8
8
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
var isMergeableObject = function isMergeableObject(value) {
|
|
12
|
-
return isNonNullObject(value)
|
|
13
|
-
&& !isSpecial(value)
|
|
11
|
+
var isMergeableObject$1 = function isMergeableObject(value) {
|
|
12
|
+
return isNonNullObject$1(value)
|
|
13
|
+
&& !isSpecial$1(value)
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
function isNonNullObject(value) {
|
|
16
|
+
function isNonNullObject$1(value) {
|
|
17
17
|
return !!value && typeof value === 'object'
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function isSpecial(value) {
|
|
20
|
+
function isSpecial$1(value) {
|
|
21
21
|
var stringValue = Object.prototype.toString.call(value);
|
|
22
22
|
|
|
23
23
|
return stringValue === '[object RegExp]'
|
|
24
24
|
|| stringValue === '[object Date]'
|
|
25
|
-
|| isReactElement(value)
|
|
25
|
+
|| isReactElement$1(value)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
29
|
-
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
30
|
-
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
29
|
+
var canUseSymbol$1 = typeof Symbol === 'function' && Symbol.for;
|
|
30
|
+
var REACT_ELEMENT_TYPE$1 = canUseSymbol$1 ? Symbol.for('react.element') : 0xeac7;
|
|
31
31
|
|
|
32
|
-
function isReactElement(value) {
|
|
33
|
-
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
32
|
+
function isReactElement$1(value) {
|
|
33
|
+
return value.$$typeof === REACT_ELEMENT_TYPE$1
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function emptyTarget(val) {
|
|
36
|
+
function emptyTarget$1(val) {
|
|
37
37
|
return Array.isArray(val) ? [] : {}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
40
|
+
function cloneUnlessOtherwiseSpecified$1(value, options) {
|
|
41
41
|
return (options.clone !== false && options.isMergeableObject(value))
|
|
42
|
-
? deepmerge(emptyTarget(value), value, options)
|
|
42
|
+
? deepmerge$1(emptyTarget$1(value), value, options)
|
|
43
43
|
: value
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function defaultArrayMerge(target, source, options) {
|
|
46
|
+
function defaultArrayMerge$1(target, source, options) {
|
|
47
47
|
return target.concat(source).map(function(element) {
|
|
48
|
-
return cloneUnlessOtherwiseSpecified(element, options)
|
|
48
|
+
return cloneUnlessOtherwiseSpecified$1(element, options)
|
|
49
49
|
})
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function getMergeFunction(key, options) {
|
|
52
|
+
function getMergeFunction$1(key, options) {
|
|
53
53
|
if (!options.customMerge) {
|
|
54
|
-
return deepmerge
|
|
54
|
+
return deepmerge$1
|
|
55
55
|
}
|
|
56
56
|
var customMerge = options.customMerge(key);
|
|
57
|
-
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
57
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge$1
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
60
|
+
function getEnumerableOwnPropertySymbols$1(target) {
|
|
61
61
|
return Object.getOwnPropertySymbols
|
|
62
62
|
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
63
63
|
return Object.propertyIsEnumerable.call(target, symbol)
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
: []
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function getKeys(target) {
|
|
69
|
-
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
68
|
+
function getKeys$1(target) {
|
|
69
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols$1(target))
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function propertyIsOnObject(object, property) {
|
|
72
|
+
function propertyIsOnObject$1(object, property) {
|
|
73
73
|
try {
|
|
74
74
|
return property in object
|
|
75
75
|
} catch(_) {
|
|
@@ -78,69 +78,69 @@
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
81
|
-
function propertyIsUnsafe(target, key) {
|
|
82
|
-
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
81
|
+
function propertyIsUnsafe$1(target, key) {
|
|
82
|
+
return propertyIsOnObject$1(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
83
83
|
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
84
84
|
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function mergeObject(target, source, options) {
|
|
87
|
+
function mergeObject$1(target, source, options) {
|
|
88
88
|
var destination = {};
|
|
89
89
|
if (options.isMergeableObject(target)) {
|
|
90
|
-
getKeys(target).forEach(function(key) {
|
|
91
|
-
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
90
|
+
getKeys$1(target).forEach(function(key) {
|
|
91
|
+
destination[key] = cloneUnlessOtherwiseSpecified$1(target[key], options);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
getKeys(source).forEach(function(key) {
|
|
95
|
-
if (propertyIsUnsafe(target, key)) {
|
|
94
|
+
getKeys$1(source).forEach(function(key) {
|
|
95
|
+
if (propertyIsUnsafe$1(target, key)) {
|
|
96
96
|
return
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
100
|
-
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
99
|
+
if (propertyIsOnObject$1(target, key) && options.isMergeableObject(source[key])) {
|
|
100
|
+
destination[key] = getMergeFunction$1(key, options)(target[key], source[key], options);
|
|
101
101
|
} else {
|
|
102
|
-
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
102
|
+
destination[key] = cloneUnlessOtherwiseSpecified$1(source[key], options);
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
return destination
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
function deepmerge(target, source, options) {
|
|
108
|
+
function deepmerge$1(target, source, options) {
|
|
109
109
|
options = options || {};
|
|
110
|
-
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
111
|
-
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
110
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge$1;
|
|
111
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject$1;
|
|
112
112
|
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
113
113
|
// implementations can use it. The caller may not replace it.
|
|
114
|
-
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
114
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified$1;
|
|
115
115
|
|
|
116
116
|
var sourceIsArray = Array.isArray(source);
|
|
117
117
|
var targetIsArray = Array.isArray(target);
|
|
118
118
|
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
119
119
|
|
|
120
120
|
if (!sourceAndTargetTypesMatch) {
|
|
121
|
-
return cloneUnlessOtherwiseSpecified(source, options)
|
|
121
|
+
return cloneUnlessOtherwiseSpecified$1(source, options)
|
|
122
122
|
} else if (sourceIsArray) {
|
|
123
123
|
return options.arrayMerge(target, source, options)
|
|
124
124
|
} else {
|
|
125
|
-
return mergeObject(target, source, options)
|
|
125
|
+
return mergeObject$1(target, source, options)
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
deepmerge.all = function deepmergeAll(array, options) {
|
|
129
|
+
deepmerge$1.all = function deepmergeAll(array, options) {
|
|
130
130
|
if (!Array.isArray(array)) {
|
|
131
131
|
throw new Error('first argument should be an array')
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
return array.reduce(function(prev, next) {
|
|
135
|
-
return deepmerge(prev, next, options)
|
|
135
|
+
return deepmerge$1(prev, next, options)
|
|
136
136
|
}, {})
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
var deepmerge_1 = deepmerge;
|
|
139
|
+
var deepmerge_1$1 = deepmerge$1;
|
|
140
140
|
|
|
141
|
-
var cjs = deepmerge_1;
|
|
141
|
+
var cjs$1 = deepmerge_1$1;
|
|
142
142
|
|
|
143
|
-
var deepmerge$
|
|
143
|
+
var deepmerge$2 = /*@__PURE__*/getDefaultExportFromCjs$1(cjs$1);
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Wraps values in an `Ok` type.
|
|
@@ -3263,9 +3263,9 @@
|
|
|
3263
3263
|
isPlatformInternal,
|
|
3264
3264
|
logger: config.systemLogger?.level ?? "info",
|
|
3265
3265
|
customLogger: config.systemLogger?.customLogger,
|
|
3266
|
-
widget: deepmerge$
|
|
3267
|
-
modals: deepmerge$
|
|
3268
|
-
intentResolver: deepmerge$
|
|
3266
|
+
widget: deepmerge$2(defaultWidgetConfig, decodedWidgetConfigResult.result ?? {}),
|
|
3267
|
+
modals: deepmerge$2(defaultModalsConfig, decodedModalsConfigResult.result ?? {}),
|
|
3268
|
+
intentResolver: deepmerge$2(defaultIntentResolverConfig, decodedIntentResolverConfigResult.result ?? {}),
|
|
3269
3269
|
};
|
|
3270
3270
|
return combined;
|
|
3271
3271
|
};
|
|
@@ -7464,7 +7464,7 @@
|
|
|
7464
7464
|
const { rootElement } = this.appendWidgetResources(resources);
|
|
7465
7465
|
this.subscribeForThemeChanges(io, rootElement);
|
|
7466
7466
|
const config = {
|
|
7467
|
-
...deepmerge$
|
|
7467
|
+
...deepmerge$2(resources.config, this.config.widget),
|
|
7468
7468
|
rootElement
|
|
7469
7469
|
};
|
|
7470
7470
|
return PromiseWrap(async () => {
|
|
@@ -7751,7 +7751,7 @@
|
|
|
7751
7751
|
}
|
|
7752
7752
|
}
|
|
7753
7753
|
|
|
7754
|
-
var version$1 = "4.2.
|
|
7754
|
+
var version$1 = "4.2.5";
|
|
7755
7755
|
|
|
7756
7756
|
const setupGlobalSystem = (io, bridge) => {
|
|
7757
7757
|
return {
|
|
@@ -8846,6 +8846,9 @@
|
|
|
8846
8846
|
return Utils._isNode;
|
|
8847
8847
|
}
|
|
8848
8848
|
static _isNode;
|
|
8849
|
+
static getMethodName(method) {
|
|
8850
|
+
return typeof method === "string" ? method : method?.name;
|
|
8851
|
+
}
|
|
8849
8852
|
}
|
|
8850
8853
|
|
|
8851
8854
|
class PromiseWrapper {
|
|
@@ -10805,220 +10808,2198 @@
|
|
|
10805
10808
|
}
|
|
10806
10809
|
};
|
|
10807
10810
|
|
|
10808
|
-
var version = "6.
|
|
10811
|
+
var version = "6.9.0";
|
|
10809
10812
|
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
const webPlatform = gwConfig?.webPlatform ?? undefined;
|
|
10832
|
-
if (glue42gd) {
|
|
10833
|
-
ws = glue42gd.gwURL;
|
|
10834
|
-
}
|
|
10835
|
-
if (Utils.isNode() && nodeStartingContext && nodeStartingContext.gwURL) {
|
|
10836
|
-
ws = nodeStartingContext.gwURL;
|
|
10837
|
-
}
|
|
10838
|
-
if (!ws && !sharedWorker && !inproc) {
|
|
10839
|
-
ws = defaultWs;
|
|
10840
|
-
}
|
|
10841
|
-
let instanceId;
|
|
10842
|
-
let windowId;
|
|
10843
|
-
let pid;
|
|
10844
|
-
let environment;
|
|
10845
|
-
let region;
|
|
10846
|
-
const appName = getApplication();
|
|
10847
|
-
let uniqueAppName = appName;
|
|
10848
|
-
if (typeof glue42gd !== "undefined") {
|
|
10849
|
-
windowId = glue42gd.windowId;
|
|
10850
|
-
pid = glue42gd.pid;
|
|
10851
|
-
if (glue42gd.env) {
|
|
10852
|
-
environment = glue42gd.env.env;
|
|
10853
|
-
region = glue42gd.env.region;
|
|
10854
|
-
}
|
|
10855
|
-
uniqueAppName = glue42gd.application ?? "glue-app";
|
|
10856
|
-
instanceId = glue42gd.appInstanceId;
|
|
10857
|
-
}
|
|
10858
|
-
else if (Utils.isNode()) {
|
|
10859
|
-
pid = process.pid;
|
|
10860
|
-
if (nodeStartingContext) {
|
|
10861
|
-
environment = nodeStartingContext.env;
|
|
10862
|
-
region = nodeStartingContext.region;
|
|
10863
|
-
instanceId = nodeStartingContext.instanceId;
|
|
10864
|
-
}
|
|
10865
|
-
}
|
|
10866
|
-
else if (typeof window?.glue42electron !== "undefined") {
|
|
10867
|
-
windowId = window?.glue42electron.instanceId;
|
|
10868
|
-
pid = window?.glue42electron.pid;
|
|
10869
|
-
environment = window?.glue42electron.env;
|
|
10870
|
-
region = window?.glue42electron.region;
|
|
10871
|
-
uniqueAppName = window?.glue42electron.application ?? "glue-app";
|
|
10872
|
-
instanceId = window?.glue42electron.instanceId;
|
|
10873
|
-
}
|
|
10874
|
-
else ;
|
|
10875
|
-
const replaySpecs = configuration.gateway?.replaySpecs ?? [];
|
|
10876
|
-
replaySpecs.push(ContextMessageReplaySpec);
|
|
10877
|
-
let identity = {
|
|
10878
|
-
application: uniqueAppName,
|
|
10879
|
-
applicationName: appName,
|
|
10880
|
-
windowId,
|
|
10881
|
-
instance: instanceId,
|
|
10882
|
-
process: pid,
|
|
10883
|
-
region,
|
|
10884
|
-
environment,
|
|
10885
|
-
api: ext.version || version
|
|
10886
|
-
};
|
|
10887
|
-
if (configuration.identity) {
|
|
10888
|
-
identity = Object.assign(identity, configuration.identity);
|
|
10889
|
-
}
|
|
10890
|
-
return {
|
|
10891
|
-
identity,
|
|
10892
|
-
reconnectInterval,
|
|
10893
|
-
ws,
|
|
10894
|
-
sharedWorker,
|
|
10895
|
-
webPlatform,
|
|
10896
|
-
inproc,
|
|
10897
|
-
protocolVersion,
|
|
10898
|
-
reconnectAttempts,
|
|
10899
|
-
replaySpecs,
|
|
10900
|
-
};
|
|
10901
|
-
}
|
|
10902
|
-
function getContexts() {
|
|
10903
|
-
const defaultConfig = {
|
|
10904
|
-
reAnnounceKnownContexts: true,
|
|
10905
|
-
subscribeOnUpdate: true,
|
|
10906
|
-
subscribeOnGet: true,
|
|
10907
|
-
onlyReAnnounceSubscribedContexts: true
|
|
10908
|
-
};
|
|
10909
|
-
if (typeof configuration.contexts === "undefined") {
|
|
10910
|
-
return defaultConfig;
|
|
10911
|
-
}
|
|
10912
|
-
if (typeof configuration.contexts === "boolean" && configuration.contexts) {
|
|
10913
|
-
return defaultConfig;
|
|
10914
|
-
}
|
|
10915
|
-
if (typeof configuration.contexts === "object") {
|
|
10916
|
-
return { ...defaultConfig, ...configuration.contexts };
|
|
10917
|
-
}
|
|
10813
|
+
/*!
|
|
10814
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
10815
|
+
*
|
|
10816
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
10817
|
+
* Released under the MIT License.
|
|
10818
|
+
*/
|
|
10819
|
+
function isObject$1(o) {
|
|
10820
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
10821
|
+
}
|
|
10822
|
+
function isPlainObject$2(o) {
|
|
10823
|
+
let ctor;
|
|
10824
|
+
let prot;
|
|
10825
|
+
if (isObject$1(o) === false)
|
|
10826
|
+
return false;
|
|
10827
|
+
ctor = o.constructor;
|
|
10828
|
+
if (ctor === undefined)
|
|
10829
|
+
return true;
|
|
10830
|
+
prot = ctor.prototype;
|
|
10831
|
+
if (isObject$1(prot) === false)
|
|
10832
|
+
return false;
|
|
10833
|
+
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
10918
10834
|
return false;
|
|
10919
10835
|
}
|
|
10920
|
-
|
|
10921
|
-
if (configuration.application) {
|
|
10922
|
-
return configuration.application;
|
|
10923
|
-
}
|
|
10924
|
-
if (glue42gd) {
|
|
10925
|
-
return glue42gd.applicationName;
|
|
10926
|
-
}
|
|
10927
|
-
if (typeof window !== "undefined" && typeof window.glue42electron !== "undefined") {
|
|
10928
|
-
return window.glue42electron.application;
|
|
10929
|
-
}
|
|
10930
|
-
const uid = nanoid(10);
|
|
10931
|
-
if (Utils.isNode()) {
|
|
10932
|
-
if (nodeStartingContext) {
|
|
10933
|
-
return nodeStartingContext.applicationConfig.name;
|
|
10934
|
-
}
|
|
10935
|
-
return "NodeJS" + uid;
|
|
10936
|
-
}
|
|
10937
|
-
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
10938
|
-
return document.title + ` (${uid})`;
|
|
10939
|
-
}
|
|
10940
|
-
return uid;
|
|
10941
|
-
}
|
|
10942
|
-
function getAuth() {
|
|
10943
|
-
if (typeof configuration.auth === "string") {
|
|
10944
|
-
return {
|
|
10945
|
-
token: configuration.auth
|
|
10946
|
-
};
|
|
10947
|
-
}
|
|
10948
|
-
if (configuration.auth) {
|
|
10949
|
-
return configuration.auth;
|
|
10950
|
-
}
|
|
10951
|
-
if (Utils.isNode() && nodeStartingContext && nodeStartingContext.gwToken) {
|
|
10952
|
-
return {
|
|
10953
|
-
gatewayToken: nodeStartingContext.gwToken
|
|
10954
|
-
};
|
|
10955
|
-
}
|
|
10956
|
-
if (configuration.gateway?.webPlatform) {
|
|
10957
|
-
return {
|
|
10958
|
-
username: "glue42",
|
|
10959
|
-
password: ""
|
|
10960
|
-
};
|
|
10961
|
-
}
|
|
10962
|
-
}
|
|
10963
|
-
function getLogger() {
|
|
10964
|
-
let config = configuration.logger;
|
|
10965
|
-
const defaultLevel = "warn";
|
|
10966
|
-
if (!config) {
|
|
10967
|
-
config = defaultLevel;
|
|
10968
|
-
}
|
|
10969
|
-
let gdConsoleLevel;
|
|
10970
|
-
if (glue42gd) {
|
|
10971
|
-
gdConsoleLevel = glue42gd.consoleLogLevel;
|
|
10972
|
-
}
|
|
10973
|
-
if (typeof config === "string") {
|
|
10974
|
-
return { console: gdConsoleLevel ?? config, publish: defaultLevel };
|
|
10975
|
-
}
|
|
10976
|
-
return {
|
|
10977
|
-
console: gdConsoleLevel ?? config.console ?? defaultLevel,
|
|
10978
|
-
publish: config.publish ?? defaultLevel
|
|
10979
|
-
};
|
|
10980
|
-
}
|
|
10981
|
-
const connection = getConnection();
|
|
10982
|
-
let application = getApplication();
|
|
10983
|
-
if (typeof window !== "undefined") {
|
|
10984
|
-
const windowAsAny = window;
|
|
10985
|
-
const containerApplication = windowAsAny.htmlContainer ?
|
|
10986
|
-
`${windowAsAny.htmlContainer.containerName}.${windowAsAny.htmlContainer.application}` :
|
|
10987
|
-
windowAsAny?.glue42gd?.application;
|
|
10988
|
-
if (containerApplication) {
|
|
10989
|
-
application = containerApplication;
|
|
10990
|
-
}
|
|
10991
|
-
}
|
|
10992
|
-
return {
|
|
10993
|
-
bus: configuration.bus ?? false,
|
|
10994
|
-
application,
|
|
10995
|
-
auth: getAuth(),
|
|
10996
|
-
logger: getLogger(),
|
|
10997
|
-
connection,
|
|
10998
|
-
metrics: configuration.metrics ?? true,
|
|
10999
|
-
contexts: getContexts(),
|
|
11000
|
-
version: ext.version || version,
|
|
11001
|
-
libs: ext.libs ?? [],
|
|
11002
|
-
customLogger: configuration.customLogger
|
|
11003
|
-
};
|
|
10836
|
+
return true;
|
|
11004
10837
|
}
|
|
11005
10838
|
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
10839
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
10840
|
+
return isNonNullObject(value)
|
|
10841
|
+
&& !isSpecial(value)
|
|
10842
|
+
};
|
|
10843
|
+
|
|
10844
|
+
function isNonNullObject(value) {
|
|
10845
|
+
return !!value && typeof value === 'object'
|
|
10846
|
+
}
|
|
10847
|
+
|
|
10848
|
+
function isSpecial(value) {
|
|
10849
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
10850
|
+
|
|
10851
|
+
return stringValue === '[object RegExp]'
|
|
10852
|
+
|| stringValue === '[object Date]'
|
|
10853
|
+
|| isReactElement(value)
|
|
10854
|
+
}
|
|
10855
|
+
|
|
10856
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
10857
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
10858
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
10859
|
+
|
|
10860
|
+
function isReactElement(value) {
|
|
10861
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
10862
|
+
}
|
|
10863
|
+
|
|
10864
|
+
function emptyTarget(val) {
|
|
10865
|
+
return Array.isArray(val) ? [] : {}
|
|
10866
|
+
}
|
|
10867
|
+
|
|
10868
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
10869
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
10870
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
10871
|
+
: value
|
|
10872
|
+
}
|
|
10873
|
+
|
|
10874
|
+
function defaultArrayMerge(target, source, options) {
|
|
10875
|
+
return target.concat(source).map(function(element) {
|
|
10876
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
10877
|
+
})
|
|
10878
|
+
}
|
|
10879
|
+
|
|
10880
|
+
function getMergeFunction(key, options) {
|
|
10881
|
+
if (!options.customMerge) {
|
|
10882
|
+
return deepmerge
|
|
10883
|
+
}
|
|
10884
|
+
var customMerge = options.customMerge(key);
|
|
10885
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
10886
|
+
}
|
|
10887
|
+
|
|
10888
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
10889
|
+
return Object.getOwnPropertySymbols
|
|
10890
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
10891
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
10892
|
+
})
|
|
10893
|
+
: []
|
|
10894
|
+
}
|
|
10895
|
+
|
|
10896
|
+
function getKeys(target) {
|
|
10897
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
10898
|
+
}
|
|
10899
|
+
|
|
10900
|
+
function propertyIsOnObject(object, property) {
|
|
10901
|
+
try {
|
|
10902
|
+
return property in object
|
|
10903
|
+
} catch(_) {
|
|
10904
|
+
return false
|
|
10905
|
+
}
|
|
10906
|
+
}
|
|
10907
|
+
|
|
10908
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
10909
|
+
function propertyIsUnsafe(target, key) {
|
|
10910
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
10911
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
10912
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
10913
|
+
}
|
|
10914
|
+
|
|
10915
|
+
function mergeObject(target, source, options) {
|
|
10916
|
+
var destination = {};
|
|
10917
|
+
if (options.isMergeableObject(target)) {
|
|
10918
|
+
getKeys(target).forEach(function(key) {
|
|
10919
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
10920
|
+
});
|
|
10921
|
+
}
|
|
10922
|
+
getKeys(source).forEach(function(key) {
|
|
10923
|
+
if (propertyIsUnsafe(target, key)) {
|
|
10924
|
+
return
|
|
10925
|
+
}
|
|
10926
|
+
|
|
10927
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
10928
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
10929
|
+
} else {
|
|
10930
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
10931
|
+
}
|
|
10932
|
+
});
|
|
10933
|
+
return destination
|
|
10934
|
+
}
|
|
10935
|
+
|
|
10936
|
+
function deepmerge(target, source, options) {
|
|
10937
|
+
options = options || {};
|
|
10938
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
10939
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
10940
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
10941
|
+
// implementations can use it. The caller may not replace it.
|
|
10942
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
10943
|
+
|
|
10944
|
+
var sourceIsArray = Array.isArray(source);
|
|
10945
|
+
var targetIsArray = Array.isArray(target);
|
|
10946
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
10947
|
+
|
|
10948
|
+
if (!sourceAndTargetTypesMatch) {
|
|
10949
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
10950
|
+
} else if (sourceIsArray) {
|
|
10951
|
+
return options.arrayMerge(target, source, options)
|
|
10952
|
+
} else {
|
|
10953
|
+
return mergeObject(target, source, options)
|
|
10954
|
+
}
|
|
10955
|
+
}
|
|
10956
|
+
|
|
10957
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
10958
|
+
if (!Array.isArray(array)) {
|
|
10959
|
+
throw new Error('first argument should be an array')
|
|
10960
|
+
}
|
|
10961
|
+
|
|
10962
|
+
return array.reduce(function(prev, next) {
|
|
10963
|
+
return deepmerge(prev, next, options)
|
|
10964
|
+
}, {})
|
|
10965
|
+
};
|
|
10966
|
+
|
|
10967
|
+
var deepmerge_1 = deepmerge;
|
|
10968
|
+
|
|
10969
|
+
var cjs = deepmerge_1;
|
|
10970
|
+
|
|
10971
|
+
var deepMerge = /*@__PURE__*/getDefaultExportFromCjs(cjs);
|
|
10972
|
+
|
|
10973
|
+
var dist = {};
|
|
10974
|
+
|
|
10975
|
+
var builder$2 = {};
|
|
10976
|
+
|
|
10977
|
+
var builder$1 = {};
|
|
10978
|
+
|
|
10979
|
+
var nullMetricsManager = {};
|
|
10980
|
+
|
|
10981
|
+
var nullManager$1 = {};
|
|
10982
|
+
|
|
10983
|
+
Object.defineProperty(nullManager$1, "__esModule", { value: true });
|
|
10984
|
+
nullManager$1.NullManager = void 0;
|
|
10985
|
+
class NullManager {
|
|
10986
|
+
constructor() {
|
|
10987
|
+
this.started = false;
|
|
10988
|
+
}
|
|
10989
|
+
waitForFinalExport(timeoutMs) {
|
|
10990
|
+
return Promise.resolve();
|
|
10991
|
+
}
|
|
10992
|
+
get settings() {
|
|
10993
|
+
return {};
|
|
10994
|
+
}
|
|
10995
|
+
start() {
|
|
10996
|
+
this.started = true;
|
|
10997
|
+
return Promise.resolve();
|
|
10998
|
+
}
|
|
10999
|
+
stop() {
|
|
11000
|
+
this.started = false;
|
|
11001
|
+
return Promise.resolve();
|
|
11002
|
+
}
|
|
11003
|
+
}
|
|
11004
|
+
nullManager$1.NullManager = NullManager;
|
|
11005
|
+
|
|
11006
|
+
var safeStringify$1 = {};
|
|
11007
|
+
|
|
11008
|
+
var isPlainObject$1 = {};
|
|
11009
|
+
|
|
11010
|
+
// https://github.com/jonschlinkert/is-plain-object/blob/master/is-plain-object.js
|
|
11011
|
+
// cf204a3
|
|
11012
|
+
Object.defineProperty(isPlainObject$1, "__esModule", { value: true });
|
|
11013
|
+
isPlainObject$1.isPlainObject = void 0;
|
|
11014
|
+
/*!
|
|
11015
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
11016
|
+
*
|
|
11017
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
11018
|
+
* Released under the MIT License.
|
|
11019
|
+
*/
|
|
11020
|
+
function isObject(o) {
|
|
11021
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
11022
|
+
}
|
|
11023
|
+
function isPlainObject(o) {
|
|
11024
|
+
let ctor;
|
|
11025
|
+
let prot;
|
|
11026
|
+
if (isObject(o) === false)
|
|
11027
|
+
return false;
|
|
11028
|
+
// If has modified constructor
|
|
11029
|
+
ctor = o.constructor;
|
|
11030
|
+
if (ctor === undefined)
|
|
11031
|
+
return true;
|
|
11032
|
+
// If has modified prototype
|
|
11033
|
+
prot = ctor.prototype;
|
|
11034
|
+
if (isObject(prot) === false)
|
|
11035
|
+
return false;
|
|
11036
|
+
// If constructor does not have an Object-specific method
|
|
11037
|
+
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
11038
|
+
return false;
|
|
11039
|
+
}
|
|
11040
|
+
// Most likely a plain Object
|
|
11041
|
+
return true;
|
|
11042
|
+
}
|
|
11043
|
+
isPlainObject$1.isPlainObject = isPlainObject;
|
|
11044
|
+
|
|
11045
|
+
Object.defineProperty(safeStringify$1, "__esModule", { value: true });
|
|
11046
|
+
safeStringify$1.safeStringify = void 0;
|
|
11047
|
+
const is_plain_object_1 = isPlainObject$1;
|
|
11048
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11049
|
+
function safeStringify(obj) {
|
|
11050
|
+
if (!obj) {
|
|
11051
|
+
return JSON.stringify(obj);
|
|
11052
|
+
}
|
|
11053
|
+
return JSON.stringify(obj, (k, v) => {
|
|
11054
|
+
if (!v || typeof v !== "object")
|
|
11055
|
+
return v;
|
|
11056
|
+
if (!(0, is_plain_object_1.isPlainObject)(v))
|
|
11057
|
+
return Object.prototype.toString.call(v);
|
|
11058
|
+
return v;
|
|
11059
|
+
});
|
|
11060
|
+
}
|
|
11061
|
+
safeStringify$1.safeStringify = safeStringify;
|
|
11062
|
+
|
|
11063
|
+
var _null$1 = {};
|
|
11064
|
+
|
|
11065
|
+
Object.defineProperty(_null$1, "__esModule", { value: true });
|
|
11066
|
+
_null$1.NullMetric = void 0;
|
|
11067
|
+
class NullMetric {
|
|
11068
|
+
constructor(settings, logger) {
|
|
11069
|
+
this.settings = settings;
|
|
11070
|
+
this.logger = logger;
|
|
11071
|
+
this.started = false;
|
|
11072
|
+
}
|
|
11073
|
+
start() {
|
|
11074
|
+
var _a;
|
|
11075
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`null metric has been started instead of ${this.settings.type} one`);
|
|
11076
|
+
this.started = true;
|
|
11077
|
+
return Promise.resolve();
|
|
11078
|
+
}
|
|
11079
|
+
stop() {
|
|
11080
|
+
var _a;
|
|
11081
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`null metric has been stopped instead of ${this.settings.type} one`);
|
|
11082
|
+
this.started = false;
|
|
11083
|
+
return Promise.resolve();
|
|
11084
|
+
}
|
|
11085
|
+
add() { }
|
|
11086
|
+
record() { }
|
|
11087
|
+
}
|
|
11088
|
+
_null$1.NullMetric = NullMetric;
|
|
11089
|
+
|
|
11090
|
+
Object.defineProperty(nullMetricsManager, "__esModule", { value: true });
|
|
11091
|
+
nullMetricsManager.NullMetricsManager = void 0;
|
|
11092
|
+
const nullManager_1$2 = nullManager$1;
|
|
11093
|
+
const safe_stringify_1$2 = safeStringify$1;
|
|
11094
|
+
const null_1 = _null$1;
|
|
11095
|
+
class NullMetricsManager extends nullManager_1$2.NullManager {
|
|
11096
|
+
constructor(settings, otelSettings, logger) {
|
|
11097
|
+
if ((otelSettings === null || otelSettings === void 0 ? void 0 : otelSettings.logSettingsOnStartup) !== false) {
|
|
11098
|
+
logger === null || logger === void 0 ? void 0 : logger.info(`Starting NullMetrcsManager with settings ${(0, safe_stringify_1$2.safeStringify)(settings)}`);
|
|
11099
|
+
}
|
|
11100
|
+
super();
|
|
11101
|
+
}
|
|
11102
|
+
waitForFinalExport(timeoutMs) {
|
|
11103
|
+
return Promise.resolve();
|
|
11104
|
+
}
|
|
11105
|
+
getFromSettings(settings) {
|
|
11106
|
+
return new null_1.NullMetric(settings);
|
|
11107
|
+
}
|
|
11108
|
+
get(type) {
|
|
11109
|
+
return new null_1.NullMetric({ name: type, type, enabled: false, description: type });
|
|
11110
|
+
}
|
|
11111
|
+
}
|
|
11112
|
+
nullMetricsManager.NullMetricsManager = NullMetricsManager;
|
|
11113
|
+
|
|
11114
|
+
var hasRequiredBuilder$2;
|
|
11115
|
+
|
|
11116
|
+
function requireBuilder$2 () {
|
|
11117
|
+
if (hasRequiredBuilder$2) return builder$1;
|
|
11118
|
+
hasRequiredBuilder$2 = 1;
|
|
11119
|
+
Object.defineProperty(builder$1, "__esModule", { value: true });
|
|
11120
|
+
builder$1.MetricsManagerBuilder = void 0;
|
|
11121
|
+
const nullMetricsManager_1 = nullMetricsManager;
|
|
11122
|
+
const __1 = requireDist();
|
|
11123
|
+
class MetricsManagerBuilder {
|
|
11124
|
+
withLogger(logger) {
|
|
11125
|
+
this.logger = logger;
|
|
11126
|
+
return this;
|
|
11127
|
+
}
|
|
11128
|
+
withSettings(settings) {
|
|
11129
|
+
this.settings = settings;
|
|
11130
|
+
return this;
|
|
11131
|
+
}
|
|
11132
|
+
withMeterProvider(meterProviderCreateFunc) {
|
|
11133
|
+
this.meterProviderCreateFunc = meterProviderCreateFunc;
|
|
11134
|
+
return this;
|
|
11135
|
+
}
|
|
11136
|
+
withDependencyContainer(container) {
|
|
11137
|
+
this.dependencyContainer = container;
|
|
11138
|
+
return this;
|
|
11139
|
+
}
|
|
11140
|
+
build() {
|
|
11141
|
+
// const validator = new MetricsBuilderValidator();
|
|
11142
|
+
// validator.validate(this);
|
|
11143
|
+
return this.buildCore();
|
|
11144
|
+
}
|
|
11145
|
+
buildCore() {
|
|
11146
|
+
var _a, _b, _c, _d;
|
|
11147
|
+
let metricsPlugin;
|
|
11148
|
+
if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enabled) !== true ||
|
|
11149
|
+
((_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.metrics) === null || _c === void 0 ? void 0 : _c.enabled) !== true ||
|
|
11150
|
+
!(metricsPlugin = (0, __1.loadInsightsPlugin)("metrics", this.logger))) {
|
|
11151
|
+
return new nullMetricsManager_1.NullMetricsManager((_d = this.settings) === null || _d === void 0 ? void 0 : _d.metrics, this.settings, this.logger);
|
|
11152
|
+
}
|
|
11153
|
+
const manager = metricsPlugin.newMetricsManager(this.settings, this.dependencyContainer, this.meterProviderCreateFunc, this.logger);
|
|
11154
|
+
return manager;
|
|
11155
|
+
}
|
|
11156
|
+
}
|
|
11157
|
+
builder$1.MetricsManagerBuilder = MetricsManagerBuilder;
|
|
11158
|
+
|
|
11159
|
+
return builder$1;
|
|
11160
|
+
}
|
|
11161
|
+
|
|
11162
|
+
var builder = {};
|
|
11163
|
+
|
|
11164
|
+
var nullTracesManager = {};
|
|
11165
|
+
|
|
11166
|
+
var nullTracingState = {};
|
|
11167
|
+
|
|
11168
|
+
Object.defineProperty(nullTracingState, "__esModule", { value: true });
|
|
11169
|
+
class NullTracingState {
|
|
11170
|
+
constructor(source, propagationInfo, disablePropagation) {
|
|
11171
|
+
this.source = source;
|
|
11172
|
+
this.propagationInfo = propagationInfo;
|
|
11173
|
+
this.disablePropagation = disablePropagation;
|
|
11174
|
+
this.currentSpanStatus = { code: 0 /*SpanStatusCode.UNSET*/ };
|
|
11175
|
+
this.level = "OFF";
|
|
11176
|
+
}
|
|
11177
|
+
endSpan() {
|
|
11178
|
+
return Promise.resolve();
|
|
11179
|
+
}
|
|
11180
|
+
get enabled() {
|
|
11181
|
+
return false;
|
|
11182
|
+
}
|
|
11183
|
+
get id() {
|
|
11184
|
+
return undefined;
|
|
11185
|
+
}
|
|
11186
|
+
get traceId() {
|
|
11187
|
+
return undefined;
|
|
11188
|
+
}
|
|
11189
|
+
set status(status) {
|
|
11190
|
+
this.currentSpanStatus = Object.assign({}, status);
|
|
11191
|
+
}
|
|
11192
|
+
get status() {
|
|
11193
|
+
return this.currentSpanStatus;
|
|
11194
|
+
}
|
|
11195
|
+
addEvent(name, attributesOrStartTime, startTime) {
|
|
11196
|
+
return this;
|
|
11197
|
+
}
|
|
11198
|
+
recordException(exception, time) { }
|
|
11199
|
+
isRecording() {
|
|
11200
|
+
return false;
|
|
11201
|
+
}
|
|
11202
|
+
updateName(name) {
|
|
11203
|
+
return this;
|
|
11204
|
+
}
|
|
11205
|
+
spanContext() {
|
|
11206
|
+
return undefined;
|
|
11207
|
+
}
|
|
11208
|
+
addData(level, data) {
|
|
11209
|
+
}
|
|
11210
|
+
end() { }
|
|
11211
|
+
getPropagationInfo() {
|
|
11212
|
+
if (this.propagationInfo) {
|
|
11213
|
+
return this.propagationInfo;
|
|
11214
|
+
}
|
|
11215
|
+
return null;
|
|
11216
|
+
// // todo vnikolov: should we use otel's own context management at all?
|
|
11217
|
+
// const propagationInfo = { };
|
|
11218
|
+
// propagation.inject(context.active(), propagationInfo);
|
|
11219
|
+
// return propagationInfo;
|
|
11220
|
+
}
|
|
11221
|
+
injectPropagationInfo(carrier) {
|
|
11222
|
+
if (this.propagationInfo && !this.disablePropagation) {
|
|
11223
|
+
carrier.__interopIOTracePropagationInfo = this.propagationInfo;
|
|
11224
|
+
}
|
|
11225
|
+
}
|
|
11226
|
+
}
|
|
11227
|
+
nullTracingState.default = NullTracingState;
|
|
11228
|
+
|
|
11229
|
+
var traces = {};
|
|
11230
|
+
|
|
11231
|
+
var otelUtils = {};
|
|
11232
|
+
|
|
11233
|
+
var container = {};
|
|
11234
|
+
|
|
11235
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11236
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11237
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11238
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11239
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11240
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11241
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11242
|
+
});
|
|
11243
|
+
};
|
|
11244
|
+
Object.defineProperty(container, "__esModule", { value: true });
|
|
11245
|
+
container.Container = void 0;
|
|
11246
|
+
const safe_stringify_1$1 = safeStringify$1;
|
|
11247
|
+
class Container {
|
|
11248
|
+
static get instance() {
|
|
11249
|
+
var _a, _b;
|
|
11250
|
+
return (_a = Container._instance) !== null && _a !== void 0 ? _a : (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _b === void 0 ? void 0 : _b.instance;
|
|
11251
|
+
}
|
|
11252
|
+
static errorless(callback, defaultValue) {
|
|
11253
|
+
try {
|
|
11254
|
+
if (typeof callback !== "function") {
|
|
11255
|
+
return callback;
|
|
11256
|
+
}
|
|
11257
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
11258
|
+
const toReturn = callback();
|
|
11259
|
+
return toReturn;
|
|
11260
|
+
}
|
|
11261
|
+
catch (err) {
|
|
11262
|
+
return Container.handleErrorlessMode(err, defaultValue);
|
|
11263
|
+
}
|
|
11264
|
+
}
|
|
11265
|
+
static errorlessDefined(callback, defaultValue) {
|
|
11266
|
+
try {
|
|
11267
|
+
if (typeof callback !== "function") {
|
|
11268
|
+
return callback;
|
|
11269
|
+
}
|
|
11270
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
11271
|
+
const toReturn = callback();
|
|
11272
|
+
return toReturn;
|
|
11273
|
+
}
|
|
11274
|
+
catch (err) {
|
|
11275
|
+
return Container.handleErrorlessMode(err, defaultValue);
|
|
11276
|
+
}
|
|
11277
|
+
}
|
|
11278
|
+
static errorlessAsync(callback, defaultValue) {
|
|
11279
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11280
|
+
try {
|
|
11281
|
+
if (typeof callback !== "function") {
|
|
11282
|
+
return callback;
|
|
11283
|
+
}
|
|
11284
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
11285
|
+
const toReturn = (yield callback)();
|
|
11286
|
+
return toReturn;
|
|
11287
|
+
}
|
|
11288
|
+
catch (err) {
|
|
11289
|
+
return Container.handleErrorlessMode(err, defaultValue);
|
|
11290
|
+
}
|
|
11291
|
+
});
|
|
11292
|
+
}
|
|
11293
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11294
|
+
static handleErrorlessMode(err, defaultValue) {
|
|
11295
|
+
var _a, _b, _c, _d, _e;
|
|
11296
|
+
let message = undefined;
|
|
11297
|
+
try {
|
|
11298
|
+
if (err === null || err === void 0 ? void 0 : err.message) {
|
|
11299
|
+
message = (err === null || err === void 0 ? void 0 : err.message) + " " + ((_a = err === null || err === void 0 ? void 0 : err.stack) !== null && _a !== void 0 ? _a : new Error().stack);
|
|
11300
|
+
}
|
|
11301
|
+
if (!message) {
|
|
11302
|
+
try {
|
|
11303
|
+
message = (0, safe_stringify_1$1.safeStringify)(err) + " " + new Error().stack;
|
|
11304
|
+
}
|
|
11305
|
+
catch ( /*silent catch*/_f) { /*silent catch*/ }
|
|
11306
|
+
}
|
|
11307
|
+
if (!message) {
|
|
11308
|
+
try {
|
|
11309
|
+
message = (err === null || err === void 0 ? void 0 : err.toString()) + " " + new Error().stack;
|
|
11310
|
+
}
|
|
11311
|
+
catch ( /*silent catch*/_g) { /*silent catch*/ }
|
|
11312
|
+
}
|
|
11313
|
+
}
|
|
11314
|
+
catch ( /*silent catch*/_h) { /*silent catch*/ }
|
|
11315
|
+
if (!message) {
|
|
11316
|
+
message = "unknown " + new Error().stack;
|
|
11317
|
+
}
|
|
11318
|
+
try {
|
|
11319
|
+
if (!((_c = (_b = Container.instance) === null || _b === void 0 ? void 0 : _b.settings) === null || _c === void 0 ? void 0 : _c.errorlessMode)) {
|
|
11320
|
+
(_d = Container.instance.logger) === null || _d === void 0 ? void 0 : _d.error("Observed error " + message);
|
|
11321
|
+
throw err;
|
|
11322
|
+
}
|
|
11323
|
+
}
|
|
11324
|
+
catch (_j) {
|
|
11325
|
+
throw err;
|
|
11326
|
+
}
|
|
11327
|
+
try {
|
|
11328
|
+
(_e = Container.instance.logger) === null || _e === void 0 ? void 0 : _e.warn("Caught error " + message);
|
|
11329
|
+
return defaultValue;
|
|
11330
|
+
}
|
|
11331
|
+
catch (_k) {
|
|
11332
|
+
return defaultValue;
|
|
11333
|
+
}
|
|
11334
|
+
}
|
|
11335
|
+
constructor(_settings, _traces, metrics, logs, logger) {
|
|
11336
|
+
var _a;
|
|
11337
|
+
this._settings = _settings;
|
|
11338
|
+
this._traces = _traces;
|
|
11339
|
+
this.metrics = metrics;
|
|
11340
|
+
this.logs = logs;
|
|
11341
|
+
this.logger = logger;
|
|
11342
|
+
this.started = false;
|
|
11343
|
+
// const validator = new ContainerValidator();
|
|
11344
|
+
// validator.validate(this);
|
|
11345
|
+
Container._instance = this;
|
|
11346
|
+
globalThis.ioInsightsInternals = (_a = globalThis.ioInsightsInternals) !== null && _a !== void 0 ? _a : {};
|
|
11347
|
+
globalThis.ioInsightsInternals.instance = this;
|
|
11348
|
+
}
|
|
11349
|
+
get traces() {
|
|
11350
|
+
var _a, _b;
|
|
11351
|
+
if ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.traces) {
|
|
11352
|
+
return (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _b === void 0 ? void 0 : _b.traces;
|
|
11353
|
+
}
|
|
11354
|
+
return this._traces;
|
|
11355
|
+
}
|
|
11356
|
+
waitForFinalExport(timeoutMs) {
|
|
11357
|
+
var _a, _b, _c;
|
|
11358
|
+
return Promise.allSettled([
|
|
11359
|
+
(_a = this.traces) === null || _a === void 0 ? void 0 : _a.waitForFinalExport(timeoutMs),
|
|
11360
|
+
(_b = this.metrics) === null || _b === void 0 ? void 0 : _b.waitForFinalExport(timeoutMs),
|
|
11361
|
+
(_c = this.logs) === null || _c === void 0 ? void 0 : _c.waitForFinalExport(timeoutMs)
|
|
11362
|
+
]);
|
|
11363
|
+
}
|
|
11364
|
+
get settings() {
|
|
11365
|
+
return this._settings;
|
|
11366
|
+
}
|
|
11367
|
+
start() {
|
|
11368
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11369
|
+
// vnikolov TODO: maybe log this? don't silently refuse to start
|
|
11370
|
+
const metricsPromise = this.metrics.settings.enabled ? this.metrics.start() : Promise.resolve();
|
|
11371
|
+
const tracesPromise = this.traces.settings.enabled ? this.traces.start() : Promise.resolve();
|
|
11372
|
+
const logsPromise = this.logs.settings.enabled ? this.logs.start() : Promise.resolve();
|
|
11373
|
+
yield Promise.all([metricsPromise, tracesPromise, logsPromise]);
|
|
11374
|
+
this.started = true;
|
|
11375
|
+
});
|
|
11376
|
+
}
|
|
11377
|
+
stop() {
|
|
11378
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11379
|
+
const metricsPromise = this.metrics.started ? this.metrics.stop() : Promise.resolve();
|
|
11380
|
+
const tracesPromise = this.traces.started ? this.traces.stop() : Promise.resolve();
|
|
11381
|
+
const logsPromise = this.logs.started ? this.logs.stop() : Promise.resolve();
|
|
11382
|
+
yield Promise.all([metricsPromise, tracesPromise, logsPromise]);
|
|
11383
|
+
this.started = false;
|
|
11384
|
+
});
|
|
11385
|
+
}
|
|
11386
|
+
}
|
|
11387
|
+
container.Container = Container;
|
|
11388
|
+
|
|
11389
|
+
(function (exports) {
|
|
11390
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11391
|
+
exports.extractFilteringContextFromArgs = exports.deep_value = exports.getOTELData = exports.flattenOtelAtributes = void 0;
|
|
11392
|
+
const container_1 = container;
|
|
11393
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11394
|
+
const flattenOtelAtributes = (data, maxDepth) => {
|
|
11395
|
+
if (data === undefined ||
|
|
11396
|
+
data === null) {
|
|
11397
|
+
return {};
|
|
11398
|
+
}
|
|
11399
|
+
if (typeof data !== "object") {
|
|
11400
|
+
data = { unknownAttribute: data };
|
|
11401
|
+
}
|
|
11402
|
+
const toReturn = {};
|
|
11403
|
+
for (const [key, value] of Object.entries(data)) {
|
|
11404
|
+
const otelValues = (0, exports.getOTELData)(key, value, 0, maxDepth);
|
|
11405
|
+
for (const [otelKey, otelValue] of otelValues) {
|
|
11406
|
+
toReturn[otelKey] = otelValue;
|
|
11407
|
+
}
|
|
11408
|
+
}
|
|
11409
|
+
return toReturn;
|
|
11410
|
+
};
|
|
11411
|
+
exports.flattenOtelAtributes = flattenOtelAtributes;
|
|
11412
|
+
const getOTELData = (key, value, depth, maxDepth) => {
|
|
11413
|
+
depth += 1;
|
|
11414
|
+
if (depth > maxDepth) {
|
|
11415
|
+
return [[key, "<depth exceeded>"]];
|
|
11416
|
+
}
|
|
11417
|
+
const isObject = Boolean(value && typeof value === "object");
|
|
11418
|
+
const isValidPrimitiveValue = typeof value === "number" || typeof value === "string" || typeof value === "boolean";
|
|
11419
|
+
if (isValidPrimitiveValue) {
|
|
11420
|
+
return [[key, value]];
|
|
11421
|
+
}
|
|
11422
|
+
if (isAttributeArray(value)) {
|
|
11423
|
+
return [[key, value]].concat(flatten(key, value, depth, maxDepth));
|
|
11424
|
+
}
|
|
11425
|
+
else if (isObject) {
|
|
11426
|
+
return flatten(key, value, depth, maxDepth);
|
|
11427
|
+
}
|
|
11428
|
+
else if (typeof value === "function") {
|
|
11429
|
+
return [];
|
|
11430
|
+
}
|
|
11431
|
+
else if (value) {
|
|
11432
|
+
return [[key, value + ""]];
|
|
11433
|
+
}
|
|
11434
|
+
else {
|
|
11435
|
+
return [];
|
|
11436
|
+
}
|
|
11437
|
+
};
|
|
11438
|
+
exports.getOTELData = getOTELData;
|
|
11439
|
+
const flatten = (key, obj, depth, maxDepth) => {
|
|
11440
|
+
const toReturn = [];
|
|
11441
|
+
for (const [key2, val2] of Object.entries(obj)) {
|
|
11442
|
+
for (const [key3, val3] of (0, exports.getOTELData)(key2, val2, depth, maxDepth)) {
|
|
11443
|
+
toReturn.push([key + "." + key3, val3]);
|
|
11444
|
+
}
|
|
11445
|
+
}
|
|
11446
|
+
return toReturn;
|
|
11447
|
+
};
|
|
11448
|
+
const isAttributeArray = (value) => {
|
|
11449
|
+
if (!Array.isArray(value)) {
|
|
11450
|
+
return false;
|
|
11451
|
+
}
|
|
11452
|
+
return value.every((item) => item === null ||
|
|
11453
|
+
item === undefined ||
|
|
11454
|
+
typeof item === "string" ||
|
|
11455
|
+
typeof item === "number" ||
|
|
11456
|
+
typeof item === "boolean");
|
|
11457
|
+
};
|
|
11458
|
+
// todo vnikolov: document all the places where deep_value is used in the spec, as well
|
|
11459
|
+
// as the regex matches
|
|
11460
|
+
const deep_value = function (obj, path) {
|
|
11461
|
+
// eslint-disable-next-line no-var
|
|
11462
|
+
if (!path) {
|
|
11463
|
+
return null;
|
|
11464
|
+
}
|
|
11465
|
+
// eslint-disable-next-line no-var
|
|
11466
|
+
for (var i = 0, path = path.split("."), len = path.length; i < len; i++) {
|
|
11467
|
+
if (obj === null || obj === undefined) {
|
|
11468
|
+
return undefined;
|
|
11469
|
+
}
|
|
11470
|
+
obj = obj[path[i]];
|
|
11471
|
+
}
|
|
11472
|
+
return obj;
|
|
11473
|
+
};
|
|
11474
|
+
exports.deep_value = deep_value;
|
|
11475
|
+
// https://stackoverflow.com/a/8817473
|
|
11476
|
+
const extractFilteringContextFromArgs = (template, args, that) => {
|
|
11477
|
+
let filteringContext = {};
|
|
11478
|
+
if (typeof template.thisMapping === "function") {
|
|
11479
|
+
filteringContext = Object.assign(Object.assign({}, filteringContext), container_1.Container.errorless(() => template.thisMapping.apply(that, [that])));
|
|
11480
|
+
}
|
|
11481
|
+
else {
|
|
11482
|
+
Object.keys(template.thisMapping || {}).forEach((keyOrPath) => {
|
|
11483
|
+
if (!keyOrPath || !template.thisMapping) {
|
|
11484
|
+
return;
|
|
11485
|
+
}
|
|
11486
|
+
const filteringContextKey = template.thisMapping[keyOrPath];
|
|
11487
|
+
filteringContext[filteringContextKey] = (0, exports.deep_value)(that, keyOrPath);
|
|
11488
|
+
});
|
|
11489
|
+
}
|
|
11490
|
+
if (typeof template.argMapping === "function") {
|
|
11491
|
+
filteringContext = Object.assign(Object.assign({}, filteringContext), container_1.Container.errorless(() => template.argMapping.apply(that, args)));
|
|
11492
|
+
}
|
|
11493
|
+
else {
|
|
11494
|
+
Object.keys(template.argMapping || {}).forEach((keyOrPath) => {
|
|
11495
|
+
if (!keyOrPath || !template.argMapping) {
|
|
11496
|
+
return;
|
|
11497
|
+
}
|
|
11498
|
+
const filteringContextKey = template.argMapping[keyOrPath];
|
|
11499
|
+
const value = (0, exports.deep_value)(args, keyOrPath);
|
|
11500
|
+
if (typeof value === "string" ||
|
|
11501
|
+
typeof value === "number") {
|
|
11502
|
+
filteringContext[filteringContextKey] = value;
|
|
11503
|
+
}
|
|
11504
|
+
});
|
|
11505
|
+
}
|
|
11506
|
+
return filteringContext;
|
|
11507
|
+
};
|
|
11508
|
+
exports.extractFilteringContextFromArgs = extractFilteringContextFromArgs;
|
|
11509
|
+
|
|
11510
|
+
} (otelUtils));
|
|
11511
|
+
|
|
11512
|
+
var hasRequiredTraces;
|
|
11513
|
+
|
|
11514
|
+
function requireTraces () {
|
|
11515
|
+
if (hasRequiredTraces) return traces;
|
|
11516
|
+
hasRequiredTraces = 1;
|
|
11517
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
11518
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11519
|
+
};
|
|
11520
|
+
Object.defineProperty(traces, "__esModule", { value: true });
|
|
11521
|
+
traces.withSpan = void 0;
|
|
11522
|
+
const otelUtils_1 = otelUtils;
|
|
11523
|
+
const nullTracesManager_1 = requireNullTracesManager();
|
|
11524
|
+
const nullTracingState_1 = __importDefault(nullTracingState);
|
|
11525
|
+
/**
|
|
11526
|
+
* Null-safe singleton class that can be invoked even if you haven't initialized
|
|
11527
|
+
* the library (yet?), or if you don't have access to the current manager instance.
|
|
11528
|
+
*/
|
|
11529
|
+
class Traces {
|
|
11530
|
+
static get instance() {
|
|
11531
|
+
var _a, _b;
|
|
11532
|
+
if ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.traces) {
|
|
11533
|
+
return (_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.ioInsightsInternals) === null || _b === void 0 ? void 0 : _b.traces;
|
|
11534
|
+
}
|
|
11535
|
+
if (!Traces._instance) {
|
|
11536
|
+
Traces._instance = new nullTracesManager_1.NullTracesManager(undefined, undefined, undefined);
|
|
11537
|
+
}
|
|
11538
|
+
return Traces._instance;
|
|
11539
|
+
}
|
|
11540
|
+
static set instance(value) {
|
|
11541
|
+
Traces._instance = value;
|
|
11542
|
+
}
|
|
11543
|
+
static get currentTracingState() {
|
|
11544
|
+
var _a;
|
|
11545
|
+
return ((_a = Traces.instance) === null || _a === void 0 ? void 0 : _a.currentTracingState) || new nullTracingState_1.default("unknown", null, true);
|
|
11546
|
+
}
|
|
11547
|
+
static set currentTracingState(value) {
|
|
11548
|
+
if (Traces.instance) {
|
|
11549
|
+
Traces.instance.currentTracingState = value;
|
|
11550
|
+
}
|
|
11551
|
+
}
|
|
11552
|
+
static removePropagationInfo(propagationInfoCarrier) {
|
|
11553
|
+
Traces.extractPropagationInfo(propagationInfoCarrier, true);
|
|
11554
|
+
return propagationInfoCarrier;
|
|
11555
|
+
}
|
|
11556
|
+
static extractPropagationInfo(propagationInfoCarrier, deleteProperty) {
|
|
11557
|
+
if (propagationInfoCarrier === null || propagationInfoCarrier === void 0 ? void 0 : propagationInfoCarrier.traceparent) {
|
|
11558
|
+
return propagationInfoCarrier;
|
|
11559
|
+
}
|
|
11560
|
+
const nestedPropagationInfo = propagationInfoCarrier === null || propagationInfoCarrier === void 0 ? void 0 : propagationInfoCarrier.__interopIOTracePropagationInfo;
|
|
11561
|
+
if (nestedPropagationInfo) {
|
|
11562
|
+
if (deleteProperty === true) {
|
|
11563
|
+
delete propagationInfoCarrier.__interopIOTracePropagationInfo;
|
|
11564
|
+
}
|
|
11565
|
+
return nestedPropagationInfo;
|
|
11566
|
+
}
|
|
11567
|
+
else {
|
|
11568
|
+
return null;
|
|
11569
|
+
}
|
|
11570
|
+
}
|
|
11571
|
+
static withSpan(source, filteringContextOrDecoratorOptionsOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
|
|
11572
|
+
// decorator or wrapping a function
|
|
11573
|
+
if (!(filteringContextOrDecoratorOptionsOrCallback instanceof Function) &&
|
|
11574
|
+
(!filteringContextOrDecoratorOptionsOrCallback ||
|
|
11575
|
+
filteringContextOrDecoratorOptionsOrCallback.argMapping ||
|
|
11576
|
+
filteringContextOrDecoratorOptionsOrCallback.thisMapping ||
|
|
11577
|
+
filteringContextOrDecoratorOptionsOrCallback.defaults) &&
|
|
11578
|
+
!propagationInfoOrCallback &&
|
|
11579
|
+
!optionsOrCallback &&
|
|
11580
|
+
!callback) {
|
|
11581
|
+
return function (target, propertyKey, descriptor) {
|
|
11582
|
+
let originalFn;
|
|
11583
|
+
if (descriptor) {
|
|
11584
|
+
// decorator
|
|
11585
|
+
originalFn = descriptor.value;
|
|
11586
|
+
}
|
|
11587
|
+
else {
|
|
11588
|
+
// wrapping function directly
|
|
11589
|
+
originalFn = target;
|
|
11590
|
+
}
|
|
11591
|
+
let tracedFunction = function (...args) {
|
|
11592
|
+
return Traces.withSpan(source, filteringContextOrDecoratorOptionsOrCallback
|
|
11593
|
+
? (0, otelUtils_1.extractFilteringContextFromArgs)(filteringContextOrDecoratorOptionsOrCallback, args, this)
|
|
11594
|
+
: {}, null, filteringContextOrDecoratorOptionsOrCallback, () => {
|
|
11595
|
+
return originalFn.apply(this, args);
|
|
11596
|
+
});
|
|
11597
|
+
};
|
|
11598
|
+
if (Traces.isAsyncFunction(originalFn)) {
|
|
11599
|
+
// fix for interception API using toString() to check for async functions
|
|
11600
|
+
const inner = tracedFunction;
|
|
11601
|
+
tracedFunction = function __insightsAsyncTracedFunction(...args) {
|
|
11602
|
+
return inner.apply(this, args);
|
|
11603
|
+
};
|
|
11604
|
+
Object.defineProperty(tracedFunction, Symbol.toStringTag, {
|
|
11605
|
+
value: "AsyncFunction",
|
|
11606
|
+
configurable: true,
|
|
11607
|
+
});
|
|
11608
|
+
}
|
|
11609
|
+
if (descriptor) {
|
|
11610
|
+
descriptor.value = tracedFunction;
|
|
11611
|
+
}
|
|
11612
|
+
else {
|
|
11613
|
+
return tracedFunction;
|
|
11614
|
+
}
|
|
11615
|
+
};
|
|
11616
|
+
}
|
|
11617
|
+
return Traces.instance.withSpan(source, filteringContextOrDecoratorOptionsOrCallback, propagationInfoOrCallback, optionsOrCallback, callback);
|
|
11618
|
+
}
|
|
11619
|
+
static isAsyncFunction(value) {
|
|
11620
|
+
return value && {}.toString.call(value) === '[object AsyncFunction]';
|
|
11621
|
+
}
|
|
11622
|
+
static withSpans(tracingMap, objectToTrace) {
|
|
11623
|
+
for (const tracingMapPropertyName in tracingMap) {
|
|
11624
|
+
if (typeof objectToTrace[tracingMapPropertyName] === "function") {
|
|
11625
|
+
const originalMethod = objectToTrace[tracingMapPropertyName];
|
|
11626
|
+
const tracingMapPropertyValue = tracingMap[tracingMapPropertyName];
|
|
11627
|
+
if (!tracingMapPropertyValue) {
|
|
11628
|
+
continue;
|
|
11629
|
+
}
|
|
11630
|
+
let wrapperMaker;
|
|
11631
|
+
if (typeof tracingMapPropertyValue === "string") {
|
|
11632
|
+
wrapperMaker = Traces.withSpan(tracingMapPropertyValue);
|
|
11633
|
+
}
|
|
11634
|
+
else {
|
|
11635
|
+
wrapperMaker = Traces.withSpan(tracingMapPropertyValue.source, tracingMapPropertyValue.decoratorOptions);
|
|
11636
|
+
}
|
|
11637
|
+
objectToTrace[tracingMapPropertyName] = wrapperMaker(originalMethod);
|
|
11638
|
+
}
|
|
11639
|
+
}
|
|
11640
|
+
return objectToTrace;
|
|
11641
|
+
}
|
|
11642
|
+
}
|
|
11643
|
+
traces.default = Traces;
|
|
11644
|
+
traces.withSpan = Traces.withSpan;
|
|
11645
|
+
|
|
11646
|
+
return traces;
|
|
11647
|
+
}
|
|
11648
|
+
|
|
11649
|
+
var hasRequiredNullTracesManager;
|
|
11650
|
+
|
|
11651
|
+
function requireNullTracesManager () {
|
|
11652
|
+
if (hasRequiredNullTracesManager) return nullTracesManager;
|
|
11653
|
+
hasRequiredNullTracesManager = 1;
|
|
11654
|
+
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11655
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11656
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11657
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11658
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11659
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11660
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11661
|
+
});
|
|
11662
|
+
};
|
|
11663
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
11664
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11665
|
+
};
|
|
11666
|
+
Object.defineProperty(nullTracesManager, "__esModule", { value: true });
|
|
11667
|
+
nullTracesManager.NullTracesManager = void 0;
|
|
11668
|
+
const nullTracingState_1 = __importDefault(nullTracingState);
|
|
11669
|
+
const traces_1 = __importDefault(requireTraces());
|
|
11670
|
+
const nullManager_1 = nullManager$1;
|
|
11671
|
+
const safe_stringify_1 = safeStringify$1;
|
|
11672
|
+
class NullTracesManager extends nullManager_1.NullManager {
|
|
11673
|
+
get settings() {
|
|
11674
|
+
return this._settings || {};
|
|
11675
|
+
}
|
|
11676
|
+
set settings(value) {
|
|
11677
|
+
this._settings = value;
|
|
11678
|
+
}
|
|
11679
|
+
constructor(_settings, otelSettings, logger) {
|
|
11680
|
+
if ((otelSettings === null || otelSettings === void 0 ? void 0 : otelSettings.logSettingsOnStartup) !== false) {
|
|
11681
|
+
logger === null || logger === void 0 ? void 0 : logger.info(`Starting NullTracesManager with settings ${(0, safe_stringify_1.safeStringify)(_settings)}`);
|
|
11682
|
+
}
|
|
11683
|
+
super();
|
|
11684
|
+
this._settings = _settings;
|
|
11685
|
+
this.logger = logger;
|
|
11686
|
+
}
|
|
11687
|
+
withSequenceSpan(source, filteringContextOrCallback, optionsOrCallback, callback) {
|
|
11688
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11689
|
+
return this.withSequenceSpanEx(source, source + ".start", filteringContextOrCallback, optionsOrCallback, callback);
|
|
11690
|
+
});
|
|
11691
|
+
}
|
|
11692
|
+
withSequenceSpanEx(source, traceName, filteringContextOrCallback, optionsOrCallback, callback) {
|
|
11693
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11694
|
+
return this.withSpan(source, filteringContextOrCallback, null, optionsOrCallback, callback);
|
|
11695
|
+
});
|
|
11696
|
+
}
|
|
11697
|
+
get currentTracingState() {
|
|
11698
|
+
return new nullTracingState_1.default("nullTracingState", null, true);
|
|
11699
|
+
}
|
|
11700
|
+
set currentTracingState(ts) {
|
|
11701
|
+
}
|
|
11702
|
+
waitForFinalExport(timeoutMs) {
|
|
11703
|
+
return Promise.resolve();
|
|
11704
|
+
}
|
|
11705
|
+
withSpan(source, filteringContextOrCallback, propagationInfoOrCallback, optionsOrCallback, callback) {
|
|
11706
|
+
var _a;
|
|
11707
|
+
const actualCallback =
|
|
11708
|
+
// eslint-disable-next-line no-nested-ternary
|
|
11709
|
+
typeof filteringContextOrCallback === "function"
|
|
11710
|
+
? filteringContextOrCallback
|
|
11711
|
+
: typeof propagationInfoOrCallback === "function"
|
|
11712
|
+
? propagationInfoOrCallback
|
|
11713
|
+
: typeof optionsOrCallback === "function"
|
|
11714
|
+
? optionsOrCallback
|
|
11715
|
+
: callback;
|
|
11716
|
+
if (!actualCallback) {
|
|
11717
|
+
throw new Error("callback must be provided");
|
|
11718
|
+
}
|
|
11719
|
+
if (typeof actualCallback !== "function") {
|
|
11720
|
+
throw new Error("Callback must be a function, received " + typeof actualCallback);
|
|
11721
|
+
}
|
|
11722
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug("nullTracesManager.withSpan: " + source);
|
|
11723
|
+
// a null manager means no propagation
|
|
11724
|
+
// let extractedPI: PropagationInfo | null = null;
|
|
11725
|
+
// if (propagationInfoOrCallback) {
|
|
11726
|
+
// let propagationInfoCarrier = {};
|
|
11727
|
+
// if (!isFunctionType(propagationInfoOrCallback)) {
|
|
11728
|
+
// propagationInfoCarrier = { ...propagationInfoOrCallback };
|
|
11729
|
+
// }
|
|
11730
|
+
// extractedPI = Traces.extractPropagationInfo(propagationInfoCarrier);
|
|
11731
|
+
// } else {
|
|
11732
|
+
// extractedPI = Traces.currentTracingState?.getPropagationInfo() || null;
|
|
11733
|
+
// }
|
|
11734
|
+
// const nts = new NullTracingState(source, extractedPI);
|
|
11735
|
+
const nts = new nullTracingState_1.default(source, null, true);
|
|
11736
|
+
traces_1.default.currentTracingState = nts;
|
|
11737
|
+
try {
|
|
11738
|
+
return actualCallback(nts);
|
|
11739
|
+
}
|
|
11740
|
+
finally {
|
|
11741
|
+
traces_1.default.currentTracingState = null;
|
|
11742
|
+
}
|
|
11743
|
+
}
|
|
11744
|
+
setFilterConfig(filters) {
|
|
11745
|
+
}
|
|
11746
|
+
get startupTraceFinished() {
|
|
11747
|
+
return (() => { });
|
|
11748
|
+
}
|
|
11749
|
+
get userJourneyMarker() {
|
|
11750
|
+
return (() => { });
|
|
11751
|
+
}
|
|
11752
|
+
setUserJourneyMarker(userJourneyMarker) {
|
|
11753
|
+
}
|
|
11754
|
+
get clickstreamMarker() {
|
|
11755
|
+
return (() => { });
|
|
11756
|
+
}
|
|
11757
|
+
}
|
|
11758
|
+
nullTracesManager.NullTracesManager = NullTracesManager;
|
|
11759
|
+
|
|
11760
|
+
return nullTracesManager;
|
|
11761
|
+
}
|
|
11762
|
+
|
|
11763
|
+
var hasRequiredBuilder$1;
|
|
11764
|
+
|
|
11765
|
+
function requireBuilder$1 () {
|
|
11766
|
+
if (hasRequiredBuilder$1) return builder;
|
|
11767
|
+
hasRequiredBuilder$1 = 1;
|
|
11768
|
+
Object.defineProperty(builder, "__esModule", { value: true });
|
|
11769
|
+
builder.TracesManagerBuilder = void 0;
|
|
11770
|
+
const nullTracesManager_1 = requireNullTracesManager();
|
|
11771
|
+
const container_1 = container;
|
|
11772
|
+
const __1 = requireDist();
|
|
11773
|
+
class TracesManagerBuilder {
|
|
11774
|
+
constructor() {
|
|
11775
|
+
this.traceLogger = null;
|
|
11776
|
+
}
|
|
11777
|
+
withLogger(logger) {
|
|
11778
|
+
this.logger = logger;
|
|
11779
|
+
return this;
|
|
11780
|
+
}
|
|
11781
|
+
withTraceLogger(traceLogger) {
|
|
11782
|
+
this.traceLogger = traceLogger;
|
|
11783
|
+
return this;
|
|
11784
|
+
}
|
|
11785
|
+
withSettings(settings) {
|
|
11786
|
+
this.settings = settings;
|
|
11787
|
+
return this;
|
|
11788
|
+
}
|
|
11789
|
+
withMetrics(metrics) {
|
|
11790
|
+
this.metrics = metrics;
|
|
11791
|
+
return this;
|
|
11792
|
+
}
|
|
11793
|
+
withTracerProvider(tracerProvider) {
|
|
11794
|
+
this.tracerProvider = tracerProvider;
|
|
11795
|
+
return this;
|
|
11796
|
+
}
|
|
11797
|
+
withSamplerGetter(samplerGetter) {
|
|
11798
|
+
this.samplerGetter = samplerGetter;
|
|
11799
|
+
return this;
|
|
11800
|
+
}
|
|
11801
|
+
withSpanProcessors(spanProcessors) {
|
|
11802
|
+
this.spanProcessors = spanProcessors;
|
|
11803
|
+
return this;
|
|
11804
|
+
}
|
|
11805
|
+
withSpanExporters(spanExporters) {
|
|
11806
|
+
this.spanExporters = spanExporters;
|
|
11807
|
+
return this;
|
|
11808
|
+
}
|
|
11809
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11810
|
+
withProviderRegistrationSettings(providerRegistrationSettings) {
|
|
11811
|
+
var _a;
|
|
11812
|
+
this.providerRegistrationSettings = Object.assign({ contextManager: (_a = this.providerRegistrationSettings) === null || _a === void 0 ? void 0 : _a.contextManager }, providerRegistrationSettings);
|
|
11813
|
+
return this;
|
|
11814
|
+
}
|
|
11815
|
+
withContextManager(contextManager) {
|
|
11816
|
+
this.providerRegistrationSettings = Object.assign(Object.assign({}, this.providerRegistrationSettings), { contextManager });
|
|
11817
|
+
this.contextManager = contextManager;
|
|
11818
|
+
return this;
|
|
11819
|
+
}
|
|
11820
|
+
withPropagator(propagator) {
|
|
11821
|
+
this.providerRegistrationSettings = Object.assign(Object.assign({}, this.providerRegistrationSettings), { propagator });
|
|
11822
|
+
this.propagator = propagator;
|
|
11823
|
+
return this;
|
|
11824
|
+
}
|
|
11825
|
+
withPropagationInfoStorage(store, read) {
|
|
11826
|
+
this.store = store;
|
|
11827
|
+
this.read = read;
|
|
11828
|
+
return this;
|
|
11829
|
+
}
|
|
11830
|
+
build() {
|
|
11831
|
+
// vnikolov TODO
|
|
11832
|
+
// const validator = new TracesBuilderValidator();
|
|
11833
|
+
// validator.validate(this);
|
|
11834
|
+
var _a;
|
|
11835
|
+
if (((_a = globalThis.ioInsightsInternals) === null || _a === void 0 ? void 0 : _a.traces) &&
|
|
11836
|
+
!this.settings.definitiveInstance) {
|
|
11837
|
+
return globalThis.ioInsightsInternals.traces;
|
|
11838
|
+
}
|
|
11839
|
+
if (this.contextManager && this.settings.traces) {
|
|
11840
|
+
this.settings.traces.useOTELContextManager = true;
|
|
11841
|
+
}
|
|
11842
|
+
return this.buildCore();
|
|
11843
|
+
}
|
|
11844
|
+
buildCore() {
|
|
11845
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11846
|
+
let tracePlugin;
|
|
11847
|
+
if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.enabled) !== true ||
|
|
11848
|
+
((_c = (_b = this.settings) === null || _b === void 0 ? void 0 : _b.traces) === null || _c === void 0 ? void 0 : _c.enabled) !== true ||
|
|
11849
|
+
!(tracePlugin = (0, __1.loadInsightsPlugin)("traces", this.logger))) {
|
|
11850
|
+
return new nullTracesManager_1.NullTracesManager((_d = this.settings) === null || _d === void 0 ? void 0 : _d.traces, this.settings, this.logger);
|
|
11851
|
+
}
|
|
11852
|
+
const manager = tracePlugin.newTracesManager(this.settings, this.logger, (_e = this.traceLogger) !== null && _e !== void 0 ? _e : this.logger, this.getOrMake("contextManager"), this.getOrMake("propagator"), this.getOrMake("tracerProvider"), (_f = this.settings.traces) === null || _f === void 0 ? void 0 : _f.samplerGetter, this.getOrMake("spanProcessors"), this.getOrMake("spanExporters", true, (_g = this.settings.traces) === null || _g === void 0 ? void 0 : _g.url), this.getOrMake("providerRegistrationSettings"), this.metrics, this.store, this.read);
|
|
11853
|
+
return manager;
|
|
11854
|
+
}
|
|
11855
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11856
|
+
getOrMake(key, invoke, arg) {
|
|
11857
|
+
var _a, _b, _c, _d;
|
|
11858
|
+
if (this[key]) {
|
|
11859
|
+
return this[key];
|
|
11860
|
+
}
|
|
11861
|
+
if (invoke !== false &&
|
|
11862
|
+
typeof ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.traces) === null || _b === void 0 ? void 0 : _b[key]) === "function") {
|
|
11863
|
+
return container_1.Container.errorless(() => { var _a, _b; return (_b = (_a = this.settings.traces)[key]) === null || _b === void 0 ? void 0 : _b.call(_a, arg); });
|
|
11864
|
+
}
|
|
11865
|
+
return (_d = (_c = this.settings) === null || _c === void 0 ? void 0 : _c.traces) === null || _d === void 0 ? void 0 : _d[key];
|
|
11866
|
+
}
|
|
11867
|
+
}
|
|
11868
|
+
builder.TracesManagerBuilder = TracesManagerBuilder;
|
|
11869
|
+
|
|
11870
|
+
return builder;
|
|
11871
|
+
}
|
|
11872
|
+
|
|
11873
|
+
var _null = {};
|
|
11874
|
+
|
|
11875
|
+
Object.defineProperty(_null, "__esModule", { value: true });
|
|
11876
|
+
_null.NullLogger = void 0;
|
|
11877
|
+
class NullLogger {
|
|
11878
|
+
get level() {
|
|
11879
|
+
return 60 /* IOInsights.LoggerLogLevel.INFO */;
|
|
11880
|
+
}
|
|
11881
|
+
error() {
|
|
11882
|
+
// do nothing
|
|
11883
|
+
}
|
|
11884
|
+
warn() {
|
|
11885
|
+
// do nothing
|
|
11886
|
+
}
|
|
11887
|
+
info() {
|
|
11888
|
+
// do nothing
|
|
11889
|
+
}
|
|
11890
|
+
debug() {
|
|
11891
|
+
// do nothing
|
|
11892
|
+
}
|
|
11893
|
+
verbose() {
|
|
11894
|
+
// do nothing
|
|
11895
|
+
}
|
|
11896
|
+
}
|
|
11897
|
+
_null.NullLogger = NullLogger;
|
|
11898
|
+
|
|
11899
|
+
var nullManager = {};
|
|
11900
|
+
|
|
11901
|
+
Object.defineProperty(nullManager, "__esModule", { value: true });
|
|
11902
|
+
nullManager.NullLogsManager = void 0;
|
|
11903
|
+
const nullManager_1$1 = nullManager$1;
|
|
11904
|
+
const safe_stringify_1 = safeStringify$1;
|
|
11905
|
+
class NullLogsManager extends nullManager_1$1.NullManager {
|
|
11906
|
+
constructor(settings, otelSettings, logger) {
|
|
11907
|
+
if ((otelSettings === null || otelSettings === void 0 ? void 0 : otelSettings.logSettingsOnStartup) !== false) {
|
|
11908
|
+
logger === null || logger === void 0 ? void 0 : logger.info(`Starting NullLogsManager with settings ${(0, safe_stringify_1.safeStringify)(settings)}`);
|
|
11909
|
+
}
|
|
11910
|
+
super();
|
|
11911
|
+
}
|
|
11912
|
+
emit(logRecord) {
|
|
11913
|
+
return null;
|
|
11914
|
+
}
|
|
11915
|
+
}
|
|
11916
|
+
nullManager.NullLogsManager = NullLogsManager;
|
|
11917
|
+
|
|
11918
|
+
var constants = {};
|
|
11919
|
+
|
|
11920
|
+
Object.defineProperty(constants, "__esModule", { value: true });
|
|
11921
|
+
constants.Defaults = void 0;
|
|
11922
|
+
constants.Defaults = {
|
|
11923
|
+
DEFAULT_USER: "unknown-user",
|
|
11924
|
+
DEFAULT_SERVICE_NAME: "unknown-service-name",
|
|
11925
|
+
DEFAULT_SERVICE_ID: "unknown-service-id",
|
|
11926
|
+
DEFAULT_SERVICE_VERSION: "unknown-service-version",
|
|
11927
|
+
DEFAULT_PLATFORM_VERSION: "unknown-platform-version",
|
|
11928
|
+
};
|
|
11929
|
+
|
|
11930
|
+
var logWrapper = {};
|
|
11931
|
+
|
|
11932
|
+
Object.defineProperty(logWrapper, "__esModule", { value: true });
|
|
11933
|
+
logWrapper.LogWrapper = void 0;
|
|
11934
|
+
// wraps an OTEL library logger into an OTEL library logger
|
|
11935
|
+
// allows filtering messages etc
|
|
11936
|
+
class LogWrapper {
|
|
11937
|
+
constructor(logger, dropLog) {
|
|
11938
|
+
this.logger = logger;
|
|
11939
|
+
this.dropLog = dropLog;
|
|
11940
|
+
}
|
|
11941
|
+
get level() {
|
|
11942
|
+
var _a;
|
|
11943
|
+
return (_a = this.logger.level) !== null && _a !== void 0 ? _a : 0 /* IOInsights.LoggerLogLevel.NONE */;
|
|
11944
|
+
}
|
|
11945
|
+
error(message, ...args) {
|
|
11946
|
+
var _a;
|
|
11947
|
+
if ((_a = this.dropLog) === null || _a === void 0 ? void 0 : _a.call(this, 50 /* IOInsights.LoggerLogLevel.WARN */, message)) {
|
|
11948
|
+
return;
|
|
11949
|
+
}
|
|
11950
|
+
// we log errors as warn because some of our clients stopped the platform if an log error is observed (they consider it as broken state)
|
|
11951
|
+
// we can do that since otel impl is not considered critical
|
|
11952
|
+
this.logger.warn(message, ...args);
|
|
11953
|
+
}
|
|
11954
|
+
warn(message, ...args) {
|
|
11955
|
+
var _a;
|
|
11956
|
+
if ((_a = this.dropLog) === null || _a === void 0 ? void 0 : _a.call(this, 50 /* IOInsights.LoggerLogLevel.WARN */, message)) {
|
|
11957
|
+
return;
|
|
11958
|
+
}
|
|
11959
|
+
this.logger.warn(message, ...args);
|
|
11960
|
+
}
|
|
11961
|
+
info(message, ...args) {
|
|
11962
|
+
var _a;
|
|
11963
|
+
if ((_a = this.dropLog) === null || _a === void 0 ? void 0 : _a.call(this, 60 /* IOInsights.LoggerLogLevel.INFO */, message)) {
|
|
11964
|
+
return;
|
|
11965
|
+
}
|
|
11966
|
+
this.logger.info(message, ...args);
|
|
11967
|
+
}
|
|
11968
|
+
debug(message, ...args) {
|
|
11969
|
+
var _a;
|
|
11970
|
+
if ((_a = this.dropLog) === null || _a === void 0 ? void 0 : _a.call(this, 70 /* IOInsights.LoggerLogLevel.DEBUG */, message)) {
|
|
11971
|
+
return;
|
|
11972
|
+
}
|
|
11973
|
+
this.logger.debug(message, ...args);
|
|
11974
|
+
}
|
|
11975
|
+
verbose(message, ...args) {
|
|
11976
|
+
var _a;
|
|
11977
|
+
if ((_a = this.dropLog) === null || _a === void 0 ? void 0 : _a.call(this, 80 /* IOInsights.LoggerLogLevel.VERBOSE */, message)) {
|
|
11978
|
+
return;
|
|
11979
|
+
}
|
|
11980
|
+
this.logger.verbose(message, ...args);
|
|
11981
|
+
}
|
|
11982
|
+
}
|
|
11983
|
+
logWrapper.LogWrapper = LogWrapper;
|
|
11984
|
+
|
|
11985
|
+
var hasRequiredBuilder;
|
|
11986
|
+
|
|
11987
|
+
function requireBuilder () {
|
|
11988
|
+
if (hasRequiredBuilder) return builder$2;
|
|
11989
|
+
hasRequiredBuilder = 1;
|
|
11990
|
+
Object.defineProperty(builder$2, "__esModule", { value: true });
|
|
11991
|
+
builder$2.Builder = void 0;
|
|
11992
|
+
const builder_1 = requireBuilder$2();
|
|
11993
|
+
const builder_2 = requireBuilder$1();
|
|
11994
|
+
const null_1 = _null;
|
|
11995
|
+
const container_1 = container;
|
|
11996
|
+
const nullMetricsManager_1 = nullMetricsManager;
|
|
11997
|
+
const nullTracesManager_1 = requireNullTracesManager();
|
|
11998
|
+
const nullManager_1 = nullManager;
|
|
11999
|
+
const constants_1 = constants;
|
|
12000
|
+
const logWrapper_1 = logWrapper;
|
|
12001
|
+
const _1 = requireDist();
|
|
12002
|
+
const safe_stringify_1 = safeStringify$1;
|
|
12003
|
+
class Builder {
|
|
12004
|
+
constructor() {
|
|
12005
|
+
this.logger = new null_1.NullLogger();
|
|
12006
|
+
}
|
|
12007
|
+
// these methods must be invoked...
|
|
12008
|
+
withLogger(loggerArg) {
|
|
12009
|
+
var _a;
|
|
12010
|
+
if (loggerArg) {
|
|
12011
|
+
this.logger = new logWrapper_1.LogWrapper(loggerArg, (_, msg) => {
|
|
12012
|
+
var _a, _b, _c;
|
|
12013
|
+
if (((_a = this.settings) === null || _a === void 0 ? void 0 : _a.suppressDoubleInitializationWarnings) &&
|
|
12014
|
+
~(msg + "").indexOf("@opentelemetry/api: Attempted duplicate registration of API")) {
|
|
12015
|
+
return true;
|
|
12016
|
+
}
|
|
12017
|
+
if (((_b = this.settings) === null || _b === void 0 ? void 0 : _b.suppressDoubleInitializationWarnings) &&
|
|
12018
|
+
~(msg + "").indexOf("Current logger will overwrite one already registered")) {
|
|
12019
|
+
return true;
|
|
12020
|
+
}
|
|
12021
|
+
if (((_c = this.settings) === null || _c === void 0 ? void 0 : _c.suppressDoubleInitializationWarnings) &&
|
|
12022
|
+
~(msg + "").indexOf("Current logger will be overwritten")) {
|
|
12023
|
+
return true;
|
|
12024
|
+
}
|
|
12025
|
+
return false;
|
|
12026
|
+
});
|
|
12027
|
+
}
|
|
12028
|
+
const basePlugin = (0, _1.loadInsightsPlugin)("base", this.logger);
|
|
12029
|
+
if (basePlugin) {
|
|
12030
|
+
if (this.logger.level) {
|
|
12031
|
+
const level = (_a = this.logger.level) === null || _a === void 0 ? void 0 : _a.valueOf();
|
|
12032
|
+
basePlugin.diag.setLogger(this.logger, level);
|
|
12033
|
+
}
|
|
12034
|
+
else {
|
|
12035
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12036
|
+
basePlugin.diag.setLogger(this.logger, 70 /* IOInsights.LoggerLogLevel.DEBUG */);
|
|
12037
|
+
}
|
|
12038
|
+
}
|
|
12039
|
+
return this;
|
|
12040
|
+
}
|
|
12041
|
+
withSettings(settings) {
|
|
12042
|
+
this.settings = settings;
|
|
12043
|
+
return this;
|
|
12044
|
+
}
|
|
12045
|
+
// ...before these methods
|
|
12046
|
+
withMetrics() {
|
|
12047
|
+
this.metricsBuilder = new builder_1.MetricsManagerBuilder();
|
|
12048
|
+
this.metricsBuilder.withLogger(this.logger);
|
|
12049
|
+
this.metricsBuilder.withSettings(Object.assign({ enabled: false }, this.settings));
|
|
12050
|
+
return this.metricsBuilder;
|
|
12051
|
+
}
|
|
12052
|
+
withTraces() {
|
|
12053
|
+
this.tracesBuilder = new builder_2.TracesManagerBuilder();
|
|
12054
|
+
this.tracesBuilder.withLogger(this.logger);
|
|
12055
|
+
this.tracesBuilder.withSettings(Object.assign({ enabled: false }, this.settings));
|
|
12056
|
+
return this.tracesBuilder;
|
|
12057
|
+
}
|
|
12058
|
+
build() {
|
|
12059
|
+
// const validator = new BuilderValidator();
|
|
12060
|
+
// validator.validate(this);
|
|
12061
|
+
return this.buildCore();
|
|
12062
|
+
}
|
|
12063
|
+
buildCore() {
|
|
12064
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
12065
|
+
this.settings = (_a = this.settings) !== null && _a !== void 0 ? _a : { enabled: false };
|
|
12066
|
+
const nonPartialSettings = Object.assign({ enabled: false }, this.settings);
|
|
12067
|
+
if (((_b = this.settings) === null || _b === void 0 ? void 0 : _b.logSettingsOnStartup) !== false) {
|
|
12068
|
+
this.logger.info(`Starting interop.io OTEL with settings ${(0, safe_stringify_1.safeStringify)(this.settings)}`);
|
|
12069
|
+
}
|
|
12070
|
+
const basePlugin = (0, _1.loadInsightsPlugin)("base", this.logger);
|
|
12071
|
+
if (((_c = this.settings) === null || _c === void 0 ? void 0 : _c.enabled) !== false &&
|
|
12072
|
+
basePlugin) {
|
|
12073
|
+
if (((_e = (_d = this.settings) === null || _d === void 0 ? void 0 : _d.metrics) === null || _e === void 0 ? void 0 : _e.enabled) &&
|
|
12074
|
+
((_f = this.settings) === null || _f === void 0 ? void 0 : _f.metrics.platformMetricsEnabled) &&
|
|
12075
|
+
!this.metricsBuilder) {
|
|
12076
|
+
throw new Error("metrics.platformMetricsEnabled is true, but .withMetrics() method not called.");
|
|
12077
|
+
}
|
|
12078
|
+
const providedAdditionalResourceAttributes = this.settings.additionalResourceAttributes;
|
|
12079
|
+
this.settings.additionalResourceAttributes = () => {
|
|
12080
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
12081
|
+
const evaluatedAdditionalResourceAttributes = (_a = container_1.Container.errorlessDefined(providedAdditionalResourceAttributes, {})) !== null && _a !== void 0 ? _a : {};
|
|
12082
|
+
return Object.assign(Object.assign({}, evaluatedAdditionalResourceAttributes), { user: (_e = (_d = (_b = evaluatedAdditionalResourceAttributes.userId) !== null && _b !== void 0 ? _b : (_c = this.settings) === null || _c === void 0 ? void 0 : _c.userId) !== null && _d !== void 0 ? _d : evaluatedAdditionalResourceAttributes["user.id"]) !== null && _e !== void 0 ? _e : constants_1.Defaults.DEFAULT_USER, "user.id": (_j = (_h = (_f = evaluatedAdditionalResourceAttributes.userId) !== null && _f !== void 0 ? _f : (_g = this.settings) === null || _g === void 0 ? void 0 : _g.userId) !== null && _h !== void 0 ? _h : evaluatedAdditionalResourceAttributes["user.id"]) !== null && _j !== void 0 ? _j : constants_1.Defaults.DEFAULT_USER, "service.name": (_o = (_m = (_k = evaluatedAdditionalResourceAttributes.serviceName) !== null && _k !== void 0 ? _k : (_l = this.settings) === null || _l === void 0 ? void 0 : _l.serviceName) !== null && _m !== void 0 ? _m : evaluatedAdditionalResourceAttributes["service.name"]) !== null && _o !== void 0 ? _o : constants_1.Defaults.DEFAULT_SERVICE_NAME, "service.instance.id": (_s = (_r = (_p = evaluatedAdditionalResourceAttributes.serviceId) !== null && _p !== void 0 ? _p : (_q = this.settings) === null || _q === void 0 ? void 0 : _q.serviceId) !== null && _r !== void 0 ? _r : evaluatedAdditionalResourceAttributes["service.instance.id"]) !== null && _s !== void 0 ? _s : constants_1.Defaults.DEFAULT_SERVICE_ID, "service.version": (_w = (_v = (_t = evaluatedAdditionalResourceAttributes.serviceVersion) !== null && _t !== void 0 ? _t : (_u = this.settings) === null || _u === void 0 ? void 0 : _u.serviceVersion) !== null && _v !== void 0 ? _v : evaluatedAdditionalResourceAttributes["service.version"]) !== null && _w !== void 0 ? _w : constants_1.Defaults.DEFAULT_SERVICE_VERSION, platformVersion: (_z = (_x = evaluatedAdditionalResourceAttributes.platformVersion) !== null && _x !== void 0 ? _x : (_y = this.settings) === null || _y === void 0 ? void 0 : _y.platformVersion) !== null && _z !== void 0 ? _z : constants_1.Defaults.DEFAULT_PLATFORM_VERSION });
|
|
12083
|
+
};
|
|
12084
|
+
Builder.maybeAddResourceAttributesToAttributes(this.settings);
|
|
12085
|
+
Builder.maybeAddResourceAttributesToAttributes(this.settings.logs);
|
|
12086
|
+
Builder.maybeAddResourceAttributesToAttributes(this.settings.metrics);
|
|
12087
|
+
Builder.maybeAddResourceAttributesToAttributes(this.settings.traces);
|
|
12088
|
+
Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.logs);
|
|
12089
|
+
Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.metrics);
|
|
12090
|
+
Builder.propagateAttributeDown("useSSOAuth", this.settings, this.settings.traces);
|
|
12091
|
+
Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.logs);
|
|
12092
|
+
Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.metrics);
|
|
12093
|
+
Builder.propagateAttributeDown("useSSOAuthRawToken", this.settings, this.settings.traces);
|
|
12094
|
+
Builder.propagateAttributesDown("headers", this.settings, this.settings.logs);
|
|
12095
|
+
Builder.propagateAttributesDown("headers", this.settings, this.settings.metrics);
|
|
12096
|
+
Builder.propagateAttributesDown("headers", this.settings, this.settings.traces);
|
|
12097
|
+
Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.logs);
|
|
12098
|
+
Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.logs);
|
|
12099
|
+
Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.metrics);
|
|
12100
|
+
Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.metrics);
|
|
12101
|
+
Builder.propagateAttributesDown("additionalAttributes", this.settings, this.settings.traces);
|
|
12102
|
+
Builder.propagateAttributesDown("additionalResourceAttributes", this.settings, this.settings.traces);
|
|
12103
|
+
const metricsBuilder = (_g = this.metricsBuilder) !== null && _g !== void 0 ? _g : this.withMetrics();
|
|
12104
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12105
|
+
const metrics = metricsBuilder.withSettings(this.settings).build();
|
|
12106
|
+
const tracesBuilder = (_h = this.tracesBuilder) !== null && _h !== void 0 ? _h : this.withTraces();
|
|
12107
|
+
tracesBuilder.withMetrics(metrics);
|
|
12108
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12109
|
+
const traces = tracesBuilder.withSettings(this.settings).build();
|
|
12110
|
+
_1.Traces.instance = traces;
|
|
12111
|
+
const logsPlugin = (((_k = (_j = this === null || this === void 0 ? void 0 : this.settings) === null || _j === void 0 ? void 0 : _j.logs) === null || _k === void 0 ? void 0 : _k.enabled) &&
|
|
12112
|
+
(0, _1.loadInsightsPlugin)("logs", this.logger));
|
|
12113
|
+
const logs = (((_m = (_l = this === null || this === void 0 ? void 0 : this.settings) === null || _l === void 0 ? void 0 : _l.logs) === null || _m === void 0 ? void 0 : _m.enabled) && logsPlugin) ?
|
|
12114
|
+
logsPlugin.newLogsManager(this.logger, this.settings.logs, nonPartialSettings, logsPlugin) :
|
|
12115
|
+
new nullManager_1.NullLogsManager(this.settings.logs, nonPartialSettings, this.logger);
|
|
12116
|
+
_1.Logs.instance = logs;
|
|
12117
|
+
return new container_1.Container(nonPartialSettings, traces, metrics, logs, this.logger);
|
|
12118
|
+
}
|
|
12119
|
+
else {
|
|
12120
|
+
return new container_1.Container(nonPartialSettings, new nullTracesManager_1.NullTracesManager(this.settings.traces, nonPartialSettings, this.logger), new nullMetricsManager_1.NullMetricsManager(this.settings.metrics, nonPartialSettings, this.logger), new nullManager_1.NullLogsManager(this.settings.logs, nonPartialSettings, this.logger), this.logger);
|
|
12121
|
+
}
|
|
12122
|
+
}
|
|
12123
|
+
static propagateAttributeDown(k, otelSettings, settings) {
|
|
12124
|
+
var _a;
|
|
12125
|
+
if (!settings) {
|
|
12126
|
+
return;
|
|
12127
|
+
}
|
|
12128
|
+
settings[k] = (_a = settings[k]) !== null && _a !== void 0 ? _a : otelSettings[k];
|
|
12129
|
+
}
|
|
12130
|
+
static propagateAttributesDown(k, otelSettings, settings) {
|
|
12131
|
+
var _a, _b;
|
|
12132
|
+
if (!settings) {
|
|
12133
|
+
return;
|
|
12134
|
+
}
|
|
12135
|
+
const providedOtel = (_a = otelSettings[k]) !== null && _a !== void 0 ? _a : {};
|
|
12136
|
+
const provided = (_b = settings[k]) !== null && _b !== void 0 ? _b : {};
|
|
12137
|
+
settings[k] = () => (Object.assign(Object.assign({}, container_1.Container.errorless(providedOtel)), container_1.Container.errorless(provided)));
|
|
12138
|
+
}
|
|
12139
|
+
static maybeAddResourceAttributesToAttributes(settings) {
|
|
12140
|
+
if (settings === null || settings === void 0 ? void 0 : settings.addResourceAttributesToAttributes) {
|
|
12141
|
+
const providedAdditionalResourceAttributes = settings.additionalResourceAttributes;
|
|
12142
|
+
const providedAdditionalAttributes = settings.additionalAttributes;
|
|
12143
|
+
settings.additionalAttributes = () => (Object.assign(Object.assign({}, container_1.Container.errorless(providedAdditionalResourceAttributes)), container_1.Container.errorless(providedAdditionalAttributes)));
|
|
12144
|
+
}
|
|
12145
|
+
}
|
|
12146
|
+
}
|
|
12147
|
+
builder$2.Builder = Builder;
|
|
12148
|
+
|
|
12149
|
+
return builder$2;
|
|
12150
|
+
}
|
|
12151
|
+
|
|
12152
|
+
var log4jsWrapper = {};
|
|
12153
|
+
|
|
12154
|
+
Object.defineProperty(log4jsWrapper, "__esModule", { value: true });
|
|
12155
|
+
log4jsWrapper.Log4jsWrapper = void 0;
|
|
12156
|
+
// wraps a log4js wrapper into an OTEL library logger
|
|
12157
|
+
class Log4jsWrapper {
|
|
12158
|
+
constructor(logger) {
|
|
12159
|
+
this.logger = logger;
|
|
12160
|
+
}
|
|
12161
|
+
get level() {
|
|
12162
|
+
return this.convert("level" in this.logger ? this.logger.level : this.logger.publishLevel());
|
|
12163
|
+
}
|
|
12164
|
+
error(message, ...args) {
|
|
12165
|
+
// we log errors as warn because some of our clients stopped the platform if an log error is observed (they consider it as broken state)
|
|
12166
|
+
// we can do that since otel impl is not considered critical
|
|
12167
|
+
this.logger.warn(message, ...args);
|
|
12168
|
+
}
|
|
12169
|
+
warn(message, ...args) {
|
|
12170
|
+
this.logger.warn(message, ...args);
|
|
12171
|
+
}
|
|
12172
|
+
info(message, ...args) {
|
|
12173
|
+
this.logger.info(message, ...args);
|
|
12174
|
+
}
|
|
12175
|
+
debug(message, ...args) {
|
|
12176
|
+
this.logger.debug(message, ...args);
|
|
12177
|
+
}
|
|
12178
|
+
verbose(message, ...args) {
|
|
12179
|
+
this.logger.trace(message, ...args);
|
|
12180
|
+
}
|
|
12181
|
+
convert(level) {
|
|
12182
|
+
if (level === undefined) {
|
|
12183
|
+
return 60 /* IOInsights.LoggerLogLevel.INFO */;
|
|
12184
|
+
}
|
|
12185
|
+
const currentLevel = typeof level !== "string" ? level.levelStr.toLowerCase() : level.toLowerCase();
|
|
12186
|
+
switch (currentLevel) {
|
|
12187
|
+
case "off": {
|
|
12188
|
+
return 0 /* IOInsights.LoggerLogLevel.NONE */;
|
|
12189
|
+
}
|
|
12190
|
+
case "error": {
|
|
12191
|
+
return 30 /* IOInsights.LoggerLogLevel.ERROR */;
|
|
12192
|
+
}
|
|
12193
|
+
case "warn": {
|
|
12194
|
+
return 50 /* IOInsights.LoggerLogLevel.WARN */;
|
|
12195
|
+
}
|
|
12196
|
+
case "info": {
|
|
12197
|
+
return 60 /* IOInsights.LoggerLogLevel.INFO */;
|
|
12198
|
+
}
|
|
12199
|
+
case "debug": {
|
|
12200
|
+
return 70 /* IOInsights.LoggerLogLevel.DEBUG */;
|
|
12201
|
+
}
|
|
12202
|
+
case "trace": {
|
|
12203
|
+
return 80 /* IOInsights.LoggerLogLevel.VERBOSE */;
|
|
12204
|
+
}
|
|
12205
|
+
default: {
|
|
12206
|
+
return 60 /* IOInsights.LoggerLogLevel.INFO */;
|
|
12207
|
+
}
|
|
12208
|
+
}
|
|
12209
|
+
}
|
|
12210
|
+
}
|
|
12211
|
+
log4jsWrapper.Log4jsWrapper = Log4jsWrapper;
|
|
12212
|
+
|
|
12213
|
+
var metricsDependencyBuilder = {};
|
|
12214
|
+
|
|
12215
|
+
var nullPerfProvider = {};
|
|
12216
|
+
|
|
12217
|
+
Object.defineProperty(nullPerfProvider, "__esModule", { value: true });
|
|
12218
|
+
nullPerfProvider.NullPerformanceProvider = void 0;
|
|
12219
|
+
class NullPerformanceProvider {
|
|
12220
|
+
getAppsCPU() {
|
|
12221
|
+
return Promise.resolve(undefined);
|
|
12222
|
+
}
|
|
12223
|
+
getAppsMemory() {
|
|
12224
|
+
return Promise.resolve(undefined);
|
|
12225
|
+
}
|
|
12226
|
+
getSystemCPU() {
|
|
12227
|
+
return Promise.resolve(undefined);
|
|
12228
|
+
}
|
|
12229
|
+
getSystemMemory() {
|
|
12230
|
+
return Promise.resolve(undefined);
|
|
12231
|
+
}
|
|
12232
|
+
}
|
|
12233
|
+
nullPerfProvider.NullPerformanceProvider = NullPerformanceProvider;
|
|
12234
|
+
|
|
12235
|
+
Object.defineProperty(metricsDependencyBuilder, "__esModule", { value: true });
|
|
12236
|
+
metricsDependencyBuilder.MetricsDependencyBuilder = void 0;
|
|
12237
|
+
const nullPerfProvider_1 = nullPerfProvider;
|
|
12238
|
+
class MetricsDependencyBuilder {
|
|
12239
|
+
constructor() {
|
|
12240
|
+
this.performanceProvider = new nullPerfProvider_1.NullPerformanceProvider();
|
|
12241
|
+
this.instanceFocusedHandler = () => () => { };
|
|
12242
|
+
this.instanceStartedHandler = () => () => { };
|
|
12243
|
+
this.instanceStoppedHandler = () => () => { };
|
|
12244
|
+
this.instanceReadyHandler = () => () => { };
|
|
12245
|
+
this.instanceErrorHandler = () => () => { };
|
|
12246
|
+
this.instanceCrashHandler = () => () => { };
|
|
12247
|
+
this.layoutRestoredHandler = () => () => { };
|
|
12248
|
+
this.platformStartedHandler = () => () => { };
|
|
12249
|
+
this.platformErrorHandler = () => () => { };
|
|
12250
|
+
this.workspaceLoadedHandler = () => () => { };
|
|
12251
|
+
this.workspaceRestoredHandler = () => () => { };
|
|
12252
|
+
this.workspaceSavedHandler = () => () => { };
|
|
12253
|
+
this.workspaceStoppedHandler = () => () => { };
|
|
12254
|
+
this.workspaceSelectedHandler = () => () => { };
|
|
12255
|
+
this.workspaceStartedHandler = () => () => { };
|
|
12256
|
+
this.workspaceFrameCreatedHandler = () => () => { };
|
|
12257
|
+
this.workspaceFrameInitHandler = () => () => { };
|
|
12258
|
+
this.workspaceFramePageLoadHandler = () => () => { };
|
|
12259
|
+
this.workspaceFrameWorkspaceRenderHandler = () => () => { };
|
|
12260
|
+
this.workspaceComponentCreatedHandler = () => () => { };
|
|
12261
|
+
this.workspaceAppsStartedHandler = () => () => { };
|
|
12262
|
+
this.workspaceStartupHandler = () => () => { };
|
|
12263
|
+
}
|
|
12264
|
+
build() {
|
|
12265
|
+
const container = {
|
|
12266
|
+
performanceProvider: this.performanceProvider,
|
|
12267
|
+
instanceStartedHandler: this.instanceStartedHandler,
|
|
12268
|
+
instanceStoppedHandler: this.instanceStoppedHandler,
|
|
12269
|
+
instanceReadyHandler: this.instanceReadyHandler,
|
|
12270
|
+
instanceFocusedHandler: this.instanceFocusedHandler,
|
|
12271
|
+
instanceErrorHandler: this.instanceErrorHandler,
|
|
12272
|
+
instanceCrashHandler: this.instanceCrashHandler,
|
|
12273
|
+
layoutRestoredHandler: this.layoutRestoredHandler,
|
|
12274
|
+
platformStartedHandler: this.platformStartedHandler,
|
|
12275
|
+
platformErrorHandler: this.platformErrorHandler,
|
|
12276
|
+
workspaceLoadedHandler: this.workspaceLoadedHandler,
|
|
12277
|
+
workspaceSavedHandler: this.workspaceSavedHandler,
|
|
12278
|
+
workspaceStoppedHandler: this.workspaceStoppedHandler,
|
|
12279
|
+
workspaceSelectedHandler: this.workspaceSelectedHandler,
|
|
12280
|
+
workspaceRestoredHandler: this.workspaceRestoredHandler,
|
|
12281
|
+
workspaceStartedHandler: this.workspaceStartedHandler,
|
|
12282
|
+
workspaceStartupHandler: this.workspaceStartupHandler,
|
|
12283
|
+
workspaceFrameCreatedHandler: this.workspaceFrameCreatedHandler,
|
|
12284
|
+
workspaceFrameInitHandler: this.workspaceFrameInitHandler,
|
|
12285
|
+
workspaceFramePageLoadHandler: this.workspaceFramePageLoadHandler,
|
|
12286
|
+
workspaceFrameWorkspaceRenderHandler: this.workspaceFrameWorkspaceRenderHandler,
|
|
12287
|
+
workspaceComponentCreatedHandler: this.workspaceComponentCreatedHandler,
|
|
12288
|
+
workspaceAppsStartedHandler: this.workspaceAppsStartedHandler,
|
|
12289
|
+
};
|
|
12290
|
+
return container;
|
|
12291
|
+
}
|
|
12292
|
+
withInstanceStartedHandler(instanceStartedHandler) {
|
|
12293
|
+
this.instanceStartedHandler = instanceStartedHandler;
|
|
12294
|
+
return this;
|
|
12295
|
+
}
|
|
12296
|
+
withInstanceStoppedHandler(instanceStoppedHandler) {
|
|
12297
|
+
this.instanceStoppedHandler = instanceStoppedHandler;
|
|
12298
|
+
return this;
|
|
12299
|
+
}
|
|
12300
|
+
withInstanceReadyHandler(instanceReadyHandler) {
|
|
12301
|
+
this.instanceReadyHandler = instanceReadyHandler;
|
|
12302
|
+
return this;
|
|
12303
|
+
}
|
|
12304
|
+
withInstanceFocusedHandler(instanceFocusedHandler) {
|
|
12305
|
+
this.instanceFocusedHandler = instanceFocusedHandler;
|
|
12306
|
+
return this;
|
|
12307
|
+
}
|
|
12308
|
+
withInstanceErrorHandler(instanceErrorHandler) {
|
|
12309
|
+
this.instanceErrorHandler = instanceErrorHandler;
|
|
12310
|
+
return this;
|
|
12311
|
+
}
|
|
12312
|
+
withInstanceCrashHandler(instanceCrashHandler) {
|
|
12313
|
+
this.instanceCrashHandler = instanceCrashHandler;
|
|
12314
|
+
return this;
|
|
12315
|
+
}
|
|
12316
|
+
withLayoutRestoredHandler(layoutRestoredHandler) {
|
|
12317
|
+
this.layoutRestoredHandler = layoutRestoredHandler;
|
|
12318
|
+
return this;
|
|
12319
|
+
}
|
|
12320
|
+
withWorkspaceLoadedHandler(workspaceLoadedHandler) {
|
|
12321
|
+
this.workspaceLoadedHandler = workspaceLoadedHandler;
|
|
12322
|
+
return this;
|
|
12323
|
+
}
|
|
12324
|
+
withWorkspaceSavedHandler(workspaceSavedHandler) {
|
|
12325
|
+
this.workspaceSavedHandler = workspaceSavedHandler;
|
|
12326
|
+
return this;
|
|
12327
|
+
}
|
|
12328
|
+
withWorkspaceStartedHandler(workspaceStartedHandler) {
|
|
12329
|
+
this.workspaceRestoredHandler = () => () => { };
|
|
12330
|
+
this.workspaceStartedHandler = workspaceStartedHandler;
|
|
12331
|
+
return this;
|
|
12332
|
+
}
|
|
12333
|
+
withWorkspaceStoppedHandler(workspaceStoppedHandler) {
|
|
12334
|
+
this.workspaceStoppedHandler = workspaceStoppedHandler;
|
|
12335
|
+
return this;
|
|
12336
|
+
}
|
|
12337
|
+
withWorkspaceSelectedHandler(workspaceSelectedHandler) {
|
|
12338
|
+
this.workspaceSelectedHandler = workspaceSelectedHandler;
|
|
12339
|
+
return this;
|
|
12340
|
+
}
|
|
12341
|
+
withPlatformStartedHandler(platformStartedHandler) {
|
|
12342
|
+
this.platformStartedHandler = platformStartedHandler;
|
|
12343
|
+
return this;
|
|
12344
|
+
}
|
|
12345
|
+
withPlatformErrorHandler(platformErrorHandler) {
|
|
12346
|
+
this.platformErrorHandler = platformErrorHandler;
|
|
12347
|
+
return this;
|
|
12348
|
+
}
|
|
12349
|
+
withPerfProvider(perfProvider) {
|
|
12350
|
+
this.performanceProvider = perfProvider;
|
|
12351
|
+
return this;
|
|
12352
|
+
}
|
|
12353
|
+
withWorkspaceRestoredHandler(workspaceRestoredHandler) {
|
|
12354
|
+
this.workspaceRestoredHandler = workspaceRestoredHandler;
|
|
12355
|
+
this.workspaceStartedHandler = () => () => { };
|
|
12356
|
+
return this;
|
|
12357
|
+
}
|
|
12358
|
+
withWorkspaceStartupHandler(workspaceStartupHandler) {
|
|
12359
|
+
this.workspaceStartupHandler = workspaceStartupHandler;
|
|
12360
|
+
return this;
|
|
12361
|
+
}
|
|
12362
|
+
withWorkspaceFrameCreatedHandler(workspaceFrameCreatedHandler) {
|
|
12363
|
+
this.workspaceFrameCreatedHandler = workspaceFrameCreatedHandler;
|
|
12364
|
+
return this;
|
|
12365
|
+
}
|
|
12366
|
+
withWorkspaceFrameInitHandler(workspaceFrameInitHandler) {
|
|
12367
|
+
this.workspaceFrameInitHandler = workspaceFrameInitHandler;
|
|
12368
|
+
return this;
|
|
12369
|
+
}
|
|
12370
|
+
withWorkspaceFramePageLoadHandler(workspaceFramePageLoadHandler) {
|
|
12371
|
+
this.workspaceFramePageLoadHandler = workspaceFramePageLoadHandler;
|
|
12372
|
+
return this;
|
|
12373
|
+
}
|
|
12374
|
+
withWorkspaceFrameWorkspaceRenderHandler(workspaceFrameWorkspaceRenderHandler) {
|
|
12375
|
+
this.workspaceFrameWorkspaceRenderHandler = workspaceFrameWorkspaceRenderHandler;
|
|
12376
|
+
return this;
|
|
12377
|
+
}
|
|
12378
|
+
withWorkspaceComponentCreatedHandler(workspaceComponentCreatedHandler) {
|
|
12379
|
+
this.workspaceComponentCreatedHandler = workspaceComponentCreatedHandler;
|
|
12380
|
+
return this;
|
|
12381
|
+
}
|
|
12382
|
+
withWorkspaceAppsStartedHandler(workspaceAppsStartedHandler) {
|
|
12383
|
+
this.workspaceAppsStartedHandler = workspaceAppsStartedHandler;
|
|
12384
|
+
return this;
|
|
12385
|
+
}
|
|
12386
|
+
}
|
|
12387
|
+
metricsDependencyBuilder.MetricsDependencyBuilder = MetricsDependencyBuilder;
|
|
12388
|
+
|
|
12389
|
+
var logs = {};
|
|
12390
|
+
|
|
12391
|
+
Object.defineProperty(logs, "__esModule", { value: true });
|
|
12392
|
+
logs.Logs = void 0;
|
|
12393
|
+
const nullManager_1 = nullManager;
|
|
12394
|
+
class Logs {
|
|
12395
|
+
static get instance() {
|
|
12396
|
+
return Logs._instance;
|
|
12397
|
+
}
|
|
12398
|
+
static set instance(manager) {
|
|
12399
|
+
Logs._instance = manager;
|
|
12400
|
+
}
|
|
12401
|
+
static emit(record) {
|
|
12402
|
+
return Logs._instance.emit(record);
|
|
12403
|
+
}
|
|
12404
|
+
}
|
|
12405
|
+
logs.Logs = Logs;
|
|
12406
|
+
Logs._instance = new nullManager_1.NullLogsManager(undefined, undefined, undefined);
|
|
12407
|
+
|
|
12408
|
+
var pluginLoader = {};
|
|
12409
|
+
|
|
12410
|
+
Object.defineProperty(pluginLoader, "__esModule", { value: true });
|
|
12411
|
+
pluginLoader.registerInsightsPlugin = pluginLoader.loadInsightsPlugin = void 0;
|
|
12412
|
+
const returnedPlugins = new Map();
|
|
12413
|
+
function loadInsightsPlugin(name, logger) {
|
|
12414
|
+
if (returnedPlugins.get(name) !== undefined) {
|
|
12415
|
+
return returnedPlugins.get(name);
|
|
12416
|
+
}
|
|
12417
|
+
if (typeof globalThis.ioInsightsPlugins === "undefined") {
|
|
12418
|
+
return null;
|
|
12419
|
+
}
|
|
12420
|
+
let plugin = globalThis.ioInsightsPlugins[name];
|
|
12421
|
+
if (!plugin) {
|
|
12422
|
+
return null;
|
|
12423
|
+
}
|
|
12424
|
+
if (typeof plugin === "function") {
|
|
12425
|
+
try {
|
|
12426
|
+
plugin = plugin();
|
|
12427
|
+
}
|
|
12428
|
+
catch (err) {
|
|
12429
|
+
logger === null || logger === void 0 ? void 0 : logger.error(`Error loading io.Insights plugin ${name}`, err);
|
|
12430
|
+
returnedPlugins.set(name, null);
|
|
12431
|
+
return null;
|
|
12432
|
+
}
|
|
12433
|
+
}
|
|
12434
|
+
returnedPlugins.set(name, plugin);
|
|
12435
|
+
return plugin;
|
|
12436
|
+
}
|
|
12437
|
+
pluginLoader.loadInsightsPlugin = loadInsightsPlugin;
|
|
12438
|
+
function registerInsightsPlugin(name, pluginOrFactoryFunc) {
|
|
12439
|
+
if (typeof globalThis.ioInsightsPlugins === "undefined") {
|
|
12440
|
+
globalThis.ioInsightsPlugins = {};
|
|
12441
|
+
}
|
|
12442
|
+
globalThis.ioInsightsPlugins[name] = pluginOrFactoryFunc;
|
|
12443
|
+
}
|
|
12444
|
+
pluginLoader.registerInsightsPlugin = registerInsightsPlugin;
|
|
12445
|
+
|
|
12446
|
+
var isNode$1 = {};
|
|
12447
|
+
|
|
12448
|
+
Object.defineProperty(isNode$1, "__esModule", { value: true });
|
|
12449
|
+
isNode$1.isNode = void 0;
|
|
12450
|
+
let _isNode;
|
|
12451
|
+
function isNode() {
|
|
12452
|
+
if (typeof _isNode !== "undefined") {
|
|
12453
|
+
return _isNode;
|
|
12454
|
+
}
|
|
12455
|
+
if (typeof window !== "undefined") {
|
|
12456
|
+
_isNode = false;
|
|
12457
|
+
return false;
|
|
12458
|
+
}
|
|
12459
|
+
// Only Node.JS has a process variable that is of [[Class]] process
|
|
12460
|
+
try {
|
|
12461
|
+
_isNode = Object.prototype.toString.call(commonjsGlobal.process) === "[object process]";
|
|
12462
|
+
}
|
|
12463
|
+
catch (e) {
|
|
12464
|
+
_isNode = false;
|
|
12465
|
+
}
|
|
12466
|
+
return _isNode;
|
|
12467
|
+
}
|
|
12468
|
+
isNode$1.isNode = isNode;
|
|
12469
|
+
|
|
12470
|
+
var hasRequiredDist;
|
|
12471
|
+
|
|
12472
|
+
function requireDist () {
|
|
12473
|
+
if (hasRequiredDist) return dist;
|
|
12474
|
+
hasRequiredDist = 1;
|
|
12475
|
+
(function (exports) {
|
|
12476
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12477
|
+
if (k2 === undefined) k2 = k;
|
|
12478
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12479
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12480
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12481
|
+
}
|
|
12482
|
+
Object.defineProperty(o, k2, desc);
|
|
12483
|
+
}) : (function(o, m, k, k2) {
|
|
12484
|
+
if (k2 === undefined) k2 = k;
|
|
12485
|
+
o[k2] = m[k];
|
|
12486
|
+
}));
|
|
12487
|
+
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
12488
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
12489
|
+
}) : function(o, v) {
|
|
12490
|
+
o["default"] = v;
|
|
12491
|
+
});
|
|
12492
|
+
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
12493
|
+
if (mod && mod.__esModule) return mod;
|
|
12494
|
+
var result = {};
|
|
12495
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
12496
|
+
__setModuleDefault(result, mod);
|
|
12497
|
+
return result;
|
|
12498
|
+
};
|
|
12499
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
12500
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12501
|
+
};
|
|
12502
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12503
|
+
exports.SpanStatusCode = exports.deep_value = exports.extractFilteringContextFromArgs = exports.getOTELData = exports.flattenOtelAtributes = exports.safeStringify = exports.isNode = exports.loadInsightsPlugin = exports.registerInsightsPlugin = exports.Logs = exports.NullTracingState = exports.OTEL_PI_KEY = exports.withSpan = exports.Traces = exports.MetricsDependencyBuilder = exports.NullMetric = exports.Container = exports.Log4jsWrapper = exports.Builder = void 0;
|
|
12504
|
+
var builder_1 = requireBuilder();
|
|
12505
|
+
Object.defineProperty(exports, "Builder", { enumerable: true, get: function () { return builder_1.Builder; } });
|
|
12506
|
+
var log4jsWrapper_1 = log4jsWrapper;
|
|
12507
|
+
Object.defineProperty(exports, "Log4jsWrapper", { enumerable: true, get: function () { return log4jsWrapper_1.Log4jsWrapper; } });
|
|
12508
|
+
var container_1 = container;
|
|
12509
|
+
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return container_1.Container; } });
|
|
12510
|
+
var null_1 = _null$1;
|
|
12511
|
+
Object.defineProperty(exports, "NullMetric", { enumerable: true, get: function () { return null_1.NullMetric; } });
|
|
12512
|
+
var metricsDependencyBuilder_1 = metricsDependencyBuilder;
|
|
12513
|
+
Object.defineProperty(exports, "MetricsDependencyBuilder", { enumerable: true, get: function () { return metricsDependencyBuilder_1.MetricsDependencyBuilder; } });
|
|
12514
|
+
const traces_1 = __importStar(requireTraces());
|
|
12515
|
+
exports.Traces = traces_1.default;
|
|
12516
|
+
Object.defineProperty(exports, "withSpan", { enumerable: true, get: function () { return traces_1.withSpan; } });
|
|
12517
|
+
exports.OTEL_PI_KEY = "__interopIOTracePropagationInfo";
|
|
12518
|
+
const nullTracingState_1 = __importDefault(nullTracingState);
|
|
12519
|
+
exports.NullTracingState = nullTracingState_1.default;
|
|
12520
|
+
var logs_1 = logs;
|
|
12521
|
+
Object.defineProperty(exports, "Logs", { enumerable: true, get: function () { return logs_1.Logs; } });
|
|
12522
|
+
const pluginLoader_1 = pluginLoader;
|
|
12523
|
+
Object.defineProperty(exports, "registerInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.registerInsightsPlugin; } });
|
|
12524
|
+
Object.defineProperty(exports, "loadInsightsPlugin", { enumerable: true, get: function () { return pluginLoader_1.loadInsightsPlugin; } });
|
|
12525
|
+
const isNode_1 = isNode$1;
|
|
12526
|
+
Object.defineProperty(exports, "isNode", { enumerable: true, get: function () { return isNode_1.isNode; } });
|
|
12527
|
+
const safe_stringify_1 = safeStringify$1;
|
|
12528
|
+
Object.defineProperty(exports, "safeStringify", { enumerable: true, get: function () { return safe_stringify_1.safeStringify; } });
|
|
12529
|
+
const otelUtils_1 = otelUtils;
|
|
12530
|
+
Object.defineProperty(exports, "getOTELData", { enumerable: true, get: function () { return otelUtils_1.getOTELData; } });
|
|
12531
|
+
Object.defineProperty(exports, "flattenOtelAtributes", { enumerable: true, get: function () { return otelUtils_1.flattenOtelAtributes; } });
|
|
12532
|
+
Object.defineProperty(exports, "extractFilteringContextFromArgs", { enumerable: true, get: function () { return otelUtils_1.extractFilteringContextFromArgs; } });
|
|
12533
|
+
Object.defineProperty(exports, "deep_value", { enumerable: true, get: function () { return otelUtils_1.deep_value; } });
|
|
12534
|
+
if (typeof Promise !== "undefined") {
|
|
12535
|
+
Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(promises.map((p) => p
|
|
12536
|
+
.then((value) => ({
|
|
12537
|
+
status: "fulfilled",
|
|
12538
|
+
value
|
|
12539
|
+
}))
|
|
12540
|
+
.catch((reason) => ({
|
|
12541
|
+
status: "rejected",
|
|
12542
|
+
reason
|
|
12543
|
+
})))));
|
|
12544
|
+
}
|
|
12545
|
+
var SpanStatusCode;
|
|
12546
|
+
(function (SpanStatusCode) {
|
|
12547
|
+
/**
|
|
12548
|
+
* The default status.
|
|
12549
|
+
*/
|
|
12550
|
+
SpanStatusCode[SpanStatusCode["UNSET"] = 0] = "UNSET";
|
|
12551
|
+
/**
|
|
12552
|
+
* The operation has been validated by an Application developer or
|
|
12553
|
+
* Operator to have completed successfully.
|
|
12554
|
+
*/
|
|
12555
|
+
SpanStatusCode[SpanStatusCode["OK"] = 1] = "OK";
|
|
12556
|
+
/**
|
|
12557
|
+
* The operation contains an error.
|
|
12558
|
+
*/
|
|
12559
|
+
SpanStatusCode[SpanStatusCode["ERROR"] = 2] = "ERROR";
|
|
12560
|
+
})(SpanStatusCode || (SpanStatusCode = {}));
|
|
12561
|
+
exports.SpanStatusCode = SpanStatusCode;
|
|
12562
|
+
|
|
12563
|
+
} (dist));
|
|
12564
|
+
return dist;
|
|
12565
|
+
}
|
|
12566
|
+
|
|
12567
|
+
var distExports = requireDist();
|
|
12568
|
+
|
|
12569
|
+
function setInsightsAttributes(settings, ext, glue42gd, nodeStartingContext) {
|
|
12570
|
+
let applicationName = settings.applicationName ?? "unknown-app";
|
|
12571
|
+
if (glue42gd) {
|
|
12572
|
+
applicationName = settings.applicationName ?? glue42gd?.appName ?? applicationName;
|
|
12573
|
+
}
|
|
12574
|
+
if (nodeStartingContext) {
|
|
12575
|
+
applicationName = settings.applicationName ?? nodeStartingContext.applicationConfig.name ?? applicationName;
|
|
12576
|
+
}
|
|
12577
|
+
settings.applicationName = applicationName;
|
|
12578
|
+
if (settings.traces?.closeTrace) {
|
|
12579
|
+
glue42gd?.addCloseHandler(() => distExports.Traces.withSpan("interopio.api.application.close", () => { }));
|
|
12580
|
+
}
|
|
12581
|
+
const sid = glue42gd?.sid;
|
|
12582
|
+
const user = glue42gd?.user;
|
|
12583
|
+
const osUser = (Utils.isNode() && process?.env?.USERNAME) ?? glue42gd?.env?.windowsUserName;
|
|
12584
|
+
const machine = (Utils.isNode() && process?.env?.COMPUTERNAME) ?? glue42gd?.env?.machineName;
|
|
12585
|
+
const env = nodeStartingContext?.env ?? glue42gd?.env?.env;
|
|
12586
|
+
const region = nodeStartingContext?.region ?? glue42gd?.env?.region;
|
|
12587
|
+
const appInstanceId = nodeStartingContext?.instanceId ?? glue42gd?.appInstanceId ?? "";
|
|
12588
|
+
const windowId = glue42gd?.windowId;
|
|
12589
|
+
const extraInsightsContext = {
|
|
12590
|
+
interopioCoreVersion: version,
|
|
12591
|
+
interopioLibVersion: ext.version || version,
|
|
12592
|
+
host: "io.api",
|
|
12593
|
+
tracingAppName: applicationName,
|
|
12594
|
+
tracingAppInstanceId: appInstanceId,
|
|
12595
|
+
user,
|
|
12596
|
+
osUser,
|
|
12597
|
+
machine,
|
|
12598
|
+
env,
|
|
12599
|
+
region,
|
|
12600
|
+
windowId,
|
|
12601
|
+
sid
|
|
12602
|
+
};
|
|
12603
|
+
let providedAdditionalResourceAttributesFunc = settings.additionalResourceAttributes;
|
|
12604
|
+
if (typeof providedAdditionalResourceAttributesFunc !== "function") {
|
|
12605
|
+
const providedAdditionalResourceAttributes = settings.additionalResourceAttributes;
|
|
12606
|
+
providedAdditionalResourceAttributesFunc = () => providedAdditionalResourceAttributes;
|
|
12607
|
+
}
|
|
12608
|
+
settings.additionalResourceAttributes = () => ({
|
|
12609
|
+
...extraInsightsContext,
|
|
12610
|
+
...providedAdditionalResourceAttributesFunc(),
|
|
12611
|
+
});
|
|
12612
|
+
}
|
|
12613
|
+
function setDefaultTraceFilters(settings) {
|
|
12614
|
+
if (!settings.traces) {
|
|
12615
|
+
return;
|
|
12616
|
+
}
|
|
12617
|
+
settings.traces.defaultFilters ??= [];
|
|
12618
|
+
settings.traces.defaultFilters.push({
|
|
12619
|
+
"source": "interopio.api.instrumentation.fetch",
|
|
12620
|
+
"canBeRoot": false
|
|
12621
|
+
});
|
|
12622
|
+
settings.traces.defaultFilters.push({
|
|
12623
|
+
"source": "interopio.api.instrumentation.xhr",
|
|
12624
|
+
"canBeRoot": false
|
|
12625
|
+
});
|
|
12626
|
+
settings.traces.defaultFilters.push({
|
|
12627
|
+
"source": "interopio.api.prefs",
|
|
12628
|
+
"canBeRoot": false
|
|
12629
|
+
});
|
|
12630
|
+
settings.traces.defaultFilters.push({
|
|
12631
|
+
"source": "interopio.api.layouts",
|
|
12632
|
+
"canBeRoot": false
|
|
12633
|
+
});
|
|
12634
|
+
settings.traces.defaultFilters.push({
|
|
12635
|
+
"source": "interopio.api.windows",
|
|
12636
|
+
"canBeRoot": false
|
|
12637
|
+
});
|
|
12638
|
+
settings.traces.defaultFilters.push({
|
|
12639
|
+
"source": "interopio.api.interop",
|
|
12640
|
+
"context": {
|
|
12641
|
+
"stream": "#^t42[.].*"
|
|
12642
|
+
},
|
|
12643
|
+
"canBeRoot": false,
|
|
12644
|
+
"enabled": false
|
|
12645
|
+
});
|
|
12646
|
+
settings.traces.defaultFilters.push({
|
|
12647
|
+
"source": "interopio.api.interop",
|
|
12648
|
+
"context": {
|
|
12649
|
+
"stream": "apps.event"
|
|
12650
|
+
},
|
|
12651
|
+
"canBeRoot": false,
|
|
12652
|
+
"enabled": false
|
|
12653
|
+
});
|
|
12654
|
+
settings.traces.defaultFilters.push({
|
|
12655
|
+
"source": "interopio.api.interop",
|
|
12656
|
+
"context": {
|
|
12657
|
+
"name": "#^t42[.].*"
|
|
12658
|
+
},
|
|
12659
|
+
"canBeRoot": false,
|
|
12660
|
+
"enabled": false
|
|
12661
|
+
});
|
|
12662
|
+
settings.traces.defaultFilters.push({
|
|
12663
|
+
"source": "interopio.api.interop",
|
|
12664
|
+
"context": {
|
|
12665
|
+
"name": "apps.event"
|
|
12666
|
+
},
|
|
12667
|
+
"canBeRoot": false,
|
|
12668
|
+
"enabled": false
|
|
12669
|
+
});
|
|
12670
|
+
settings.traces.defaultFilters.push({
|
|
12671
|
+
"source": "interopio.api.interop",
|
|
12672
|
+
"context": {
|
|
12673
|
+
"method": "apps.command"
|
|
12674
|
+
},
|
|
12675
|
+
"canBeRoot": false
|
|
12676
|
+
});
|
|
12677
|
+
settings.traces.defaultFilters.push({
|
|
12678
|
+
"source": "interopio.api.interop",
|
|
12679
|
+
"context": {
|
|
12680
|
+
"method": "#^t42[.].*"
|
|
12681
|
+
},
|
|
12682
|
+
"canBeRoot": false
|
|
12683
|
+
});
|
|
12684
|
+
settings.traces.defaultFilters.push({
|
|
12685
|
+
"source": "interopio.api.contexts",
|
|
12686
|
+
"context": {
|
|
12687
|
+
"context": "___insights_pi_storage___"
|
|
12688
|
+
},
|
|
12689
|
+
"enabled": false
|
|
12690
|
+
});
|
|
12691
|
+
settings.traces.defaultFilters.push({
|
|
12692
|
+
"source": "interopio.api.contexts",
|
|
12693
|
+
"context": {
|
|
12694
|
+
"context": "#^t42[.].*"
|
|
12695
|
+
},
|
|
12696
|
+
"canBeRoot": false
|
|
12697
|
+
});
|
|
12698
|
+
settings.traces.defaultFilters.push({
|
|
12699
|
+
"source": "interopio.api.contexts",
|
|
12700
|
+
"context": {
|
|
12701
|
+
"context": "#^__.*"
|
|
12702
|
+
},
|
|
12703
|
+
"canBeRoot": false
|
|
12704
|
+
});
|
|
12705
|
+
settings.traces.defaultFilters.push({
|
|
12706
|
+
"source": "interopio.api.appManager",
|
|
12707
|
+
"canBeRoot": false
|
|
12708
|
+
});
|
|
12709
|
+
settings.traces.defaultFilters.push({
|
|
12710
|
+
"source": "interopio.api.notifications",
|
|
12711
|
+
"canBeRoot": false
|
|
12712
|
+
});
|
|
12713
|
+
}
|
|
12714
|
+
|
|
12715
|
+
function prepareConfig (configuration, ext, glue42gd) {
|
|
12716
|
+
let nodeStartingContext;
|
|
12717
|
+
if (Utils.isNode()) {
|
|
12718
|
+
const startingContextString = process.env._GD_STARTING_CONTEXT_;
|
|
12719
|
+
if (startingContextString) {
|
|
12720
|
+
try {
|
|
12721
|
+
nodeStartingContext = JSON.parse(startingContextString);
|
|
12722
|
+
}
|
|
12723
|
+
catch {
|
|
12724
|
+
}
|
|
12725
|
+
}
|
|
12726
|
+
}
|
|
12727
|
+
function getConnection() {
|
|
12728
|
+
const gwConfig = configuration.gateway;
|
|
12729
|
+
const protocolVersion = gwConfig?.protocolVersion ?? 3;
|
|
12730
|
+
const reconnectInterval = gwConfig?.reconnectInterval;
|
|
12731
|
+
const reconnectAttempts = gwConfig?.reconnectAttempts;
|
|
12732
|
+
const defaultWs = "ws://localhost:8385";
|
|
12733
|
+
let ws = gwConfig?.ws;
|
|
12734
|
+
const sharedWorker = gwConfig?.sharedWorker;
|
|
12735
|
+
const inproc = gwConfig?.inproc;
|
|
12736
|
+
const webPlatform = gwConfig?.webPlatform ?? undefined;
|
|
12737
|
+
if (glue42gd) {
|
|
12738
|
+
ws = glue42gd.gwURL;
|
|
12739
|
+
}
|
|
12740
|
+
if (Utils.isNode() && nodeStartingContext && nodeStartingContext.gwURL) {
|
|
12741
|
+
ws = nodeStartingContext.gwURL;
|
|
12742
|
+
}
|
|
12743
|
+
if (!ws && !sharedWorker && !inproc) {
|
|
12744
|
+
ws = defaultWs;
|
|
12745
|
+
}
|
|
12746
|
+
let instanceId;
|
|
12747
|
+
let windowId;
|
|
12748
|
+
let pid;
|
|
12749
|
+
let environment;
|
|
12750
|
+
let region;
|
|
12751
|
+
const appName = getApplication();
|
|
12752
|
+
let uniqueAppName = appName;
|
|
12753
|
+
if (typeof glue42gd !== "undefined") {
|
|
12754
|
+
windowId = glue42gd.windowId;
|
|
12755
|
+
pid = glue42gd.pid;
|
|
12756
|
+
if (glue42gd.env) {
|
|
12757
|
+
environment = glue42gd.env.env;
|
|
12758
|
+
region = glue42gd.env.region;
|
|
12759
|
+
}
|
|
12760
|
+
uniqueAppName = glue42gd.application ?? "glue-app";
|
|
12761
|
+
instanceId = glue42gd.appInstanceId;
|
|
12762
|
+
}
|
|
12763
|
+
else if (Utils.isNode()) {
|
|
12764
|
+
pid = process.pid;
|
|
12765
|
+
if (nodeStartingContext) {
|
|
12766
|
+
environment = nodeStartingContext.env;
|
|
12767
|
+
region = nodeStartingContext.region;
|
|
12768
|
+
instanceId = nodeStartingContext.instanceId;
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
else if (typeof window?.glue42electron !== "undefined") {
|
|
12772
|
+
windowId = window?.glue42electron.instanceId;
|
|
12773
|
+
pid = window?.glue42electron.pid;
|
|
12774
|
+
environment = window?.glue42electron.env;
|
|
12775
|
+
region = window?.glue42electron.region;
|
|
12776
|
+
uniqueAppName = window?.glue42electron.application ?? "glue-app";
|
|
12777
|
+
instanceId = window?.glue42electron.instanceId;
|
|
12778
|
+
}
|
|
12779
|
+
else ;
|
|
12780
|
+
const replaySpecs = configuration.gateway?.replaySpecs ?? [];
|
|
12781
|
+
replaySpecs.push(ContextMessageReplaySpec);
|
|
12782
|
+
let identity = {
|
|
12783
|
+
application: uniqueAppName,
|
|
12784
|
+
applicationName: appName,
|
|
12785
|
+
windowId,
|
|
12786
|
+
instance: instanceId,
|
|
12787
|
+
process: pid,
|
|
12788
|
+
region,
|
|
12789
|
+
environment,
|
|
12790
|
+
api: ext.version || version
|
|
12791
|
+
};
|
|
12792
|
+
if (configuration.identity) {
|
|
12793
|
+
identity = Object.assign(identity, configuration.identity);
|
|
12794
|
+
}
|
|
12795
|
+
return {
|
|
12796
|
+
identity,
|
|
12797
|
+
reconnectInterval,
|
|
12798
|
+
ws,
|
|
12799
|
+
sharedWorker,
|
|
12800
|
+
webPlatform,
|
|
12801
|
+
inproc,
|
|
12802
|
+
protocolVersion,
|
|
12803
|
+
reconnectAttempts,
|
|
12804
|
+
replaySpecs,
|
|
12805
|
+
};
|
|
12806
|
+
}
|
|
12807
|
+
function getContexts() {
|
|
12808
|
+
const defaultConfig = {
|
|
12809
|
+
reAnnounceKnownContexts: true,
|
|
12810
|
+
subscribeOnUpdate: true,
|
|
12811
|
+
subscribeOnGet: true,
|
|
12812
|
+
onlyReAnnounceSubscribedContexts: true
|
|
12813
|
+
};
|
|
12814
|
+
if (typeof configuration.contexts === "undefined") {
|
|
12815
|
+
return defaultConfig;
|
|
12816
|
+
}
|
|
12817
|
+
if (typeof configuration.contexts === "boolean" && configuration.contexts) {
|
|
12818
|
+
return defaultConfig;
|
|
12819
|
+
}
|
|
12820
|
+
if (typeof configuration.contexts === "object") {
|
|
12821
|
+
return { ...defaultConfig, ...configuration.contexts };
|
|
12822
|
+
}
|
|
12823
|
+
return false;
|
|
12824
|
+
}
|
|
12825
|
+
function getApplication() {
|
|
12826
|
+
if (configuration.application) {
|
|
12827
|
+
return configuration.application;
|
|
12828
|
+
}
|
|
12829
|
+
if (glue42gd) {
|
|
12830
|
+
return glue42gd.applicationName;
|
|
12831
|
+
}
|
|
12832
|
+
if (typeof window !== "undefined" && typeof window.glue42electron !== "undefined") {
|
|
12833
|
+
return window.glue42electron.application;
|
|
12834
|
+
}
|
|
12835
|
+
const uid = nanoid(10);
|
|
12836
|
+
if (Utils.isNode()) {
|
|
12837
|
+
if (nodeStartingContext) {
|
|
12838
|
+
return nodeStartingContext.applicationConfig.name;
|
|
12839
|
+
}
|
|
12840
|
+
return "NodeJS" + uid;
|
|
12841
|
+
}
|
|
12842
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
12843
|
+
return document.title + ` (${uid})`;
|
|
12844
|
+
}
|
|
12845
|
+
return uid;
|
|
12846
|
+
}
|
|
12847
|
+
async function getInsights(iodesktop, interop, logger) {
|
|
12848
|
+
const configProp = configuration.insights;
|
|
12849
|
+
if (typeof configProp !== "object" && typeof configProp !== "boolean" && typeof configProp !== "undefined") {
|
|
12850
|
+
throw new Error("insights/otel property should be boolean, object or unspecified");
|
|
12851
|
+
}
|
|
12852
|
+
if (configProp === false) {
|
|
12853
|
+
return { enabled: false };
|
|
12854
|
+
}
|
|
12855
|
+
let gdConfig;
|
|
12856
|
+
if (iodesktop) {
|
|
12857
|
+
gdConfig = iodesktop.insights;
|
|
12858
|
+
}
|
|
12859
|
+
else if (Utils.isNode() && (configuration?.insights !== false &&
|
|
12860
|
+
configuration?.insights?.enabled !== false &&
|
|
12861
|
+
configuration?.insights?.requestSettings !== false)) {
|
|
12862
|
+
gdConfig = (await interop?.invoke("T42.Otel.GetConfig", undefined, nodeStartingContext ? { environment: nodeStartingContext.env, region: nodeStartingContext.region } : undefined, { waitTimeoutMs: 0 })
|
|
12863
|
+
.then(result => result.returned)
|
|
12864
|
+
.catch(err => logger?.warn("Unable to retrieve base io.Insights settings: " +
|
|
12865
|
+
(err?.message ?? err))));
|
|
12866
|
+
}
|
|
12867
|
+
if (gdConfig &&
|
|
12868
|
+
(iodesktop ||
|
|
12869
|
+
nodeStartingContext ||
|
|
12870
|
+
(Utils.isNode() && (typeof configProp === "boolean" || !configProp?.platformInstance)))) {
|
|
12871
|
+
gdConfig = {
|
|
12872
|
+
...gdConfig,
|
|
12873
|
+
metrics: {
|
|
12874
|
+
...gdConfig?.metrics,
|
|
12875
|
+
enabled: !!gdConfig?.metrics?.enabled,
|
|
12876
|
+
platformMetricsEnabled: false
|
|
12877
|
+
}
|
|
12878
|
+
};
|
|
12879
|
+
}
|
|
12880
|
+
let settings;
|
|
12881
|
+
if (configProp === true || typeof configProp === "undefined") {
|
|
12882
|
+
settings = gdConfig ?? { enabled: false };
|
|
12883
|
+
}
|
|
12884
|
+
else {
|
|
12885
|
+
settings = deepMerge(gdConfig || {}, configProp, { isMergeableObject: isPlainObject$2 });
|
|
12886
|
+
}
|
|
12887
|
+
setInsightsAttributes(settings, ext, glue42gd, nodeStartingContext);
|
|
12888
|
+
if (settings.traces?.enabled) {
|
|
12889
|
+
setDefaultTraceFilters(settings);
|
|
12890
|
+
}
|
|
12891
|
+
return settings;
|
|
12892
|
+
}
|
|
12893
|
+
function getAuth() {
|
|
12894
|
+
if (typeof configuration.auth === "string") {
|
|
12895
|
+
return {
|
|
12896
|
+
token: configuration.auth
|
|
12897
|
+
};
|
|
12898
|
+
}
|
|
12899
|
+
if (configuration.auth) {
|
|
12900
|
+
return configuration.auth;
|
|
12901
|
+
}
|
|
12902
|
+
if (Utils.isNode() && nodeStartingContext && nodeStartingContext.gwToken) {
|
|
12903
|
+
return {
|
|
12904
|
+
gatewayToken: nodeStartingContext.gwToken
|
|
12905
|
+
};
|
|
12906
|
+
}
|
|
12907
|
+
if (configuration.gateway?.webPlatform) {
|
|
12908
|
+
return {
|
|
12909
|
+
username: "glue42",
|
|
12910
|
+
password: ""
|
|
12911
|
+
};
|
|
12912
|
+
}
|
|
12913
|
+
}
|
|
12914
|
+
function getLogger() {
|
|
12915
|
+
let config = configuration.logger;
|
|
12916
|
+
const defaultLevel = "warn";
|
|
12917
|
+
if (!config) {
|
|
12918
|
+
config = defaultLevel;
|
|
12919
|
+
}
|
|
12920
|
+
let gdConsoleLevel;
|
|
12921
|
+
if (glue42gd) {
|
|
12922
|
+
gdConsoleLevel = glue42gd.consoleLogLevel;
|
|
12923
|
+
}
|
|
12924
|
+
if (typeof config === "string") {
|
|
12925
|
+
return { console: gdConsoleLevel ?? config, publish: defaultLevel };
|
|
12926
|
+
}
|
|
12927
|
+
return {
|
|
12928
|
+
console: gdConsoleLevel ?? config.console ?? defaultLevel,
|
|
12929
|
+
publish: config.publish ?? defaultLevel
|
|
12930
|
+
};
|
|
12931
|
+
}
|
|
12932
|
+
const connection = getConnection();
|
|
12933
|
+
let application = getApplication();
|
|
12934
|
+
if (typeof window !== "undefined") {
|
|
12935
|
+
const windowAsAny = window;
|
|
12936
|
+
const containerApplication = windowAsAny.htmlContainer ?
|
|
12937
|
+
`${windowAsAny.htmlContainer.containerName}.${windowAsAny.htmlContainer.application}` :
|
|
12938
|
+
windowAsAny?.glue42gd?.application;
|
|
12939
|
+
if (containerApplication) {
|
|
12940
|
+
application = containerApplication;
|
|
12941
|
+
}
|
|
12942
|
+
}
|
|
12943
|
+
return {
|
|
12944
|
+
bus: configuration.bus ?? false,
|
|
12945
|
+
application,
|
|
12946
|
+
auth: getAuth(),
|
|
12947
|
+
logger: getLogger(),
|
|
12948
|
+
connection,
|
|
12949
|
+
metrics: configuration.metrics ?? true,
|
|
12950
|
+
contexts: getContexts(),
|
|
12951
|
+
version: ext.version || version,
|
|
12952
|
+
libs: ext.libs ?? [],
|
|
12953
|
+
customLogger: configuration.customLogger,
|
|
12954
|
+
getInsights
|
|
12955
|
+
};
|
|
12956
|
+
}
|
|
12957
|
+
|
|
12958
|
+
/******************************************************************************
|
|
12959
|
+
Copyright (c) Microsoft Corporation.
|
|
12960
|
+
|
|
12961
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12962
|
+
purpose with or without fee is hereby granted.
|
|
12963
|
+
|
|
12964
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12965
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12966
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12967
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12968
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12969
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
12970
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
12971
|
+
***************************************************************************** */
|
|
12972
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
12973
|
+
|
|
12974
|
+
|
|
12975
|
+
function __decorate(decorators, target, key, desc) {
|
|
12976
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12977
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
12978
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12979
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12980
|
+
}
|
|
12981
|
+
|
|
12982
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
12983
|
+
var e = new Error(message);
|
|
12984
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
12985
|
+
};
|
|
12986
|
+
|
|
12987
|
+
class GW3ContextData {
|
|
12988
|
+
name;
|
|
12989
|
+
contextId;
|
|
12990
|
+
context;
|
|
12991
|
+
isAnnounced;
|
|
12992
|
+
createdByUs;
|
|
12993
|
+
joinedActivity;
|
|
12994
|
+
updateCallbacks = {};
|
|
12995
|
+
activityId;
|
|
12996
|
+
sentExplicitSubscription;
|
|
12997
|
+
get hasReceivedSnapshot() {
|
|
12998
|
+
return this.snapshotPromiseWrapper.resolved;
|
|
12999
|
+
}
|
|
13000
|
+
set hasReceivedSnapshot(has) {
|
|
13001
|
+
if (has) {
|
|
13002
|
+
this.snapshotPromiseWrapper.resolve();
|
|
11022
13003
|
}
|
|
11023
13004
|
else {
|
|
11024
13005
|
this.snapshotPromiseWrapper = new PromiseWrapper();
|
|
@@ -12846,6 +14827,7 @@
|
|
|
12846
14827
|
delete context[key];
|
|
12847
14828
|
});
|
|
12848
14829
|
}
|
|
14830
|
+
distExports.Traces.removePropagationInfo(context);
|
|
12849
14831
|
return context;
|
|
12850
14832
|
}
|
|
12851
14833
|
catch (e) {
|
|
@@ -13052,6 +15034,11 @@
|
|
|
13052
15034
|
if (name in this._creationPromises) {
|
|
13053
15035
|
return this._creationPromises[name];
|
|
13054
15036
|
}
|
|
15037
|
+
const ts = distExports.Traces.currentTracingState;
|
|
15038
|
+
ts.addData("INFO", { context: name });
|
|
15039
|
+
ts.addData("DIAGNOSTIC", { data });
|
|
15040
|
+
data = deepClone(data);
|
|
15041
|
+
ts.injectPropagationInfo(data);
|
|
13055
15042
|
this._creationPromises[name] =
|
|
13056
15043
|
this._gw3Session
|
|
13057
15044
|
.send({
|
|
@@ -13087,15 +15074,21 @@
|
|
|
13087
15074
|
if (delta) {
|
|
13088
15075
|
delta = deepClone(delta);
|
|
13089
15076
|
}
|
|
15077
|
+
const ts = distExports.Traces.currentTracingState;
|
|
13090
15078
|
if (name in this._creationPromises) {
|
|
13091
15079
|
await this._creationPromises[name];
|
|
15080
|
+
distExports.Traces.currentTracingState = ts;
|
|
13092
15081
|
}
|
|
13093
15082
|
const contextData = this._contextNameToData[name];
|
|
15083
|
+
ts.addData("DIAGNOSTIC", { data: contextData });
|
|
15084
|
+
ts.addData("DEBUG", { delta });
|
|
13094
15085
|
if (!contextData || !contextData.isAnnounced) {
|
|
13095
15086
|
await this.createContext(name, delta);
|
|
13096
15087
|
return;
|
|
13097
15088
|
}
|
|
13098
15089
|
const currentContext = await this.get(contextData.name);
|
|
15090
|
+
distExports.Traces.currentTracingState = ts;
|
|
15091
|
+
distExports.Traces.removePropagationInfo(currentContext);
|
|
13099
15092
|
const calculatedDelta = this.setPathSupported ?
|
|
13100
15093
|
this.calculateContextDeltaV2(currentContext, delta) :
|
|
13101
15094
|
this.calculateContextDeltaV1(currentContext, delta);
|
|
@@ -13105,13 +15098,16 @@
|
|
|
13105
15098
|
&& !calculatedDelta.commands?.length) {
|
|
13106
15099
|
return Promise.resolve();
|
|
13107
15100
|
}
|
|
15101
|
+
const calculatedDeltaWithPropagationInfo = deepClone(calculatedDelta);
|
|
15102
|
+
ts.injectPropagationInfo(calculatedDeltaWithPropagationInfo);
|
|
13108
15103
|
const gwResponse = await this._gw3Session
|
|
13109
15104
|
.send({
|
|
13110
15105
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13111
15106
|
domain: "global",
|
|
13112
15107
|
context_id: contextData.contextId,
|
|
13113
|
-
delta:
|
|
15108
|
+
delta: calculatedDeltaWithPropagationInfo,
|
|
13114
15109
|
}, {}, { skipPeerId: false });
|
|
15110
|
+
distExports.Traces.currentTracingState = ts;
|
|
13115
15111
|
if (this._subscribeOnUpdate &&
|
|
13116
15112
|
!contextData.sentExplicitSubscription &&
|
|
13117
15113
|
!contextData.activityId) {
|
|
@@ -13121,6 +15117,7 @@
|
|
|
13121
15117
|
contextData.sentExplicitSubscription ||
|
|
13122
15118
|
contextData.activityId) {
|
|
13123
15119
|
await contextData.snapshotPromise;
|
|
15120
|
+
distExports.Traces.currentTracingState = ts;
|
|
13124
15121
|
this.handleUpdated(contextData, calculatedDelta, {
|
|
13125
15122
|
updaterId: gwResponse.peer_id
|
|
13126
15123
|
});
|
|
@@ -13130,10 +15127,14 @@
|
|
|
13130
15127
|
if (data) {
|
|
13131
15128
|
data = deepClone(data);
|
|
13132
15129
|
}
|
|
15130
|
+
const ts = distExports.Traces.currentTracingState;
|
|
13133
15131
|
if (name in this._creationPromises) {
|
|
13134
15132
|
await this._creationPromises[name];
|
|
15133
|
+
distExports.Traces.currentTracingState = ts;
|
|
13135
15134
|
}
|
|
13136
15135
|
const contextData = this._contextNameToData[name];
|
|
15136
|
+
ts.addData("DIAGNOSTIC", { data: contextData });
|
|
15137
|
+
ts.injectPropagationInfo(data);
|
|
13137
15138
|
if (!contextData || !contextData.isAnnounced) {
|
|
13138
15139
|
return this.createContext(name, data);
|
|
13139
15140
|
}
|
|
@@ -13144,6 +15145,7 @@
|
|
|
13144
15145
|
context_id: contextData.contextId,
|
|
13145
15146
|
delta: { reset: data },
|
|
13146
15147
|
}, {}, { skipPeerId: false });
|
|
15148
|
+
distExports.Traces.currentTracingState = ts;
|
|
13147
15149
|
if (this._subscribeOnUpdate &&
|
|
13148
15150
|
!contextData.sentExplicitSubscription &&
|
|
13149
15151
|
!contextData.activityId) {
|
|
@@ -13164,21 +15166,30 @@
|
|
|
13164
15166
|
}
|
|
13165
15167
|
setPath(name, path, value) {
|
|
13166
15168
|
if (!this.setPathSupported) {
|
|
13167
|
-
return Promise.reject("
|
|
15169
|
+
return Promise.reject(new Error("contexts.setPath operation is not supported, use version 3.10 or later"));
|
|
13168
15170
|
}
|
|
13169
15171
|
return this.setPaths(name, [{ path, value }]);
|
|
13170
15172
|
}
|
|
13171
15173
|
async setPaths(name, pathValues) {
|
|
13172
15174
|
if (!this.setPathSupported) {
|
|
13173
|
-
return Promise.reject("
|
|
15175
|
+
return Promise.reject(new Error("contexts.setPaths operation is not supported, use version 3.10 or later"));
|
|
13174
15176
|
}
|
|
13175
15177
|
if (pathValues) {
|
|
13176
15178
|
pathValues = deepClone(pathValues);
|
|
13177
15179
|
}
|
|
15180
|
+
const ts = distExports.Traces.currentTracingState;
|
|
13178
15181
|
if (name in this._creationPromises) {
|
|
13179
15182
|
await this._creationPromises[name];
|
|
15183
|
+
distExports.Traces.currentTracingState = ts;
|
|
13180
15184
|
}
|
|
13181
15185
|
const contextData = this._contextNameToData[name];
|
|
15186
|
+
ts.addData("DIAGNOSTIC", { data: contextData });
|
|
15187
|
+
ts.addData("DEBUG", { pathValues });
|
|
15188
|
+
const injectionCarrier = { [distExports.OTEL_PI_KEY]: undefined };
|
|
15189
|
+
ts.injectPropagationInfo(injectionCarrier);
|
|
15190
|
+
if (injectionCarrier[distExports.OTEL_PI_KEY]) {
|
|
15191
|
+
pathValues.push({ path: distExports.OTEL_PI_KEY, value: injectionCarrier[distExports.OTEL_PI_KEY] });
|
|
15192
|
+
}
|
|
13182
15193
|
if (!contextData || !contextData.isAnnounced) {
|
|
13183
15194
|
const obj = {};
|
|
13184
15195
|
for (const pathValue of pathValues) {
|
|
@@ -13202,6 +15213,7 @@
|
|
|
13202
15213
|
context_id: contextData.contextId,
|
|
13203
15214
|
delta: { commands }
|
|
13204
15215
|
}, {}, { skipPeerId: false });
|
|
15216
|
+
distExports.Traces.currentTracingState = ts;
|
|
13205
15217
|
if (this._subscribeOnUpdate &&
|
|
13206
15218
|
!contextData.sentExplicitSubscription &&
|
|
13207
15219
|
!contextData.activityId) {
|
|
@@ -13211,6 +15223,7 @@
|
|
|
13211
15223
|
contextData.sentExplicitSubscription ||
|
|
13212
15224
|
contextData.activityId) {
|
|
13213
15225
|
await contextData.snapshotPromise;
|
|
15226
|
+
distExports.Traces.currentTracingState = ts;
|
|
13214
15227
|
this.handleUpdated(contextData, {
|
|
13215
15228
|
added: {},
|
|
13216
15229
|
removed: [],
|
|
@@ -13222,19 +15235,23 @@
|
|
|
13222
15235
|
}
|
|
13223
15236
|
}
|
|
13224
15237
|
async get(name) {
|
|
15238
|
+
const ts = distExports.Traces.currentTracingState;
|
|
15239
|
+
ts.addData("INFO", { context: name });
|
|
13225
15240
|
if (name in this._creationPromises) {
|
|
13226
15241
|
await this._creationPromises[name];
|
|
15242
|
+
distExports.Traces.currentTracingState = ts;
|
|
13227
15243
|
}
|
|
13228
15244
|
const contextData = this._contextNameToData[name];
|
|
13229
15245
|
if (!contextData || !contextData.isAnnounced) {
|
|
13230
15246
|
if (!contextData && this._subscribeOnGet) {
|
|
13231
|
-
this.
|
|
15247
|
+
this.subscribeInner(name, () => { });
|
|
13232
15248
|
}
|
|
13233
15249
|
return Promise.resolve({});
|
|
13234
15250
|
}
|
|
13235
15251
|
if (contextData && !contextData.sentExplicitSubscription) {
|
|
13236
15252
|
return new Promise((resolve, reject) => {
|
|
13237
|
-
this.
|
|
15253
|
+
this.subscribeInner(name, (data, _d, _r, un) => {
|
|
15254
|
+
distExports.Traces.removePropagationInfo(data);
|
|
13238
15255
|
if (!this._subscribeOnGet) {
|
|
13239
15256
|
this.unsubscribe(un);
|
|
13240
15257
|
}
|
|
@@ -13250,15 +15267,18 @@
|
|
|
13250
15267
|
}
|
|
13251
15268
|
await contextData.snapshotPromise;
|
|
13252
15269
|
const context = contextData?.context ?? {};
|
|
15270
|
+
distExports.Traces.removePropagationInfo(context);
|
|
13253
15271
|
return Promise.resolve(deepClone(context));
|
|
13254
15272
|
}
|
|
13255
15273
|
isInvalidContextError(e) {
|
|
13256
15274
|
return e.reason_uri === this.ERROR_URI_INVALID_CONTEXT
|
|
13257
15275
|
|| (e.reason_uri === this.ERROR_URI_FAILURE && e.reason?.startsWith("Unable to find context with id"));
|
|
13258
15276
|
}
|
|
13259
|
-
async
|
|
15277
|
+
async subscribeInner(name, callback, subscriptionKey) {
|
|
15278
|
+
const ts = distExports.Traces.currentTracingState;
|
|
13260
15279
|
if (name in this._creationPromises) {
|
|
13261
15280
|
await this._creationPromises[name];
|
|
15281
|
+
distExports.Traces.currentTracingState = ts;
|
|
13262
15282
|
}
|
|
13263
15283
|
const thisCallbackSubscriptionNumber = typeof subscriptionKey === "undefined" ? this._nextCallbackSubscriptionNumber : subscriptionKey;
|
|
13264
15284
|
if (typeof subscriptionKey === "undefined") {
|
|
@@ -13306,6 +15326,23 @@
|
|
|
13306
15326
|
return Promise.resolve(thisCallbackSubscriptionNumber);
|
|
13307
15327
|
}
|
|
13308
15328
|
}
|
|
15329
|
+
async subscribe(name, callback, subscriptionKey) {
|
|
15330
|
+
const contextExists = this.all().includes(name);
|
|
15331
|
+
const ts = distExports.Traces.currentTracingState;
|
|
15332
|
+
ts.addData("INFO", { context: name, contextExists });
|
|
15333
|
+
const wrappedCallback = async (...args) => {
|
|
15334
|
+
return distExports.withSpan("interopio.api.contexts.bridge.subscribe.callback", { context: name }, args?.[5], (cbts) => {
|
|
15335
|
+
distExports.Traces.removePropagationInfo(args?.[0]);
|
|
15336
|
+
distExports.Traces.removePropagationInfo(args?.[1]);
|
|
15337
|
+
cbts.addData("INFO", { context: name });
|
|
15338
|
+
cbts.addData("DEBUG", { delta: args?.[1] });
|
|
15339
|
+
cbts.addData("DEBUG", { removed: args?.[2] });
|
|
15340
|
+
cbts.addData("DIAGNOSTIC", { data: args?.[0] });
|
|
15341
|
+
return callback(args?.[0], args?.[1], args?.[2], args?.[3], args?.[4]);
|
|
15342
|
+
});
|
|
15343
|
+
};
|
|
15344
|
+
return this.subscribeInner(name, wrappedCallback, subscriptionKey);
|
|
15345
|
+
}
|
|
13309
15346
|
unsubscribe(subscriptionKey, keepInSubscriptionsCache) {
|
|
13310
15347
|
if (!keepInSubscriptionsCache) {
|
|
13311
15348
|
this._contextsSubscriptionsCache = this._contextsSubscriptionsCache.filter(x => x.subKey !== subscriptionKey);
|
|
@@ -13336,8 +15373,11 @@
|
|
|
13336
15373
|
}
|
|
13337
15374
|
}
|
|
13338
15375
|
async destroy(name) {
|
|
15376
|
+
const ts = distExports.Traces.currentTracingState;
|
|
15377
|
+
ts.addData("INFO", { context: name });
|
|
13339
15378
|
if (name in this._creationPromises) {
|
|
13340
15379
|
await this._creationPromises[name];
|
|
15380
|
+
distExports.Traces.currentTracingState = ts;
|
|
13341
15381
|
}
|
|
13342
15382
|
const contextData = this._contextNameToData[name];
|
|
13343
15383
|
const contextId = contextData?.contextId;
|
|
@@ -13475,7 +15515,7 @@
|
|
|
13475
15515
|
if (justSeen ||
|
|
13476
15516
|
!deepEqual(contextData.context, oldContext) ||
|
|
13477
15517
|
updatedMessageType === GW_MESSAGE_SUBSCRIBED_CONTEXT) {
|
|
13478
|
-
this.invokeUpdateCallbacks(contextData, contextUpdatedMsg.delta, { updaterId: contextUpdatedMsg.updater_id });
|
|
15518
|
+
this.invokeUpdateCallbacks(contextData, contextUpdatedMsg.delta ?? contextUpdatedMsg.data, { updaterId: contextUpdatedMsg.updater_id });
|
|
13479
15519
|
}
|
|
13480
15520
|
}
|
|
13481
15521
|
invokeUpdateCallbacks(contextData, delta, extraData) {
|
|
@@ -13499,7 +15539,12 @@
|
|
|
13499
15539
|
if (contextData.updateCallbacks.hasOwnProperty(updateCallbackIndex)) {
|
|
13500
15540
|
try {
|
|
13501
15541
|
const updateCallback = contextData.updateCallbacks[updateCallbackIndex];
|
|
13502
|
-
|
|
15542
|
+
const deltaArg = deepClone({
|
|
15543
|
+
...delta.added,
|
|
15544
|
+
...delta.updated,
|
|
15545
|
+
...delta.reset
|
|
15546
|
+
});
|
|
15547
|
+
updateCallback(deepClone(contextData.context), deltaArg, delta.removed, parseInt(updateCallbackIndex, 10), extraData, distExports.Traces.extractPropagationInfo(delta));
|
|
13503
15548
|
}
|
|
13504
15549
|
catch (err) {
|
|
13505
15550
|
this._logger.debug("callback error: " + JSON.stringify(err));
|
|
@@ -13679,6 +15724,27 @@
|
|
|
13679
15724
|
return new Promise((resolve) => setTimeout(() => resolve(), 0));
|
|
13680
15725
|
}
|
|
13681
15726
|
}
|
|
15727
|
+
__decorate([
|
|
15728
|
+
distExports.withSpan("interopio.api.contexts.bridge.create", { argMapping: ["context"] })
|
|
15729
|
+
], GW3Bridge.prototype, "createContext", null);
|
|
15730
|
+
__decorate([
|
|
15731
|
+
distExports.withSpan("interopio.api.contexts.bridge.update", { argMapping: ["context"] })
|
|
15732
|
+
], GW3Bridge.prototype, "update", null);
|
|
15733
|
+
__decorate([
|
|
15734
|
+
distExports.withSpan("interopio.api.contexts.bridge.set", { argMapping: ["context"] })
|
|
15735
|
+
], GW3Bridge.prototype, "set", null);
|
|
15736
|
+
__decorate([
|
|
15737
|
+
distExports.withSpan("interopio.api.contexts.bridge.setPaths", { argMapping: ["context"] })
|
|
15738
|
+
], GW3Bridge.prototype, "setPaths", null);
|
|
15739
|
+
__decorate([
|
|
15740
|
+
distExports.withSpan("interopio.api.contexts.bridge.get", { argMapping: ["context"] })
|
|
15741
|
+
], GW3Bridge.prototype, "get", null);
|
|
15742
|
+
__decorate([
|
|
15743
|
+
distExports.withSpan("interopio.api.contexts.bridge.subscribe", { argMapping: ["context"] })
|
|
15744
|
+
], GW3Bridge.prototype, "subscribe", null);
|
|
15745
|
+
__decorate([
|
|
15746
|
+
distExports.withSpan("interopio.api.contexts.bridge.destroy", { argMapping: ["context"] })
|
|
15747
|
+
], GW3Bridge.prototype, "destroy", null);
|
|
13682
15748
|
|
|
13683
15749
|
class ContextsModule {
|
|
13684
15750
|
initTime;
|
|
@@ -13766,6 +15832,21 @@
|
|
|
13766
15832
|
}
|
|
13767
15833
|
}
|
|
13768
15834
|
}
|
|
15835
|
+
__decorate([
|
|
15836
|
+
distExports.withSpan("interopio.api.contexts.module.update", { argMapping: ["context"] })
|
|
15837
|
+
], ContextsModule.prototype, "update", null);
|
|
15838
|
+
__decorate([
|
|
15839
|
+
distExports.withSpan("interopio.api.contexts.module.set", { argMapping: ["context"] })
|
|
15840
|
+
], ContextsModule.prototype, "set", null);
|
|
15841
|
+
__decorate([
|
|
15842
|
+
distExports.withSpan("interopio.api.contexts.module.setPaths", { argMapping: ["context"] })
|
|
15843
|
+
], ContextsModule.prototype, "setPaths", null);
|
|
15844
|
+
__decorate([
|
|
15845
|
+
distExports.withSpan("interopio.api.contexts.module.subscribe", { argMapping: ["context"] })
|
|
15846
|
+
], ContextsModule.prototype, "subscribe", null);
|
|
15847
|
+
__decorate([
|
|
15848
|
+
distExports.withSpan("interopio.api.contexts.module.destroy", { argMapping: ["context"] })
|
|
15849
|
+
], ContextsModule.prototype, "destroy", null);
|
|
13769
15850
|
|
|
13770
15851
|
function promisify (promise, successCallback, errorCallback) {
|
|
13771
15852
|
if (typeof successCallback !== "function" && typeof errorCallback !== "function") {
|
|
@@ -14641,6 +16722,9 @@
|
|
|
14641
16722
|
this.configuration = configuration;
|
|
14642
16723
|
}
|
|
14643
16724
|
subscribe(method, options, successCallback, errorCallback, existingSub) {
|
|
16725
|
+
const ts = distExports.Traces.currentTracingState;
|
|
16726
|
+
ts.addData("INFO", { stream: Utils.getMethodName(method) });
|
|
16727
|
+
ts.addData("INFO", { options });
|
|
14644
16728
|
const callProtocolSubscribe = (targetServers, stream, successProxy, errorProxy) => {
|
|
14645
16729
|
options.methodResponseTimeout = options.methodResponseTimeout ?? options.waitTimeoutMs;
|
|
14646
16730
|
this.protocol.client.subscribe(stream, options, targetServers, successProxy, errorProxy, existingSub);
|
|
@@ -14765,6 +16849,10 @@
|
|
|
14765
16849
|
});
|
|
14766
16850
|
}
|
|
14767
16851
|
async invoke(methodFilter, argumentObj, target, additionalOptions, success, error) {
|
|
16852
|
+
const ts = distExports.Traces.currentTracingState;
|
|
16853
|
+
ts.addData("INFO", { method: Utils.getMethodName(methodFilter) });
|
|
16854
|
+
ts.addData("INFO", { target, additionalOptions });
|
|
16855
|
+
ts.addData("DIAGNOSTIC", { arguments: argumentObj });
|
|
14768
16856
|
const getInvokePromise = async () => {
|
|
14769
16857
|
const methodDefinition = typeof methodFilter === "string" ? { name: methodFilter } : { ...methodFilter };
|
|
14770
16858
|
if (!argumentObj) {
|
|
@@ -14825,23 +16913,10 @@
|
|
|
14825
16913
|
return Promise.reject(this.generateInvalidInputInvocationResult(message, methodDefinition, argumentObj));
|
|
14826
16914
|
}
|
|
14827
16915
|
}
|
|
14828
|
-
const timeout = additionalOptions.methodResponseTimeoutMs;
|
|
16916
|
+
const timeout = additionalOptions.methodResponseTimeoutMs ?? 30000;
|
|
14829
16917
|
const additionalOptionsCopy = additionalOptions;
|
|
14830
|
-
const
|
|
14831
|
-
|
|
14832
|
-
const method = serversMethodPair.methods[0];
|
|
14833
|
-
const server = serversMethodPair.server;
|
|
14834
|
-
const invokePromise = this.protocol.client.invoke(invId, method, argumentObj, server, additionalOptionsCopy);
|
|
14835
|
-
return Promise.race([
|
|
14836
|
-
invokePromise,
|
|
14837
|
-
rejectAfter(timeout, invokePromise, {
|
|
14838
|
-
invocationId: invId,
|
|
14839
|
-
message: `Invocation timeout (${timeout} ms) reached for method name: ${method?.name}, target instance: ${JSON.stringify(server.instance)}, options: ${JSON.stringify(additionalOptionsCopy)}`,
|
|
14840
|
-
status: InvokeStatus.Error,
|
|
14841
|
-
})
|
|
14842
|
-
]);
|
|
14843
|
-
});
|
|
14844
|
-
const invocationMessages = await Promise.all(invokePromises);
|
|
16918
|
+
const serverInvokePromises = serversMethodMap.map((smp) => this.getServerInvokePromise(smp.methods[0], smp.server, argumentObj, additionalOptionsCopy, timeout));
|
|
16919
|
+
const invocationMessages = await Promise.all(serverInvokePromises);
|
|
14845
16920
|
const results = this.getInvocationResultObj(invocationMessages, methodDefinition, argumentObj);
|
|
14846
16921
|
const allRejected = invocationMessages.every((result) => result.status === InvokeStatus.Error);
|
|
14847
16922
|
if (allRejected) {
|
|
@@ -14851,6 +16926,27 @@
|
|
|
14851
16926
|
};
|
|
14852
16927
|
return promisify(getInvokePromise(), success, error);
|
|
14853
16928
|
}
|
|
16929
|
+
async getServerInvokePromise(method, server, argumentObj, additionalOptionsCopy, timeout) {
|
|
16930
|
+
const invId = nanoid(10);
|
|
16931
|
+
const ts = distExports.Traces.currentTracingState;
|
|
16932
|
+
if (argumentObj) {
|
|
16933
|
+
argumentObj = deepClone(argumentObj);
|
|
16934
|
+
ts.injectPropagationInfo(argumentObj);
|
|
16935
|
+
}
|
|
16936
|
+
ts.addData("INFO", { "server": server?.id, instance: server?.instance });
|
|
16937
|
+
ts.addData("INFO", { "invocationId": invId });
|
|
16938
|
+
const invokePromise = this.protocol.client.invoke(invId, method, argumentObj, server, additionalOptionsCopy);
|
|
16939
|
+
const returnValue = await Promise.race([
|
|
16940
|
+
invokePromise,
|
|
16941
|
+
rejectAfter(timeout, invokePromise, {
|
|
16942
|
+
invocationId: invId,
|
|
16943
|
+
message: `Invocation timeout (${timeout} ms) reached for method name: ${method?.name}, target instance: ${JSON.stringify(server.instance)}, options: ${JSON.stringify(additionalOptionsCopy)}`,
|
|
16944
|
+
status: InvokeStatus.Error,
|
|
16945
|
+
})
|
|
16946
|
+
]);
|
|
16947
|
+
ts.addData("DIAGNOSTIC", { returnValue });
|
|
16948
|
+
return returnValue;
|
|
16949
|
+
}
|
|
14854
16950
|
generateInvalidInputInvocationResult(message, methodDefinition, argumentObj) {
|
|
14855
16951
|
const method = {
|
|
14856
16952
|
...methodDefinition,
|
|
@@ -14867,6 +16963,7 @@
|
|
|
14867
16963
|
return this.getInvocationResultObj([invokeResultMessage], method, argumentObj);
|
|
14868
16964
|
}
|
|
14869
16965
|
getInvocationResultObj(invocationResults, method, calledWith) {
|
|
16966
|
+
distExports.Traces.removePropagationInfo(calledWith);
|
|
14870
16967
|
const all_return_values = invocationResults
|
|
14871
16968
|
.filter((invokeMessage) => invokeMessage.status === InvokeStatus.Success)
|
|
14872
16969
|
.reduce((allValues, currentValue) => {
|
|
@@ -15070,6 +17167,15 @@
|
|
|
15070
17167
|
return this.filterByTarget(target, serversMethodMap);
|
|
15071
17168
|
}
|
|
15072
17169
|
}
|
|
17170
|
+
__decorate([
|
|
17171
|
+
distExports.withSpan("interopio.api.interop.stream.subscribe", { argMapping: (methodDefinition) => ({ stream: Utils.getMethodName(methodDefinition) }) })
|
|
17172
|
+
], Client.prototype, "subscribe", null);
|
|
17173
|
+
__decorate([
|
|
17174
|
+
distExports.withSpan("interopio.api.interop.invoke", { argMapping: (methodDefinition) => ({ method: Utils.getMethodName(methodDefinition) }) })
|
|
17175
|
+
], Client.prototype, "invoke", null);
|
|
17176
|
+
__decorate([
|
|
17177
|
+
distExports.withSpan("interopio.api.interop.invoke.server", { argMapping: { "0.name": "method" } })
|
|
17178
|
+
], Client.prototype, "getServerInvokePromise", null);
|
|
15073
17179
|
|
|
15074
17180
|
class ServerSubscription {
|
|
15075
17181
|
protocol;
|
|
@@ -15235,9 +17341,9 @@
|
|
|
15235
17341
|
flags: def2.flags?.metadata,
|
|
15236
17342
|
};
|
|
15237
17343
|
}
|
|
15238
|
-
close() {
|
|
17344
|
+
async close() {
|
|
15239
17345
|
this._protocol.server.closeAllSubscriptions(this._repoMethod);
|
|
15240
|
-
this._server.unregister(this._repoMethod.definition, true);
|
|
17346
|
+
return this._server.unregister(this._repoMethod.definition, true);
|
|
15241
17347
|
}
|
|
15242
17348
|
push(data, branches) {
|
|
15243
17349
|
if (typeof branches !== "string" && !Array.isArray(branches) && branches !== undefined) {
|
|
@@ -15246,12 +17352,23 @@
|
|
|
15246
17352
|
if (typeof data !== "object") {
|
|
15247
17353
|
throw new Error("Invalid arguments. Data must be an object.");
|
|
15248
17354
|
}
|
|
17355
|
+
const ts = distExports.Traces.currentTracingState;
|
|
17356
|
+
ts.addData("INFO", { stream: this?.name, branches });
|
|
17357
|
+
ts.addData("DIAGNOSTIC", { data });
|
|
17358
|
+
data = deepClone(data);
|
|
17359
|
+
ts.injectPropagationInfo(data);
|
|
15249
17360
|
this._protocol.server.pushData(this._repoMethod, data, branches);
|
|
15250
17361
|
}
|
|
15251
17362
|
updateRepoMethod(repoMethod) {
|
|
15252
17363
|
this._repoMethod = repoMethod;
|
|
15253
17364
|
}
|
|
15254
17365
|
}
|
|
17366
|
+
__decorate([
|
|
17367
|
+
distExports.withSpan("interopio.api.interop.stream.close", { thisMapping: { name: "stream" } })
|
|
17368
|
+
], ServerStream.prototype, "close", null);
|
|
17369
|
+
__decorate([
|
|
17370
|
+
distExports.withSpan("interopio.api.interop.stream.push", { thisMapping: { name: "stream" } })
|
|
17371
|
+
], ServerStream.prototype, "push", null);
|
|
15255
17372
|
|
|
15256
17373
|
class Server {
|
|
15257
17374
|
protocol;
|
|
@@ -15326,14 +17443,18 @@
|
|
|
15326
17443
|
if (!methodDefinition) {
|
|
15327
17444
|
return Promise.reject("Method definition is required. Please, provide either a unique string for a method name or a “methodDefinition” object with a required “name” property.");
|
|
15328
17445
|
}
|
|
17446
|
+
const ts = distExports.Traces.currentTracingState;
|
|
17447
|
+
ts.addData("INFO", { method: Utils.getMethodName(methodDefinition) });
|
|
15329
17448
|
if (typeof callback !== "function") {
|
|
15330
|
-
return Promise.reject(`The second parameter must be a callback function. Method: ${
|
|
17449
|
+
return Promise.reject(`The second parameter must be a callback function. Method: ${Utils.getMethodName(methodDefinition)}`);
|
|
15331
17450
|
}
|
|
15332
17451
|
const wrappedCallbackFunction = async (context, resultCallback) => {
|
|
15333
17452
|
try {
|
|
15334
17453
|
const result = callback(context.args, context.instance);
|
|
15335
17454
|
if (result && typeof result.then === "function") {
|
|
17455
|
+
const cbts = distExports.Traces.currentTracingState;
|
|
15336
17456
|
const resultValue = await result;
|
|
17457
|
+
distExports.Traces.currentTracingState = cbts;
|
|
15337
17458
|
resultCallback(undefined, resultValue);
|
|
15338
17459
|
}
|
|
15339
17460
|
else {
|
|
@@ -15351,8 +17472,10 @@
|
|
|
15351
17472
|
if (!methodDefinition) {
|
|
15352
17473
|
return Promise.reject("Method definition is required. Please, provide either a unique string for a method name or a “methodDefinition” object with a required “name” property.");
|
|
15353
17474
|
}
|
|
17475
|
+
const ts = distExports.Traces.currentTracingState;
|
|
17476
|
+
ts.addData("INFO", { method: Utils.getMethodName(methodDefinition) });
|
|
15354
17477
|
if (typeof callback !== "function") {
|
|
15355
|
-
return Promise.reject(`The second parameter must be a callback function. Method: ${
|
|
17478
|
+
return Promise.reject(`The second parameter must be a callback function. Method: ${Utils.getMethodName(methodDefinition)}`);
|
|
15356
17479
|
}
|
|
15357
17480
|
const wrappedCallback = async (context, resultCallback) => {
|
|
15358
17481
|
try {
|
|
@@ -15390,6 +17513,8 @@
|
|
|
15390
17513
|
if (methodFilter === undefined) {
|
|
15391
17514
|
return Promise.reject("Please, provide either a unique string for a name or an object containing a “name” property.");
|
|
15392
17515
|
}
|
|
17516
|
+
const ts = distExports.Traces.currentTracingState;
|
|
17517
|
+
ts.addData("INFO", { method: Utils.getMethodName(methodFilter) });
|
|
15393
17518
|
if (typeof methodFilter === "function") {
|
|
15394
17519
|
await this.unregisterWithPredicate(methodFilter, forStream);
|
|
15395
17520
|
return;
|
|
@@ -15479,33 +17604,62 @@
|
|
|
15479
17604
|
});
|
|
15480
17605
|
}
|
|
15481
17606
|
onMethodInvoked(methodToExecute, invocationId, invocationArgs) {
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
}
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
17607
|
+
const propagationInfo = distExports.Traces.extractPropagationInfo(invocationArgs.args, true);
|
|
17608
|
+
distExports.withSpan("interopio.api.interop.register.callback", { method: methodToExecute?.definition?.name }, propagationInfo, (ts) => {
|
|
17609
|
+
ts.addData("INFO", { method: methodToExecute?.definition?.name });
|
|
17610
|
+
ts.addData("INFO", { invocationId });
|
|
17611
|
+
ts.addData("INFO", { invoker: invocationArgs?.instance });
|
|
17612
|
+
ts.addData("DIAGNOSTIC", { arguments: invocationArgs?.args });
|
|
17613
|
+
if (!methodToExecute || !methodToExecute.theFunction) {
|
|
17614
|
+
ts.status = { code: distExports.SpanStatusCode.ERROR, message: "Required argument 'methodToExecute' is missing." };
|
|
17615
|
+
return;
|
|
17616
|
+
}
|
|
17617
|
+
let resolveWithSpanCallback;
|
|
17618
|
+
const withSpanCallbackPromise = new Promise(resolve => {
|
|
17619
|
+
resolveWithSpanCallback = resolve;
|
|
17620
|
+
});
|
|
17621
|
+
methodToExecute.theFunction(invocationArgs, (err, result) => {
|
|
17622
|
+
if (err !== undefined && err !== null) {
|
|
17623
|
+
if (err.message && typeof err.message === "string") {
|
|
17624
|
+
err = err.message;
|
|
15493
17625
|
}
|
|
15494
|
-
|
|
15495
|
-
|
|
17626
|
+
else if (typeof err !== "string") {
|
|
17627
|
+
try {
|
|
17628
|
+
err = JSON.stringify(err);
|
|
17629
|
+
}
|
|
17630
|
+
catch (unStrException) {
|
|
17631
|
+
err = `un-stringifyable error in onMethodInvoked! Top level prop names: ${Object.keys(err)}`;
|
|
17632
|
+
}
|
|
15496
17633
|
}
|
|
17634
|
+
ts.status = { code: distExports.SpanStatusCode.ERROR, message: err };
|
|
17635
|
+
ts.recordException(err);
|
|
15497
17636
|
}
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
17637
|
+
if (!result) {
|
|
17638
|
+
result = {};
|
|
17639
|
+
}
|
|
17640
|
+
else if (typeof result !== "object" || Array.isArray(result)) {
|
|
17641
|
+
result = { _value: result };
|
|
17642
|
+
}
|
|
17643
|
+
ts.addData("DIAGNOSTIC", { returnValue: result });
|
|
17644
|
+
this.protocol.server.methodInvocationResult(methodToExecute, invocationId, err, result);
|
|
17645
|
+
resolveWithSpanCallback();
|
|
17646
|
+
});
|
|
17647
|
+
return withSpanCallbackPromise;
|
|
15506
17648
|
});
|
|
15507
17649
|
}
|
|
15508
17650
|
}
|
|
17651
|
+
__decorate([
|
|
17652
|
+
distExports.withSpan("interopio.api.interop.stream.create", { argMapping: (methodDefinition) => ({ stream: Utils.getMethodName(methodDefinition) }) })
|
|
17653
|
+
], Server.prototype, "createStream", null);
|
|
17654
|
+
__decorate([
|
|
17655
|
+
distExports.withSpan("interopio.api.interop.register", { argMapping: (methodDefinition) => ({ method: Utils.getMethodName(methodDefinition) }) })
|
|
17656
|
+
], Server.prototype, "register", null);
|
|
17657
|
+
__decorate([
|
|
17658
|
+
distExports.withSpan("interopio.api.interop.register.async", { argMapping: (methodDefinition) => ({ method: Utils.getMethodName(methodDefinition) }) })
|
|
17659
|
+
], Server.prototype, "registerAsync", null);
|
|
17660
|
+
__decorate([
|
|
17661
|
+
distExports.withSpan("interopio.api.interop.unregister", { argMapping: (methodDefinition) => ({ method: Utils.getMethodName(methodDefinition) }) })
|
|
17662
|
+
], Server.prototype, "unregister", null);
|
|
15509
17663
|
|
|
15510
17664
|
class InstanceWrapper {
|
|
15511
17665
|
wrapped = {};
|
|
@@ -16342,6 +18496,7 @@
|
|
|
16342
18496
|
session.on("subscription-cancelled", this.handleSubscriptionCancelled);
|
|
16343
18497
|
}
|
|
16344
18498
|
subscribe(streamingMethod, params, targetServers, success, error, existingSub) {
|
|
18499
|
+
distExports.Traces.removePropagationInfo(params.arguments);
|
|
16345
18500
|
if (targetServers.length === 0) {
|
|
16346
18501
|
error({
|
|
16347
18502
|
method: streamingMethod,
|
|
@@ -16477,7 +18632,7 @@
|
|
|
16477
18632
|
"{}";
|
|
16478
18633
|
pendingSub.error({
|
|
16479
18634
|
message: ERR_MSG_SUB_REJECTED + reason + " Called with:" + callArgs,
|
|
16480
|
-
called_with: pendingSub.params.arguments,
|
|
18635
|
+
called_with: distExports.Traces.removePropagationInfo(pendingSub.params.arguments),
|
|
16481
18636
|
method: pendingSub.method,
|
|
16482
18637
|
});
|
|
16483
18638
|
}
|
|
@@ -16545,7 +18700,7 @@
|
|
|
16545
18700
|
const isPrivateData = msg.oob;
|
|
16546
18701
|
const sendingServerId = trackedServersFound[0].serverId;
|
|
16547
18702
|
const server = this.repository.getServerById(sendingServerId);
|
|
16548
|
-
const
|
|
18703
|
+
const getReceivedStreamData = () => {
|
|
16549
18704
|
return {
|
|
16550
18705
|
data: msg.data,
|
|
16551
18706
|
server: server?.instance ?? {},
|
|
@@ -16556,16 +18711,29 @@
|
|
|
16556
18711
|
};
|
|
16557
18712
|
const onDataHandlers = subscription.handlers.onData;
|
|
16558
18713
|
const queuedData = subscription.queued.data;
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
}
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
18714
|
+
const rsd = getReceivedStreamData();
|
|
18715
|
+
const pi = distExports.Traces.extractPropagationInfo(rsd.data, true);
|
|
18716
|
+
const methodName = subscription?.method?.name;
|
|
18717
|
+
distExports.withSpan("interopio.api.interop.stream.onData", {
|
|
18718
|
+
method: methodName,
|
|
18719
|
+
stream: methodName
|
|
18720
|
+
}, pi, () => {
|
|
18721
|
+
const ts = distExports.Traces.currentTracingState;
|
|
18722
|
+
ts.addData("INFO", { method: methodName });
|
|
18723
|
+
ts.addData("INFO", { stream: methodName });
|
|
18724
|
+
ts.addData("INFO", { handlerCount: onDataHandlers?.length });
|
|
18725
|
+
ts.addData("DIAGNOSTIC", { data: rsd });
|
|
18726
|
+
if (onDataHandlers.length > 0) {
|
|
18727
|
+
onDataHandlers.forEach((callback) => {
|
|
18728
|
+
if (typeof callback === "function") {
|
|
18729
|
+
callback(deepClone(rsd));
|
|
18730
|
+
}
|
|
18731
|
+
});
|
|
18732
|
+
}
|
|
18733
|
+
else {
|
|
18734
|
+
queuedData.push(deepClone(rsd));
|
|
18735
|
+
}
|
|
18736
|
+
});
|
|
16569
18737
|
};
|
|
16570
18738
|
handleSubscriptionCancelled = (msg) => {
|
|
16571
18739
|
const subLocalKey = this.subscriptionIdToLocalKeyMap[msg.subscription_id];
|
|
@@ -16963,7 +19131,16 @@
|
|
|
16963
19131
|
return this.readyPromise;
|
|
16964
19132
|
}
|
|
16965
19133
|
publish = (topic, data, options) => {
|
|
19134
|
+
this.publishCore(topic, data, options);
|
|
19135
|
+
};
|
|
19136
|
+
publishCore(topic, data, options) {
|
|
16966
19137
|
const { routingKey, target } = options || {};
|
|
19138
|
+
const ts = distExports.Traces.currentTracingState;
|
|
19139
|
+
ts.addData("INFO", { topic });
|
|
19140
|
+
ts.addData("DIAGNOSTIC", { data });
|
|
19141
|
+
ts.addData("INFO", { routingKey, target });
|
|
19142
|
+
data = deepClone(data);
|
|
19143
|
+
ts.injectPropagationInfo(data);
|
|
16967
19144
|
const args = this.removeEmptyValues({
|
|
16968
19145
|
type: "publish",
|
|
16969
19146
|
topic,
|
|
@@ -16976,10 +19153,17 @@
|
|
|
16976
19153
|
.catch((err) => {
|
|
16977
19154
|
this.logger.error(`Failed to publish message to topic ${topic} with routing key ${routingKey} for ${JSON.stringify(target)}: ${JSON.stringify(err)}`);
|
|
16978
19155
|
});
|
|
16979
|
-
}
|
|
19156
|
+
}
|
|
19157
|
+
;
|
|
16980
19158
|
subscribe = (topic, callback, options) => {
|
|
19159
|
+
return this.subscribeCore(topic, callback, options);
|
|
19160
|
+
};
|
|
19161
|
+
subscribeCore(topic, callback, options) {
|
|
16981
19162
|
return new Promise((resolve, reject) => {
|
|
16982
19163
|
const { routingKey, target } = options || {};
|
|
19164
|
+
const ts = distExports.Traces.currentTracingState;
|
|
19165
|
+
ts.addData("INFO", { topic });
|
|
19166
|
+
ts.addData("INFO", { routingKey, target });
|
|
16983
19167
|
const args = this.removeEmptyValues({
|
|
16984
19168
|
type: "subscribe",
|
|
16985
19169
|
topic,
|
|
@@ -16990,7 +19174,16 @@
|
|
|
16990
19174
|
this.session.send(args)
|
|
16991
19175
|
.then((response) => {
|
|
16992
19176
|
const { subscription_id } = response;
|
|
16993
|
-
|
|
19177
|
+
ts.addData("INFO", { subscription_id });
|
|
19178
|
+
const tracedCallback = function (...tracedCallbackArgs) {
|
|
19179
|
+
const propagationInfo = distExports.Traces.extractPropagationInfo(tracedCallbackArgs?.[0], true);
|
|
19180
|
+
distExports.withSpan("interopio.api.bus.subscribe.callback", { topic }, propagationInfo, (cbts) => {
|
|
19181
|
+
cbts.addData("INFO", { topic, subscription_id });
|
|
19182
|
+
cbts.addData("DIAGNOSTIC", { data: tracedCallbackArgs?.[0] });
|
|
19183
|
+
callback.apply(this, tracedCallbackArgs);
|
|
19184
|
+
});
|
|
19185
|
+
};
|
|
19186
|
+
this.subscriptions.push({ subscription_id, topic, callback: tracedCallback, source: target });
|
|
16994
19187
|
resolve({
|
|
16995
19188
|
unsubscribe: () => {
|
|
16996
19189
|
this.session.send({ type: "unsubscribe", subscription_id, peer_id: this.peerId })
|
|
@@ -17005,7 +19198,8 @@
|
|
|
17005
19198
|
})
|
|
17006
19199
|
.catch((error) => reject(error));
|
|
17007
19200
|
});
|
|
17008
|
-
}
|
|
19201
|
+
}
|
|
19202
|
+
;
|
|
17009
19203
|
watchOnEvent = () => {
|
|
17010
19204
|
this.session.on("event", (args) => {
|
|
17011
19205
|
const { data, subscription_id } = args;
|
|
@@ -17043,10 +19237,74 @@
|
|
|
17043
19237
|
return allMatch;
|
|
17044
19238
|
}
|
|
17045
19239
|
}
|
|
19240
|
+
__decorate([
|
|
19241
|
+
distExports.withSpan("interopio.api.bus.publish", { argMapping: ["topic"] })
|
|
19242
|
+
], MessageBus.prototype, "publishCore", null);
|
|
19243
|
+
__decorate([
|
|
19244
|
+
distExports.withSpan("interopio.api.bus.subscribe", { argMapping: ["topic"] })
|
|
19245
|
+
], MessageBus.prototype, "subscribeCore", null);
|
|
19246
|
+
|
|
19247
|
+
function replaceComplexProperties(obj) {
|
|
19248
|
+
if (isPrimitiveOrFunction(obj)) {
|
|
19249
|
+
return;
|
|
19250
|
+
}
|
|
19251
|
+
for (const prop in obj) {
|
|
19252
|
+
if (!obj.hasOwnProperty(prop)) {
|
|
19253
|
+
continue;
|
|
19254
|
+
}
|
|
19255
|
+
const value = obj[prop];
|
|
19256
|
+
if (isPrimitiveOrFunction(value)) {
|
|
19257
|
+
continue;
|
|
19258
|
+
}
|
|
19259
|
+
if (isPlainObject$2(value) || Array.isArray(value)) {
|
|
19260
|
+
replaceComplexProperties(value);
|
|
19261
|
+
continue;
|
|
19262
|
+
}
|
|
19263
|
+
obj[prop] = value?.constructor?.name || value.toString();
|
|
19264
|
+
}
|
|
19265
|
+
}
|
|
19266
|
+
function isPrimitiveOrFunction(obj) {
|
|
19267
|
+
if (!obj) {
|
|
19268
|
+
return true;
|
|
19269
|
+
}
|
|
19270
|
+
if (obj !== Object(obj)) {
|
|
19271
|
+
return true;
|
|
19272
|
+
}
|
|
19273
|
+
if (typeof obj === "function") {
|
|
19274
|
+
return true;
|
|
19275
|
+
}
|
|
19276
|
+
return false;
|
|
19277
|
+
}
|
|
19278
|
+
|
|
19279
|
+
async function loadInsightsPlugins(logger, settings) {
|
|
19280
|
+
try {
|
|
19281
|
+
(await Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder; })).init();
|
|
19282
|
+
}
|
|
19283
|
+
catch {
|
|
19284
|
+
logger.warn("@interopio/insights-base plugin failed to load, insights will be disabled");
|
|
19285
|
+
}
|
|
19286
|
+
if (settings.metrics?.enabled) {
|
|
19287
|
+
try {
|
|
19288
|
+
(await Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder; })).init();
|
|
19289
|
+
}
|
|
19290
|
+
catch {
|
|
19291
|
+
logger.warn("@interopio/insights-metrics plugin failed to load, insights metrics functionality will be disabled");
|
|
19292
|
+
}
|
|
19293
|
+
}
|
|
19294
|
+
if (settings.traces?.enabled) {
|
|
19295
|
+
try {
|
|
19296
|
+
(await Promise.resolve().then(function () { return _rollup_plugin_ignore_empty_module_placeholder; })).init();
|
|
19297
|
+
}
|
|
19298
|
+
catch {
|
|
19299
|
+
logger.warn("@interopio/insights-traces plugin failed to load, insights traces functionality will be disabled");
|
|
19300
|
+
}
|
|
19301
|
+
}
|
|
19302
|
+
}
|
|
17046
19303
|
|
|
17047
19304
|
const IOConnectCoreFactory = (userConfig, ext) => {
|
|
17048
19305
|
const iodesktop = typeof window === "object" ? (window.iodesktop ?? window.glue42gd) : undefined;
|
|
17049
19306
|
const preloadPromise = typeof window === "object" ? (window.gdPreloadPromise ?? Promise.resolve()) : Promise.resolve();
|
|
19307
|
+
const glueReadyPromiseWrapper = new PromiseWrapper();
|
|
17050
19308
|
const glueInitTimer = timer("glue");
|
|
17051
19309
|
userConfig = userConfig || {};
|
|
17052
19310
|
ext = ext || {};
|
|
@@ -17057,6 +19315,7 @@
|
|
|
17057
19315
|
let _metrics;
|
|
17058
19316
|
let _contexts;
|
|
17059
19317
|
let _bus;
|
|
19318
|
+
let _insights;
|
|
17060
19319
|
let _allowTrace;
|
|
17061
19320
|
const libs = {};
|
|
17062
19321
|
function registerLib(name, inner, t) {
|
|
@@ -17220,6 +19479,43 @@
|
|
|
17220
19479
|
registerLib("bus", _bus, initTimer);
|
|
17221
19480
|
return Promise.resolve();
|
|
17222
19481
|
}
|
|
19482
|
+
async function setupInsights(interop) {
|
|
19483
|
+
const initTimer = timer("insights");
|
|
19484
|
+
const settings = await internalConfig.getInsights(iodesktop, interop, _logger);
|
|
19485
|
+
internalConfig.insights = settings;
|
|
19486
|
+
try {
|
|
19487
|
+
const builder = new distExports.Builder();
|
|
19488
|
+
const insightsLogger = _logger.subLogger("insights");
|
|
19489
|
+
if (settings.enabled) {
|
|
19490
|
+
await loadInsightsPlugins(insightsLogger, settings);
|
|
19491
|
+
}
|
|
19492
|
+
builder.withSettings(settings);
|
|
19493
|
+
builder.withLogger(new distExports.Log4jsWrapper(insightsLogger));
|
|
19494
|
+
builder.withMetrics();
|
|
19495
|
+
const INSIGHTS_PI_STORAGE = "___insights_pi_storage___";
|
|
19496
|
+
builder.withTraces()
|
|
19497
|
+
.withTraceLogger(new distExports.Log4jsWrapper(insightsLogger.subLogger("traces")))
|
|
19498
|
+
.withPropagationInfoStorage((source, pi) => _contexts?.update(INSIGHTS_PI_STORAGE, { [source.replace(/[.]/g, "_!_")]: { pi } }), (source) => _contexts?.get(INSIGHTS_PI_STORAGE)?.then(x => x[source.replace(/[.]/g, "_!_")]?.pi) ?? Promise.resolve(null));
|
|
19499
|
+
const container = builder.build();
|
|
19500
|
+
await container.start();
|
|
19501
|
+
registerLib("insights", container, initTimer);
|
|
19502
|
+
distExports.Traces.withSpan("interopio.api.startup", () => glueReadyPromiseWrapper.promise);
|
|
19503
|
+
_insights = container;
|
|
19504
|
+
return Promise.resolve();
|
|
19505
|
+
}
|
|
19506
|
+
catch (e) {
|
|
19507
|
+
initTimer.stop();
|
|
19508
|
+
_logger?.error("Error initializing insights", e);
|
|
19509
|
+
if (settings.failOnInitError) {
|
|
19510
|
+
throw e;
|
|
19511
|
+
}
|
|
19512
|
+
return Promise.resolve();
|
|
19513
|
+
}
|
|
19514
|
+
finally {
|
|
19515
|
+
replaceComplexProperties(internalConfig?.insights);
|
|
19516
|
+
replaceComplexProperties(userConfig?.insights);
|
|
19517
|
+
}
|
|
19518
|
+
}
|
|
17223
19519
|
function setupExternalLibs(externalLibs) {
|
|
17224
19520
|
try {
|
|
17225
19521
|
externalLibs.forEach((lib) => {
|
|
@@ -17267,6 +19563,7 @@
|
|
|
17267
19563
|
connection: _connection,
|
|
17268
19564
|
metrics: _metrics,
|
|
17269
19565
|
contexts: _contexts,
|
|
19566
|
+
insights: _insights,
|
|
17270
19567
|
bus: _bus,
|
|
17271
19568
|
version: internalConfig.version,
|
|
17272
19569
|
userConfig,
|
|
@@ -17335,6 +19632,7 @@
|
|
|
17335
19632
|
agmAny.server_method_aded = deprecatedDecorator(glue.agm.serverMethodAdded, "server_method_aded", "serverMethodAdded");
|
|
17336
19633
|
agmAny.server_method_removed = deprecatedDecorator(glue.agm.serverMethodRemoved, "server_method_removed", "serverMethodRemoved");
|
|
17337
19634
|
}
|
|
19635
|
+
glueReadyPromiseWrapper.resolve();
|
|
17338
19636
|
return glue;
|
|
17339
19637
|
}
|
|
17340
19638
|
async function registerInstanceIfNeeded() {
|
|
@@ -17358,12 +19656,14 @@
|
|
|
17358
19656
|
.then(() => Promise.all([setupMetrics(), setupInterop(), setupContexts(), setupBus()]))
|
|
17359
19657
|
.then(() => _interop.readyPromise)
|
|
17360
19658
|
.then(() => registerInstanceIfNeeded())
|
|
19659
|
+
.then(() => setupInsights(_interop))
|
|
17361
19660
|
.then(() => {
|
|
17362
19661
|
return setupExternalLibs(internalConfig.libs || []);
|
|
17363
19662
|
})
|
|
17364
19663
|
.then(waitForLibs)
|
|
17365
19664
|
.then(constructGlueObject)
|
|
17366
19665
|
.catch((err) => {
|
|
19666
|
+
glueReadyPromiseWrapper.reject({ err });
|
|
17367
19667
|
return Promise.reject({
|
|
17368
19668
|
err,
|
|
17369
19669
|
libs
|
|
@@ -17393,6 +19693,10 @@
|
|
|
17393
19693
|
}
|
|
17394
19694
|
iOConnectBrowserFactory.version = version$1;
|
|
17395
19695
|
|
|
19696
|
+
var _rollup_plugin_ignore_empty_module_placeholder = /*#__PURE__*/Object.freeze({
|
|
19697
|
+
__proto__: null
|
|
19698
|
+
});
|
|
19699
|
+
|
|
17396
19700
|
return iOConnectBrowserFactory;
|
|
17397
19701
|
|
|
17398
19702
|
}));
|