@interopio/otel 0.0.219 → 0.0.221

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.
Files changed (2) hide show
  1. package/insights.d.ts +442 -76
  2. package/package.json +3 -3
package/insights.d.ts CHANGED
@@ -48,25 +48,33 @@ import { deprecate } from "util";
48
48
  * io.Insights API.
49
49
  */
50
50
  export namespace IOInsights {
51
+ /**
52
+ * Entry point into the io.Insights API
53
+ */
51
54
  export interface API extends Manager<Settings> {
52
55
  /**
53
- * io.insights.metrics
56
+ * io.insights Metrics API, often accessible as io.insights.metrics
54
57
  */
55
58
  metrics: MetricsManager;
56
59
 
57
60
  /**
58
- * io.insights.traces
61
+ * io.insights Traces API, often accessible as io.insights.traces
59
62
  */
60
63
  traces: TracesManager;
61
64
 
62
65
  /**
63
- * io.insights.logs
66
+ * io.insights Logs API, often accessible as io.insights.logs
64
67
  */
65
68
  logs: LogsManager;
69
+
70
+ /**
71
+ * io.Insights settings
72
+ */
73
+ settings: Settings;
66
74
  }
67
75
 
68
76
  /**
69
- * Builder interface for constructing the IO.Insights API.
77
+ * Builder interface for constructing the io.Insights API.
70
78
  */
71
79
  export interface APIBuilder {
72
80
  /**
@@ -126,9 +134,46 @@ export namespace IOInsights {
126
134
  * Metrics API.
127
135
  */
128
136
  export interface MetricsManager extends Manager<MetricsSettings> {
129
- get(type: MetricType): Metric | undefined;
137
+ /**
138
+ * Metrics settings.
139
+ */
140
+ settings: MetricsSettings;
141
+ /**
142
+ * Creates or retrieves a metric by name.
143
+ *
144
+ * If a metric is already created with this name, it will be returned.
145
+ *
146
+ * Otherwise, if settings exist for a metric with this name, either provided
147
+ * by the platform or by configuration, a metric will be created.
148
+ *
149
+ * Otherwise, returns undefined.
150
+ *
151
+ * Subsequent calls to this method with the same name return the same metric.
152
+ *
153
+ * @param name the name of the metric, e.g. platform_startup
154
+ */
155
+ get(name: string): Metric | undefined;
156
+ /**
157
+ * Creates or retrieves a metric based on the provided settings.
158
+ *
159
+ * If a metric is already created with this name, it will be returned.
160
+ *
161
+ * Otherwise, if settings exist for a metric with this name, either provided
162
+ * by the platform or by configuration, they will be merged with the
163
+ * settings provided to this method before creating it.
164
+ *
165
+ * Otherwise, the settings provided will be used as is.
166
+ *
167
+ * Subsequent calls to this method with the same name return the same metric.
168
+ *
169
+ * @param settings settings to use when creating the metric
170
+ */
130
171
  getFromSettings(settings: MetricSettings): Metric | undefined;
131
172
  }
173
+
174
+ /**
175
+ * Builder class used to set up Metrics module.
176
+ */
132
177
  export interface MetricsManagerBuilder {
133
178
  build(): MetricsManager;
134
179
  withLogger(logger: Logger): this;
@@ -137,11 +182,18 @@ export namespace IOInsights {
137
182
  withDependencyContainer(container: MetricsDependencyContainer): this;
138
183
  }
139
184
 
185
+ /**
186
+ * Advanced usage. Allows overriding meterProvider and metricReaders instantiation
187
+ * logic.
188
+ */
140
189
  export type MetricsMeterProviderCreateFunc = () => {
141
190
  meterProvider: MetricsMeterProvider;
142
191
  metricReaders: MetricReader[];
143
192
  };
144
193
 
194
+ /**
195
+ * @ignore
196
+ */
145
197
  export interface MetricsMeterProvider extends MeterProvider {
146
198
  forceFlush(): Promise<void>;
147
199
  }
@@ -158,6 +210,7 @@ export namespace IOInsights {
158
210
  unsubscribeCallback?: () => Promise<void>
159
211
  ): Metric;
160
212
  }
213
+
161
214
  /**
162
215
  * @ignore
163
216
  */
@@ -317,6 +370,9 @@ export namespace IOInsights {
317
370
  exporterSettings?: (OTLPExporterNodeConfigBase & OTLPMetricExporterOptions);
318
371
  }
319
372
 
373
+ /**
374
+ * Settings describing a metric.
375
+ */
320
376
  export interface MetricSettings {
321
377
  enabled: boolean;
322
378
  type: MetricType;
@@ -326,7 +382,7 @@ export namespace IOInsights {
326
382
  user?: string;
327
383
  unit?: string;
328
384
  buckets?: number[];
329
- baseMetricType?: "histogram" | "gauge"; // | "counter" | "updowncounter";
385
+ baseMetricType?: "histogram" | "gauge";
330
386
  additionalAttributes?: { [key: string]: unknown } | (() => { [key: string]: unknown });
331
387
  publishingSettings?: MetricPublishingSettings;
332
388
  }
@@ -335,6 +391,11 @@ export namespace IOInsights {
335
391
  * Controls the publishing of the metric.
336
392
  */
337
393
  export interface MetricPublishingSettings {
394
+ /**
395
+ * Defines sampling probability for the metric.
396
+ *
397
+ * @default true
398
+ */
338
399
  sample?: number | boolean;
339
400
  /**
340
401
  * Controls the publishing of specific attributes.
@@ -356,14 +417,43 @@ export namespace IOInsights {
356
417
  reduceModality?: number;
357
418
  }
358
419
 
420
+ /**
421
+ * Base interface for all metrics.
422
+ */
359
423
  export interface Metric {
424
+ /**
425
+ * Settings used to create the metric.
426
+ */
360
427
  settings: MetricSettings;
428
+ /**
429
+ * Whether the metric is started.
430
+ */
361
431
  started: boolean;
362
432
 
433
+ /**
434
+ * Starts the metric, allowing it to publish values.
435
+ */
363
436
  start(): Promise<void>;
437
+ /**
438
+ * Stops the metric, meaning it can no long publish values.
439
+ */
364
440
  stop(): Promise<void>;
365
441
  }
366
442
 
443
+ /**
444
+ * Base interface for non-observable metrics with independent values, such as Gauge and Histogram.
445
+ */
446
+ export interface RecordingMetric<TData extends IOInsights.MetricData> extends Metric {
447
+ record(value: number, data?: TData): void;
448
+ }
449
+
450
+ /**
451
+ * Base interface for non-observable metrics with incremental values, such as Counter and UpDownCounter.
452
+ */
453
+ export interface IncrementalMetric<TData extends IOInsights.MetricData> extends Metric {
454
+ add(count: number, data?: TData): void;
455
+ }
456
+
367
457
  /**
368
458
  * @ignore
369
459
  */
@@ -430,11 +520,21 @@ export namespace IOInsights {
430
520
  /*rest: */
431
521
  | "null";
432
522
 
523
+ /**
524
+ * Metric filters that can be specified as default.
525
+ *
526
+ * Metric filters allow controlling specific metric data points, e.g.
527
+ * whether a particular value of a specific metric will be published.
528
+ */
433
529
  export interface MetricDefaultFilter {
530
+ /**
531
+ * Matches the type of the metric.
532
+ */
434
533
  type?: MetricType;
435
- enabled: boolean;
436
- sample?: number | boolean;
437
- overrideDefaultFilters?: boolean;
534
+ /**
535
+ * Matches the attributes attached to a metric value. Not all metrics
536
+ * have all attribute values.
537
+ */
438
538
  attributes?: {
439
539
  /**
440
540
  * Indicates whether the workspace loading involved a complex operation where existing apps are added to a new workspace.
@@ -445,12 +545,43 @@ export namespace IOInsights {
445
545
  * Indicates whether the metric includes the time to create and load the Workspace Frame App when the workspace is opened in a new frame.
446
546
  */
447
547
  includesFrameCreation?: boolean;
448
- };
548
+ } & Record<string, any>;
549
+ /**
550
+ * Whether or not the value for the matching metric will be published.
551
+ */
552
+ enabled: boolean;
553
+ /**
554
+ * Sampling probability.
555
+ */
556
+ sample?: number | boolean;
557
+ /**
558
+ * If `true`, this filter rule will be matched before any default filters provided
559
+ * by io.Connect. The default filters are usually meant filter out non-representative
560
+ * operations (e.g. partial workspace loads), but you can use this property to
561
+ * force them to be measured.
562
+ * If `false`, default filters will be matched before this filtering rule.
563
+ *
564
+ * @default false
565
+ */
566
+ overrideDefaultFilters?: boolean;
449
567
  }
568
+ /**
569
+ * Metric filters that can be specified as part of a specific metric.
570
+ */
450
571
  export interface MetricFilter extends MetricDefaultFilter {
572
+ /**
573
+ * The name of the matched metric.
574
+ */
451
575
  name: string;
576
+ /**
577
+ * The type of the matched metric.
578
+ */
452
579
  type: MetricType;
453
580
  }
581
+
582
+ /**
583
+ * @ignore
584
+ */
454
585
  export interface MetricsDependencyContainer {
455
586
  performanceProvider: PerformanceProvider;
456
587
  instanceStartedHandler: InstanceActionHandler;
@@ -478,12 +609,19 @@ export namespace IOInsights {
478
609
  platformStartedHandler: PlatformStartedHandler;
479
610
  platformErrorHandler: PlatformErrorHandler;
480
611
  }
612
+ /**
613
+ * @ignore
614
+ */
481
615
  export type Unsubscribe = () => void;
482
-
616
+ /**
617
+ * @ignore
618
+ */
483
619
  export interface InstanceActionHandlerArgs {
484
620
  application: string;
485
621
  }
486
-
622
+ /**
623
+ * @ignore
624
+ */
487
625
  export type InstanceActionHandler = (
488
626
  callback: (args: InstanceActionHandlerArgs) => void
489
627
  ) => Unsubscribe;
@@ -491,49 +629,71 @@ export namespace IOInsights {
491
629
  export interface InstanceErrorHandlerArgs {
492
630
  application: string;
493
631
  }
494
-
632
+ /**
633
+ * @ignore
634
+ */
495
635
  export type InstanceErrorHandler = (
496
636
  callback: (args: InstanceErrorHandlerArgs) => void
497
637
  ) => Unsubscribe;
498
-
638
+ /**
639
+ * @ignore
640
+ */
499
641
  export interface PlatformErrorHandlerArgs {}
500
-
642
+ /**
643
+ * @ignore
644
+ */
501
645
  export type PlatformErrorHandler = (
502
646
  callback: (args: PlatformErrorHandlerArgs) => void
503
647
  ) => Unsubscribe;
504
-
648
+ /**
649
+ * @ignore
650
+ */
505
651
  export interface InstanceCrashHandlerArgs {
506
652
  application: string;
507
653
  reason: string;
508
654
  }
509
-
655
+ /**
656
+ * @ignore
657
+ */
510
658
  export type InstanceCrashHandler = (
511
659
  callback: (args: InstanceCrashHandlerArgs) => void
512
660
  ) => Unsubscribe;
513
-
661
+ /**
662
+ * @ignore
663
+ */
514
664
  export interface InstanceFocusedHandlerArgs {
515
665
  application: string;
516
666
  focused: boolean;
517
667
  }
518
-
668
+ /**
669
+ * @ignore
670
+ */
519
671
  export type InstanceFocusedHandler = (
520
672
  callback: (args: InstanceFocusedHandlerArgs) => void
521
673
  ) => Unsubscribe;
522
-
674
+ /**
675
+ * @ignore
676
+ */
523
677
  export interface LayoutRestoredHandlerArgs {
524
678
  layout: string;
525
679
  startTime: Date;
526
680
  endTime: Date;
527
681
  }
528
-
682
+ /**
683
+ * @ignore
684
+ */
529
685
  export type LayoutRestoredHandler = (
530
686
  callback: (args: LayoutRestoredHandlerArgs) => void
531
687
  ) => Unsubscribe;
532
-
688
+ /**
689
+ * @ignore
690
+ */
533
691
  export interface WorkspaceActionHandlerArgs {
534
692
  layout: string;
535
693
  }
536
-
694
+ /**
695
+ * @ignore
696
+ */
537
697
  export interface WorkspaceTimedActionHandlerArgs extends WorkspaceActionHandlerArgs {
538
698
  startTime: Date;
539
699
  endTime: Date;
@@ -548,7 +708,9 @@ export namespace IOInsights {
548
708
  includesFrameCreation: boolean;
549
709
  [x: string]: any;
550
710
  }
551
-
711
+ /**
712
+ * @ignore
713
+ */
552
714
  export interface WorkspaceRestoredHandlerArgs extends WorkspaceActionHandlerArgs {
553
715
  startTime: Date;
554
716
  endTime: Date;
@@ -563,7 +725,9 @@ export namespace IOInsights {
563
725
  includesFrameCreation?: boolean;
564
726
  [x: string]: any;
565
727
  }
566
-
728
+ /**
729
+ * @ignore
730
+ */
567
731
  export interface WorkspaceAppsStartedHandlerArgs extends WorkspaceTimedActionHandlerArgs {
568
732
  /**
569
733
  * Indicates whether the workspace loading involved a complex operation where existing apps are added to a new workspace.
@@ -571,56 +735,86 @@ export namespace IOInsights {
571
735
  */
572
736
  complexLoad: boolean;
573
737
  }
574
-
738
+ /**
739
+ * @ignore
740
+ */
575
741
  export interface WorkspaceStartupHandlerArgs extends WorkspaceAppsStartedHandlerArgs {
576
742
  /**
577
743
  * Indicates whether the metric includes the time to create and load the Workspace Frame App when the workspace is opened in a new frame.
578
744
  */
579
745
  includesFrameCreation: boolean;
580
746
  }
581
-
747
+ /**
748
+ * @ignore
749
+ */
582
750
  export interface WorkspaceSavedHandlerArgs extends WorkspaceActionHandlerArgs {
583
751
  oldLayout: string;
584
752
  }
753
+ /**
754
+ * @ignore
755
+ */
585
756
  export interface WorkspaceLoadedHandlerArgs extends WorkspaceActionHandlerArgs {
586
757
  startTime: Date;
587
758
  endTime: Date;
588
759
  complexLoad?: boolean;
589
760
  includesFrameCreation?: boolean;
590
761
  }
591
-
762
+ /**
763
+ * @ignore
764
+ */
592
765
  export type WorkspaceGenericActionHandler<T extends WorkspaceActionHandlerArgs> = (
593
766
  callback: (args: T) => void
594
767
  ) => Unsubscribe;
595
-
768
+ /**
769
+ * @ignore
770
+ */
596
771
  export type WorkspaceActionHandler = WorkspaceGenericActionHandler<WorkspaceActionHandlerArgs>;
772
+ /**
773
+ * @ignore
774
+ */
597
775
  export type WorkspaceLoadedHandler = WorkspaceGenericActionHandler<WorkspaceLoadedHandlerArgs>;
776
+ /**
777
+ * @ignore
778
+ */
598
779
  export type WorkspaceRestoredHandler =
599
780
  WorkspaceGenericActionHandler<WorkspaceRestoredHandlerArgs>;
781
+ /**
782
+ * @ignore
783
+ */
600
784
  export type WorkspaceSavedHandler = WorkspaceGenericActionHandler<WorkspaceSavedHandlerArgs>;
601
-
785
+ /**
786
+ * @ignore
787
+ */
602
788
  export interface InstanceReadyHandlerArgs {
603
789
  application: string;
604
790
  startTime: Date;
605
791
  endTime: Date;
606
792
  api: string;
607
793
  }
608
-
794
+ /**
795
+ * @ignore
796
+ */
609
797
  export type InstanceReadyHandler = (
610
798
  callback: (args: InstanceReadyHandlerArgs) => void
611
799
  ) => Unsubscribe;
612
-
800
+ /**
801
+ * @ignore
802
+ */
613
803
  export interface PlatformStartedHandlerArgs {
614
804
  startTime: Date;
615
805
  endTime: Date;
616
806
  idleTimeMs?: number;
617
807
  api: string;
618
808
  }
619
-
809
+ /**
810
+ * @ignore
811
+ */
620
812
  export type PlatformStartedHandler = (
621
813
  callback: (args: PlatformStartedHandlerArgs) => void
622
814
  ) => Unsubscribe;
623
-
815
+ /**
816
+ * @ignore
817
+ */
624
818
  export interface PerformanceProvider {
625
819
  getAppsCPU(): Promise<AppCPU[] | undefined>;
626
820
  getAppsMemory(): Promise<AppMemory[] | undefined>;
@@ -628,25 +822,33 @@ export namespace IOInsights {
628
822
  getSystemCPU(): Promise<SystemCPU | undefined>;
629
823
  getSystemMemory(): Promise<SystemMemory | undefined>;
630
824
  }
631
-
825
+ /**
826
+ * @ignore
827
+ */
632
828
  export interface AppCPU {
633
829
  app: string;
634
830
  instance: string;
635
831
  cpu: number;
636
832
  }
637
-
833
+ /**
834
+ * @ignore
835
+ */
638
836
  export interface AppMemory {
639
837
  app: string;
640
838
  instance: string;
641
839
  memory: number;
642
840
  }
643
-
841
+ /**
842
+ * @ignore
843
+ */
644
844
  export interface SystemCPU {
645
845
  current: number;
646
846
  average: number;
647
847
  platform: number;
648
848
  }
649
-
849
+ /**
850
+ * @ignore
851
+ */
650
852
  export interface SystemMemory {
651
853
  platformTotal: number;
652
854
  systemTotal: number;
@@ -657,6 +859,13 @@ export namespace IOInsights {
657
859
  * Traces API.
658
860
  */
659
861
  export interface TracesManager extends Manager<TracesSettings> {
862
+ /**
863
+ * Traces settings.
864
+ */
865
+ settings: TracesSettings;
866
+ /**
867
+ * The tracing state representing the currently active trace and span, if any.
868
+ */
660
869
  currentTracingState: TracingState | null;
661
870
 
662
871
  /**
@@ -679,6 +888,7 @@ export namespace IOInsights {
679
888
  * Works in conjunction with the userJourney setting to track the user's entire session flow.
680
889
  */
681
890
  userJourneyMarker?: MarkerSpanCallback;
891
+ /** @ignore */
682
892
  setUserJourneyMarker(userJourneyMarker: MarkerSpanCallback): void;
683
893
 
684
894
  /**
@@ -696,8 +906,18 @@ export namespace IOInsights {
696
906
  */
697
907
  clickstreamMarker?: MarkerSpanCallback;
698
908
 
909
+ /**
910
+ * Allows updating the configured filters.
911
+ */
699
912
  setFilterConfig(filters: SpanFilter[]): void;
700
913
 
914
+ /**
915
+ * Allows creating a span for a named trace.
916
+ *
917
+ * @param source The name of the span to create.
918
+ * @param traceName The name of the trace to nest the span in. If one doesn't exist, it will be created.
919
+ * @param callback Logic to execute in the span.
920
+ */
701
921
  withSequenceSpanEx<T>(
702
922
  source: string,
703
923
  traceName:
@@ -706,6 +926,14 @@ export namespace IOInsights {
706
926
  callback:
707
927
  | IOInsights.WithSpanCallback<T>): Promise<T>;
708
928
 
929
+ /**
930
+ * Allows creating a span for a named trace.
931
+ *
932
+ * @param source The name of the span to create.
933
+ * @param traceName The name of the trace to nest the span in. If one doesn't exist, it will be created.
934
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
935
+ * @param callback Logic to execute in the span.
936
+ */
709
937
  withSequenceSpanEx<T>(
710
938
  source: string,
711
939
  traceName:
@@ -717,6 +945,15 @@ export namespace IOInsights {
717
945
  callback:
718
946
  | IOInsights.WithSpanCallback<T>): Promise<T>;
719
947
 
948
+ /**
949
+ * Allows creating a span for a named trace.
950
+ *
951
+ * @param source The name of the span to create.
952
+ * @param traceName The name of the trace to nest the span in. If one doesn't exist, it will be created.
953
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
954
+ * @param options Options to use when creating the span.
955
+ * @param callback Logic to execute in the span.
956
+ */
720
957
  withSequenceSpanEx<T>(
721
958
  source: string,
722
959
  traceName:
@@ -731,6 +968,9 @@ export namespace IOInsights {
731
968
  callback:
732
969
  | IOInsights.WithSpanCallback<T>): Promise<T>;
733
970
 
971
+ /**
972
+ * @ignore
973
+ */
734
974
  withSequenceSpanEx<T>(
735
975
  source: string,
736
976
  traceName:
@@ -747,11 +987,24 @@ export namespace IOInsights {
747
987
  callback?:
748
988
  | IOInsights.WithSpanCallback<T>): Promise<T>;
749
989
 
990
+ /**
991
+ * Allows creating a span for a named trace.
992
+ *
993
+ * @param source The name of the span to create. The name of the trace will be <source>.start, and if one doesn't exist, it will be created.
994
+ * @param callback Logic to execute in the span.
995
+ */
750
996
  withSequenceSpan<T>(
751
997
  source: string,
752
998
  callback:
753
999
  | IOInsights.WithSpanCallback<T>): Promise<T>;
754
1000
 
1001
+ /**
1002
+ * Allows creating a span for a named trace.
1003
+ *
1004
+ * @param source The name of the span to create. The name of the trace will be <source>.start, and if one doesn't exist, it will be created.
1005
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
1006
+ * @param callback Logic to execute in the span.
1007
+ */
755
1008
  withSequenceSpan<T>(
756
1009
  source: string,
757
1010
  filteringContext:
@@ -760,6 +1013,14 @@ export namespace IOInsights {
760
1013
  callback:
761
1014
  | IOInsights.WithSpanCallback<T>): Promise<T>;
762
1015
 
1016
+ /**
1017
+ * Allows creating a span for a named trace.
1018
+ *
1019
+ * @param source The name of the span to create. The name of the trace will be <source>.start, and if one doesn't exist, it will be created.
1020
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
1021
+ * @param options Options to use when creating the span.
1022
+ * @param callback Logic to execute in the span.
1023
+ */
763
1024
  withSequenceSpan<T>(
764
1025
  source: string,
765
1026
  filteringContext:
@@ -771,6 +1032,9 @@ export namespace IOInsights {
771
1032
  callback:
772
1033
  | IOInsights.WithSpanCallback<T>): Promise<T>;
773
1034
 
1035
+ /**
1036
+ * @ignore
1037
+ */
774
1038
  withSequenceSpan<T>(
775
1039
  source: string,
776
1040
  filteringContextOrCallback:
@@ -784,14 +1048,36 @@ export namespace IOInsights {
784
1048
  callback?:
785
1049
  | IOInsights.WithSpanCallback<T>): Promise<T>;
786
1050
 
787
- withSpan<T>(source: string, callback: WithSpanCallback<T>): T;
788
-
1051
+ /**
1052
+ * Allows creating a span for the currently active trace. If one doesn't exist, it will be created.
1053
+ *
1054
+ * @param source The name of the span to create.
1055
+ * @param callback Logic to execute in the span.
1056
+ */
1057
+ withSpan<T>(
1058
+ source: string,
1059
+ callback: WithSpanCallback<T>): T;
1060
+ /**
1061
+ * Allows creating a span for the currently active trace. If one doesn't exist, it will be created.
1062
+ *
1063
+ * @param source The name of the span to create.
1064
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
1065
+ * @param callback Logic to execute in the span.
1066
+ */
789
1067
  withSpan<T>(
790
1068
  source: string,
791
1069
  filteringContext: FilteringContext,
792
1070
  callback: WithSpanCallback<T>
793
1071
  ): T;
794
1072
 
1073
+ /**
1074
+ * Allows creating a span for the currently active trace or a specified trace. If one doesn't exist, it will be created.
1075
+ *
1076
+ * @param source The name of the span to create.
1077
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
1078
+ * @param propagationInfo Span and trace id to use for manually nesting the new trace.
1079
+ * @param callback Logic to execute in the span.
1080
+ */
795
1081
  withSpan<T>(
796
1082
  source: string,
797
1083
  filteringContext: FilteringContext,
@@ -799,6 +1085,15 @@ export namespace IOInsights {
799
1085
  callback: WithSpanCallback<T>
800
1086
  ): T;
801
1087
 
1088
+ /**
1089
+ * Allows creating a span for the currently active trace or a specified trace. If one doesn't exist, it will be created.
1090
+ *
1091
+ * @param source The name of the span to create.
1092
+ * @param filteringContext Filtering context used to match against the tracing filtering configuration.
1093
+ * @param propagationInfo Span and trace id to use for manually nesting the new trace.
1094
+ * @param options Options to use when creating the span.
1095
+ * @param callback Logic to execute in the span.
1096
+ */
802
1097
  withSpan<T>(
803
1098
  source: string,
804
1099
  filteringContext: FilteringContext,
@@ -809,6 +1104,9 @@ export namespace IOInsights {
809
1104
  }
810
1105
 
811
1106
  interface TracingState {
1107
+ /**
1108
+ * Ends the current span. Same as endSpan().
1109
+ */
812
1110
  end(): void;
813
1111
  /**
814
1112
  * If false, this is a placeholder object, and all its methods
@@ -859,6 +1157,9 @@ export namespace IOInsights {
859
1157
  */
860
1158
  enabled: boolean;
861
1159
 
1160
+ /**
1161
+ * Property for internal use.
1162
+ */
862
1163
  rootPropagationInfo?: PropagationInfo;
863
1164
 
864
1165
  /**
@@ -879,19 +1180,19 @@ export namespace IOInsights {
879
1180
  /**
880
1181
  * Name of span hit counter metric, set to null to disable.
881
1182
  *
882
- * Defaults to 'insights_trace_count'.
1183
+ * @default insights_trace_count
883
1184
  */
884
1185
  countMetric?: string;
885
1186
  /**
886
1187
  * Name of span duration histogram metric, set to null to disable.
887
1188
  *
888
- * Defaults to 'insights_trace_duration'.
1189
+ * @default insights_trace_duration
889
1190
  */
890
1191
  durationMetric?: string;
891
1192
  /**
892
1193
  * Name of span result counter metric, set to null to disable.
893
1194
  *
894
- * Defaults to 'insights_trace_result'.
1195
+ * @default insights_trace_result
895
1196
  */
896
1197
  resultMetric?: string;
897
1198
 
@@ -1072,12 +1373,6 @@ export namespace IOInsights {
1072
1373
  */
1073
1374
  processorSettings?: BatchSpanProcessorBrowserConfig;
1074
1375
 
1075
- /**
1076
- * Configuration for automatic instrumentation of common browser operations.
1077
- * Enables automatic tracing of document load, user interactions, fetch requests, and XHR calls.
1078
- */
1079
- autoInstrumentations?: AutoInstrumentationOptions;
1080
-
1081
1376
  /**
1082
1377
  * Maximum length for parent operation names in span hierarchies.
1083
1378
  */
@@ -1110,18 +1405,35 @@ export namespace IOInsights {
1110
1405
  */
1111
1406
  additionalResourceAttributes?: { [x: string]: unknown } | (() => { [x: string]: unknown });
1112
1407
 
1408
+ /**
1409
+ * Allows specifying a constructor callback for creating the tracerProvider instance.
1410
+ */
1113
1411
  tracerProvider?: (tracerProviderSettings: TracerConfig, tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => TracerProvider;
1412
+ /**
1413
+ * Allows specifying a constructor callback for creating the Sampler instance.
1414
+ */
1114
1415
  sampler?: (defaultSampler: Sampler, tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => Sampler;
1416
+ /**
1417
+ * Allows specifying a constructor callback for creating the SpanProcessor instances.
1418
+ */
1115
1419
  spanProcessors?: (processorSettings: BatchSpanProcessorBrowserConfig | undefined, exporterSettings: OTLPExporterNodeConfigBase, tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => SpanProcessor[];
1420
+ /**
1421
+ * Allows specifying a constructor callback for creating the SpanExporter instances.
1422
+ */
1116
1423
  spanExporters?: (exporterSettings: OTLPExporterNodeConfigBase, tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => SpanExporter[];
1424
+ /**
1425
+ * Allows specifying a constructor callback for creating the TextMapPropagator instance.
1426
+ */
1117
1427
  propagator?: (tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => TextMapPropagator;
1428
+ /**
1429
+ * Allows specifying a constructor callback for creating the ContextManager instance.
1430
+ */
1118
1431
  contextManager?: (tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => ContextManager;
1119
- providerRegistrationSettings?: (tracesSettings: IOInsights.TracesSettings, settings: IOInsights.Settings) => {
1120
- propagator?: TextMapPropagator;
1121
- contextManager?: ContextManager;
1122
- };
1123
1432
  }
1124
1433
 
1434
+ /**
1435
+ * Builder class used to set up Traces module.
1436
+ */
1125
1437
  export interface TracesManagerBuilder {
1126
1438
  build(): TracesManager;
1127
1439
  withLogger(logger: Logger): this;
@@ -1134,8 +1446,14 @@ export namespace IOInsights {
1134
1446
  read: (source: string) => Promise<PropagationInfo | null>): this;
1135
1447
  }
1136
1448
 
1449
+ /**
1450
+ * Callback executed during a span. See `withSpan`
1451
+ */
1137
1452
  export type WithSpanCallback<T> = (tracingState: TracingState) => T;
1138
1453
 
1454
+ /**
1455
+ * Options that can be provided when using `withSpan` as a decorator
1456
+ */
1139
1457
  export interface WithSpanDecoratorOptions extends WithSpanOptions {
1140
1458
  argMapping?:
1141
1459
  | { [x: string]: string }
@@ -1144,20 +1462,30 @@ export namespace IOInsights {
1144
1462
  thisMapping?: { [x: string]: string } | ((that: any) => any);
1145
1463
  }
1146
1464
 
1465
+ /**
1466
+ * Span and trace information that can be used to manually control the
1467
+ * nesting of a newly created span.
1468
+ */
1147
1469
  export interface PropagationInfo {
1148
1470
  traceparent?: string;
1149
1471
  tracestate?: string;
1150
1472
  forceTracing?: boolean;
1151
1473
  }
1474
+
1475
+ /** @ignore */
1152
1476
  export interface PropagationInfoCarrier {
1153
1477
  __interopIOTracePropagationInfo?: PropagationInfo;
1154
1478
  }
1155
1479
 
1480
+ /** @ignore */
1156
1481
  export type PropagationInfoCallback = (
1157
1482
  source: string,
1158
1483
  fullFilteringContext: FilteringContext
1159
1484
  ) => PropagationInfo | null;
1160
1485
 
1486
+ /**
1487
+ * Key-value pair that can be used to match a span against a filter in the tracing filtering config.
1488
+ */
1161
1489
  export type FilteringContext = {
1162
1490
  app?: string;
1163
1491
  user?: string;
@@ -1169,6 +1497,9 @@ export namespace IOInsights {
1169
1497
  userId?: string;
1170
1498
  } & Record<string, any>;
1171
1499
 
1500
+ /**
1501
+ * Verbosity level of a span. Controls how much information is added using `.addData()`.
1502
+ */
1172
1503
  export enum SpanVerbosity {
1173
1504
  OFF,
1174
1505
  LOWEST,
@@ -1178,6 +1509,10 @@ export namespace IOInsights {
1178
1509
  WARN,
1179
1510
  HIGHEST,
1180
1511
  }
1512
+
1513
+ /**
1514
+ * Options that can be used when creating a span.
1515
+ */
1181
1516
  export interface WithSpanOptions extends Omit<SpanCreationOptions, "sample"> {
1182
1517
  defaultFilters?: SpanFilter[];
1183
1518
  structure?: "sibling" | "nested";
@@ -1187,7 +1522,7 @@ export namespace IOInsights {
1187
1522
  /**
1188
1523
  * Whether the span will be created or will be a no-op. See 'Filter'.
1189
1524
  *
1190
- * Defaults to 'true'.
1525
+ * @default true
1191
1526
  */
1192
1527
  enabled?: boolean;
1193
1528
  /**
@@ -1198,34 +1533,34 @@ export namespace IOInsights {
1198
1533
  /**
1199
1534
  * Default span attribute verbosity level. See 'Filter'.
1200
1535
  *
1201
- * Defaults to 'INFO'.
1536
+ * @default INFO
1202
1537
  */
1203
1538
  level?: keyof typeof SpanVerbosity;
1204
1539
  /**
1205
1540
  * Whether the filtering context will be added as span attributes
1206
1541
  * to the span. See 'Filter'.
1207
1542
  *
1208
- * Defaults to 'true'.
1543
+ * @default true
1209
1544
  */
1210
1545
  addContextToTrace?: boolean;
1211
1546
  /**
1212
1547
  * Whether the span's status will be set to OK on completion, if
1213
1548
  * it's still UNSET. See 'Filter'.
1214
1549
  *
1215
- * Defaults to 'false'.
1550
+ * @default false
1216
1551
  */
1217
1552
  autoSetSuccessStatus?: boolean;
1218
1553
  /**
1219
1554
  * Default sampling setting/probability. See 'SamplingSettings'.
1220
1555
  *
1221
- * Defaults to 'true'.
1556
+ * @default true
1222
1557
  */
1223
1558
  sample?: number | boolean;
1224
1559
  /**
1225
1560
  * Whether the span will not inject its propagation info into data
1226
1561
  * transfer objects for span nesting across system boundaries.
1227
1562
  *
1228
- * Defaults to 'false'.
1563
+ * @default false
1229
1564
  */
1230
1565
  disablePropagation?: boolean;
1231
1566
  /**
@@ -1248,7 +1583,7 @@ export namespace IOInsights {
1248
1583
  /**
1249
1584
  * Whether the span will be counted in the insights_trace_count metric. See TracesSettings.countMetric.
1250
1585
  *
1251
- * Defaults to 'false'.
1586
+ * @default false
1252
1587
  */
1253
1588
  countMetric?: boolean;
1254
1589
  /**
@@ -1258,7 +1593,7 @@ export namespace IOInsights {
1258
1593
  /**
1259
1594
  * Whether the span will be counted in the insights_trace_result metric. See TracesSettings.resultMetric.
1260
1595
  *
1261
- * Defaults to 'false'.
1596
+ * @default false
1262
1597
  */
1263
1598
  resultMetric?: boolean;
1264
1599
  /**
@@ -1268,7 +1603,7 @@ export namespace IOInsights {
1268
1603
  /**
1269
1604
  * Whether the span will be counted in the insights_trace_duration metric. See TracesSettings.durationtMetric.
1270
1605
  *
1271
- * Defaults to 'false'.
1606
+ * @default false
1272
1607
  */
1273
1608
  durationMetric?: boolean;
1274
1609
  /**
@@ -1279,7 +1614,7 @@ export namespace IOInsights {
1279
1614
  * Whether the span will be able to start a new trace. If false, it will only
1280
1615
  * be able to be added to an existing trace.
1281
1616
  *
1282
- * Defaults to 'true'.
1617
+ * @default true
1283
1618
  */
1284
1619
  canBeRoot?: boolean;
1285
1620
  /**
@@ -1294,7 +1629,7 @@ export namespace IOInsights {
1294
1629
  * will be forced to be traced, even if their span filter configuration
1295
1630
  * is set to not enabled.
1296
1631
  *
1297
- * Defaults to 'false'.
1632
+ * @default false
1298
1633
  */
1299
1634
  forceChildTracing?: boolean;
1300
1635
  /**
@@ -1302,6 +1637,7 @@ export namespace IOInsights {
1302
1637
  */
1303
1638
  minDurationMs?: number;
1304
1639
 
1640
+ /** @ignore */
1305
1641
  getPropagationInfo?: PropagationInfoCallback;
1306
1642
 
1307
1643
  /**
@@ -1321,6 +1657,9 @@ export namespace IOInsights {
1321
1657
  overrideDefaultFilters?: boolean;
1322
1658
  }
1323
1659
 
1660
+ /**
1661
+ * Filter entry that can match a span to control its settings.
1662
+ */
1324
1663
  export interface SpanFilter extends Omit<SpanCreationOptions, "getPropagationInfo"> {
1325
1664
  /**
1326
1665
  * Specifies the source string used for matching spans.
@@ -1343,17 +1682,10 @@ export namespace IOInsights {
1343
1682
  [key: string]: string | number | boolean;
1344
1683
  };
1345
1684
  }
1685
+
1346
1686
  /**
1347
- * Configuration for automatic instrumentation of common browser operations.
1348
- * Enables automatic tracing of document load, user interactions, fetch requests, and XHR calls.
1349
- */
1350
- export interface AutoInstrumentationOptions {
1351
- documentLoad?: boolean | DocumentLoadInstrumentationConfig;
1352
- userInteraction?: boolean | UserInteractionInstrumentationConfig;
1353
- fetch?: boolean | FetchInstrumentationConfig;
1354
- xhr?: boolean | XMLHttpRequestInstrumentationConfig;
1355
- ignoreObservabilityUrls?: boolean;
1356
- }
1687
+ * Settings used to control the sampling probability of spans.
1688
+ */
1357
1689
  export interface SamplingSettings {
1358
1690
  /**
1359
1691
  * Span name to determine if span will match this sampling setting entry.
@@ -1511,8 +1843,19 @@ export namespace IOInsights {
1511
1843
  * Logs API.
1512
1844
  */
1513
1845
  export interface LogsManager extends Manager<LogsSettings> {
1846
+ /**
1847
+ * Logs settings.
1848
+ */
1849
+ settings: LogsSettings;
1850
+
1851
+ /**
1852
+ * Publishes an OTEL log record.
1853
+ */
1514
1854
  emit(logRecord: LogRecord): Promise<void> | null;
1515
1855
  }
1856
+ /**
1857
+ * Builder class used to set up Logs module.
1858
+ */
1516
1859
  export interface LogsManagerBuilder {
1517
1860
  build(): LogsManager;
1518
1861
  withLogger(logger: Logger): this;
@@ -1597,7 +1940,7 @@ export namespace IOInsights {
1597
1940
  /**
1598
1941
  * Name of log level counter metric, set to null to disable.
1599
1942
  *
1600
- * Defaults to 'insights_log_level_count'.
1943
+ * @default insights_log_level_count
1601
1944
  */
1602
1945
  levelCountMetric?: string;
1603
1946
 
@@ -1688,6 +2031,9 @@ export namespace IOInsights {
1688
2031
  enabled?: boolean;
1689
2032
  }
1690
2033
 
2034
+ /**
2035
+ * Level of log entry.
2036
+ */
1691
2037
  export const enum LoggerLogLevel {
1692
2038
  NONE = 0,
1693
2039
  ERROR = 30,
@@ -1698,6 +2044,9 @@ export namespace IOInsights {
1698
2044
  ALL = 9999,
1699
2045
  }
1700
2046
 
2047
+ /**
2048
+ * Log interface that can be passed to library for its own logging.
2049
+ */
1701
2050
  export interface Logger {
1702
2051
  level?: LoggerLogLevel;
1703
2052
  error(message: string, ...args: unknown[]): void;
@@ -1739,11 +2088,28 @@ export namespace IOInsights {
1739
2088
  }
1740
2089
 
1741
2090
  export interface Manager<TSettings> {
2091
+ /**
2092
+ * io.Insights settings.
2093
+ */
1742
2094
  settings: TSettings;
2095
+ /**
2096
+ * Whether or not this instance is started.
2097
+ */
1743
2098
  started: boolean;
1744
-
2099
+ /**
2100
+ * Starts publishing data.
2101
+ */
1745
2102
  start(): Promise<void>;
2103
+ /**
2104
+ * Stops publishing data.
2105
+ */
1746
2106
  stop(): Promise<void>;
2107
+
2108
+ /**
2109
+ * Waits for any pending data to be published, with the option to specify a timeout.
2110
+ *
2111
+ * @param timeoutMs maximum time to wait for export
2112
+ */
1747
2113
  waitForFinalExport(timeoutMs?: number): Promise<void>;
1748
2114
  }
1749
2115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/otel",
3
- "version": "0.0.219",
3
+ "version": "0.0.221",
4
4
  "description": "io.Insights observability library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,8 @@
39
39
  "@opentelemetry/resources": "^2.0.0",
40
40
  "@opentelemetry/sdk-logs": "^0.200.0",
41
41
  "@opentelemetry/sdk-metrics": "^2.0.0",
42
- "@opentelemetry/sdk-trace-base": "^2.0.0"
42
+ "@opentelemetry/sdk-trace-base": "^2.0.0",
43
+ "log4js": "^6.9.1"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/chai": "^4.3.20",
@@ -49,7 +50,6 @@
49
50
  "@typescript-eslint/parser": "^7.18.0",
50
51
  "chai": "^4.5.0",
51
52
  "eslint": "^8.57.1",
52
- "log4js": "^6.9.1",
53
53
  "mocha": "^10.8.2",
54
54
  "rimraf": "^5.0.10",
55
55
  "typescript": "^4.9.5"