@interopio/otel 0.1.14 → 0.1.16

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.
@@ -1,8 +1,11 @@
1
+ import { Attributes, ObservableResult } from "@opentelemetry/api";
1
2
  import { IOInsights } from "../../insights";
2
3
  import { NullManager } from "../nullManager";
3
4
  export declare class NullMetricsManager extends NullManager<IOInsights.MetricsSettings> implements IOInsights.MetricsManager {
4
5
  constructor(settings: IOInsights.MetricsSettings | undefined, otelSettings: IOInsights.Settings | undefined, logger: IOInsights.Logger);
6
+ getObservable<TData extends Attributes>(name: string, observeCallback: (result: ObservableResult<TData>) => Promise<void>, subscribeCallback?: () => Promise<void>, unsubscribeCallback?: () => Promise<void>): IOInsights.Metric | undefined;
7
+ getObservableFromSettings<TData extends Attributes>(settings: IOInsights.MetricSettings, observeCallback: (result: ObservableResult<TData>) => Promise<void>, subscribeCallback?: () => Promise<void>, unsubscribeCallback?: () => Promise<void>): IOInsights.Metric | undefined;
5
8
  waitForFinalExport(timeoutMs?: number | undefined): Promise<void>;
6
9
  getFromSettings(settings: IOInsights.MetricSettings): IOInsights.Metric | undefined;
7
- get(type: IOInsights.MetricType): IOInsights.Metric | undefined;
10
+ get(name: string): IOInsights.Metric | undefined;
8
11
  }
@@ -11,14 +11,20 @@ class NullMetricsManager extends nullManager_1.NullManager {
11
11
  }
12
12
  super();
13
13
  }
14
+ getObservable(name, observeCallback, subscribeCallback, unsubscribeCallback) {
15
+ return new null_1.NullMetric({ name, type: "null", enabled: false, description: name });
16
+ }
17
+ getObservableFromSettings(settings, observeCallback, subscribeCallback, unsubscribeCallback) {
18
+ return new null_1.NullMetric(settings);
19
+ }
14
20
  waitForFinalExport(timeoutMs) {
15
21
  return Promise.resolve();
16
22
  }
17
23
  getFromSettings(settings) {
18
24
  return new null_1.NullMetric(settings);
19
25
  }
20
- get(type) {
21
- return new null_1.NullMetric({ name: type, type, enabled: false, description: type });
26
+ get(name) {
27
+ return new null_1.NullMetric({ name, type: "null", enabled: false, description: name });
22
28
  }
23
29
  }
24
30
  exports.NullMetricsManager = NullMetricsManager;
