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