@@ -1 +1 @@
1
- {"version":3,"file":"nullMetricsManager.js","sourceRoot":"","sources":["../../src/metrics/nullMetricsManager.ts"],"names":[],"mappings":";;;AACA,gDAA6C;AAC7C,4DAAwD;AACxD,iCAAoC;AACpC,MAAa,kBAAmB,SAAQ,yBAAuC;IAC3E,YAAY,QAAgD,EAAE,YAA6C,EAAE,MAAyB;QAClI,IAAI,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,oBAAoB,MAAK,KAAK,EAAE,CAAC;YAC/C,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,4CAA4C,IAAA,8BAAa,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxF,CAAC;QACD,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,kBAAkB,CAAC,SAA8B;QAC7C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IACD,eAAe,CAAC,QAAmC;QAC/C,OAAO,IAAI,iBAAU,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACM,GAAG,CAAC,IAA2B;QAClC,OAAO,IAAI,iBAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACnF,CAAC;CACJ;AAjBD,gDAiBC"}
1
+ {"version":3,"file":"nullMetricsManager.js","sourceRoot":"","sources":["../../src/metrics/nullMetricsManager.ts"],"names":[],"mappings":";;;AAEA,gDAA6C;AAC7C,4DAAwD;AACxD,iCAAoC;AACpC,MAAa,kBAAmB,SAAQ,yBAAuC;IAC3E,YAAY,QAAgD,EAAE,YAA6C,EAAE,MAAyB;QAClI,IAAI,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,oBAAoB,MAAK,KAAK,EAAE,CAAC;YAC/C,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,4CAA4C,IAAA,8BAAa,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxF,CAAC;QACD,KAAK,EAAE,CAAC;IACZ,CAAC;IAEM,aAAa,CAChB,IAAY,EACZ,eAAmE,EACnE,iBAAuC,EACvC,mBAAyC;QACzC,OAAO,IAAI,iBAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;IAEM,yBAAyB,CAC5B,QAAmC,EACnC,eAAmE,EACnE,iBAAuC,EACvC,mBAAyC;QACzC,OAAO,IAAI,iBAAU,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,kBAAkB,CAAC,SAA8B;QAC7C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IACD,eAAe,CAAC,QAAmC;QAC/C,OAAO,IAAI,iBAAU,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACM,GAAG,CAAC,IAAY;QACnB,OAAO,IAAI,iBAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;CACJ;AAjCD,gDAiCC"}
package/insights.d.ts CHANGED
@@ -146,7 +146,7 @@ export namespace IOInsights {
146
146
  *
147
147
  * Otherwise, if settings exist for a metric with this name, either provided
148
148
  * by the platform or by configuration, a metric will be created.
149
- *
149
+ *
150
150
  * Otherwise, returns undefined.
151
151
  *
152
152
  * Subsequent calls to this method with the same name return the same metric.
@@ -158,11 +158,11 @@ export namespace IOInsights {
158
158
  * Creates or retrieves a metric based on the provided settings.
159
159
  *
160
160
  * If a metric is already created with this name, it will be returned.
161
- *
161
+ *
162
162
  * Otherwise, if settings exist for a metric with this name, either provided
163
163
  * by the platform or by configuration, they will be merged with the
164
164
  * settings provided to this method before creating it.
165
- *
165
+ *
166
166
  * Otherwise, the settings provided will be used as is.
167
167
  *
168
168
  * Subsequent calls to this method with the same name return the same metric.
@@ -170,6 +170,57 @@ export namespace IOInsights {
170
170
  * @param settings settings to use when creating the metric
171
171
  */
172
172
  getFromSettings(settings: MetricSettings): Metric | undefined;
173
+
174
+ /**
175
+ * Creates or retrieves an observable metric by name.
176
+ *
177
+ * If a metric is already created with this name, it will be returned.
178
+ *
179
+ * Otherwise, if settings exist for a metric with this name, either provided
180
+ * by the platform or by configuration, a metric will be created.
181
+ *
182
+ * Otherwise, returns undefined.
183
+ *
184
+ * Subsequent calls to this method with the same name return the same metric.
185
+ *
186
+ * @param name the name of the metric, e.g. platform_startup
187
+ * @param observeCallback callback that provides the observable metric's value, invoked once per publishInterval
188
+ * @param subscribeCallback optional callback invoked when the metric is started, can be used to
189
+ * set up subscriptions if the metric is measuring event data
190
+ * @param unsubscribeCallback optional callback invoked when the metric is stopped, can be used to
191
+ * destroy subscriptions if the metric is measuring event data
192
+ */
193
+ getObservable<TData extends Attributes>(
194
+ name: string,
195
+ observeCallback: (result: ObservableResult<TData>) => Promise<void>,
196
+ subscribeCallback?: () => Promise<void>,
197
+ unsubscribeCallback?: () => Promise<void>): Metric | undefined;
198
+
199
+ /**
200
+ * Creates or retrieves an observable metric based on the provided settings.
201
+ *
202
+ * If a metric is already created with this name, it will be returned.
203
+ *
204
+ * Otherwise, if settings exist for a metric with this name, either provided
205
+ * by the platform or by configuration, they will be merged with the
206
+ * settings provided to this method before creating it.
207
+ *
208
+ * Otherwise, the settings provided will be used as is.
209
+ *
210
+ * Subsequent calls to this method with the same name return the same metric.
211
+ *
212
+ * @param settings settings to use when creating the metric
213
+ * @param observeCallback callback that provides the observable metric's value, invoked once per publishInterval
214
+ * @param subscribeCallback optional callback invoked when the metric is started, can be used to
215
+ * set up subscriptions if the metric is measuring event data
216
+ * @param unsubscribeCallback optional callback invoked when the metric is stopped, can be used to
217
+ * destroy subscriptions if the metric is measuring event data
218
+ */
219
+ getObservableFromSettings<TData extends Attributes>(
220
+ settings: IOInsights.MetricSettings,
221
+ observeCallback: (result: ObservableResult<TData>) => Promise<void>,
222
+ subscribeCallback?: () => Promise<void>,
223
+ unsubscribeCallback?: () => Promise<void>): Metric | undefined;
173
224
  }
174
225
 
175
226
  /**
@@ -379,7 +430,7 @@ export namespace IOInsights {
379
430
  * Settings describing a metric.
380
431
  */
381
432
  export interface MetricSettings {
382
- enabled: boolean;
433
+ enabled?: boolean;
383
434
  type: MetricType;
384
435
  name?: string;
385
436
  description?: string;
@@ -1233,7 +1284,7 @@ export namespace IOInsights {
1233
1284
  /**
1234
1285
  * If `true`, io.Insights will instrument and trace the application startup process
1235
1286
  * automatically.
1236
- *
1287
+ *
1237
1288
  * @default true
1238
1289
  */
1239
1290
  instrumentAppStartup?: boolean;
@@ -1241,7 +1292,7 @@ export namespace IOInsights {
1241
1292
  /**
1242
1293
  * If `true`, io.Insights will instrument and trace the application loading process
1243
1294
  * automatically.
1244
- *
1295
+ *
1245
1296
  * @default true
1246
1297
  * @deprecated use instrumentAppStartup
1247
1298
  */
@@ -1842,11 +1893,29 @@ export namespace IOInsights {
1842
1893
  /**
1843
1894
  * If `true`, io.Insights will try to nest spans from other event listeners for the same event under
1844
1895
  * the Clickstream span. This is not guaranteed to always work due to specifics of how browsers execute
1845
- * event listeners, and will only work for listeners attached after io.Connect was initialized.
1896
+ * event listeners, and will only work for listeners attached after io.Connect was initialized -
1897
+ * unless `nestEventHandlersEagerly` is also enabled.
1846
1898
  *
1847
1899
  * @default true
1848
1900
  */
1849
1901
  nestEventListeners?: boolean;
1902
+ /**
1903
+ * If `true`, the io.Insights pre-init module (early.js, loaded from a preload script or an
1904
+ * inline snippet before the application code) eagerly patches addEventListener at page start,
1905
+ * so that listeners registered before io.Connect initialized also participate in
1906
+ * `nestEventListeners` nesting. Without it, only listeners attached after initialization
1907
+ * can be nested - and a listener that missed wrapping at registration stays unwrapped for
1908
+ * every later dispatch.
1909
+ *
1910
+ * The flag is read by the pre-init module itself from the platform-provided configuration
1911
+ * at `window.glue42gd.insights` (which mirrors this configuration object), so it has no
1912
+ * effect when the pre-init module is not installed or when running outside io.Connect
1913
+ * Desktop. The eager wrappers are inert pass-throughs until the SDK initializes, and remain
1914
+ * inert if the SDK loads with clickstream or `nestEventListeners` disabled.
1915
+ *
1916
+ * @default false
1917
+ */
1918
+ nestEventHandlersEagerly?: boolean;
1850
1919
  }
1851
1920
 
1852
1921
  export interface RequestTraceConfig {
@@ -2390,16 +2459,22 @@ export namespace IOInsights {
2390
2459
 
2391
2460
  /**
2392
2461
  * Internal library property.
2462
+ *
2463
+ * @ignore
2393
2464
  */
2394
2465
  definitiveInstance?: boolean;
2395
2466
 
2396
2467
  /**
2397
2468
  * Internal library property.
2469
+ *
2470
+ * @ignore
2398
2471
  */
2399
2472
  platformInstance?: boolean;
2400
2473
 
2401
2474
  /**
2402
2475
  * Internal library property.
2476
+ *
2477
+ * @ignore
2403
2478
  */
2404
2479
  registerControlMethods?: boolean;
2405
2480
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/otel",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "io.Insights observability library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",