@finos/legend-graph 22.3.0 → 23.0.0

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 (58) hide show
  1. package/lib/graph/DependencyManager.d.ts +1 -0
  2. package/lib/graph/DependencyManager.d.ts.map +1 -1
  3. package/lib/graph/DependencyManager.js +3 -0
  4. package/lib/graph/DependencyManager.js.map +1 -1
  5. package/lib/graphManager/AbstractPureGraphManager.d.ts +14 -14
  6. package/lib/graphManager/AbstractPureGraphManager.d.ts.map +1 -1
  7. package/lib/graphManager/AbstractPureGraphManager.js.map +1 -1
  8. package/lib/graphManager/GraphManagerEvent.d.ts +23 -21
  9. package/lib/graphManager/GraphManagerEvent.d.ts.map +1 -1
  10. package/lib/graphManager/GraphManagerEvent.js +25 -21
  11. package/lib/graphManager/GraphManagerEvent.js.map +1 -1
  12. package/lib/graphManager/{GraphBuilderReport.d.ts → GraphManagerMetrics.d.ts} +12 -9
  13. package/lib/graphManager/GraphManagerMetrics.d.ts.map +1 -0
  14. package/lib/graphManager/GraphManagerMetrics.js +66 -0
  15. package/lib/graphManager/GraphManagerMetrics.js.map +1 -0
  16. package/lib/graphManager/GraphManagerTelemetry.d.ts +8 -6
  17. package/lib/graphManager/GraphManagerTelemetry.d.ts.map +1 -1
  18. package/lib/graphManager/GraphManagerTelemetry.js +2 -2
  19. package/lib/graphManager/GraphManagerTelemetry.js.map +1 -1
  20. package/lib/graphManager/action/changeDetection/GraphObserverHelper.d.ts.map +1 -1
  21. package/lib/graphManager/action/changeDetection/GraphObserverHelper.js +2 -0
  22. package/lib/graphManager/action/changeDetection/GraphObserverHelper.js.map +1 -1
  23. package/lib/graphManager/protocol/pure/v1/V1_PureGraphManager.d.ts +16 -17
  24. package/lib/graphManager/protocol/pure/v1/V1_PureGraphManager.d.ts.map +1 -1
  25. package/lib/graphManager/protocol/pure/v1/V1_PureGraphManager.js +130 -64
  26. package/lib/graphManager/protocol/pure/v1/V1_PureGraphManager.js.map +1 -1
  27. package/lib/graphManager/protocol/pure/v1/engine/V1_Engine.d.ts +2 -1
  28. package/lib/graphManager/protocol/pure/v1/engine/V1_Engine.d.ts.map +1 -1
  29. package/lib/graphManager/protocol/pure/v1/engine/V1_Engine.js +5 -3
  30. package/lib/graphManager/protocol/pure/v1/engine/V1_Engine.js.map +1 -1
  31. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.js +2 -2
  32. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.js.map +1 -1
  33. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MilestoneBuilderHelper.d.ts +1 -1
  34. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MilestoneBuilderHelper.d.ts.map +1 -1
  35. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MilestoneBuilderHelper.js +6 -6
  36. package/lib/graphManager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MilestoneBuilderHelper.js.map +1 -1
  37. package/lib/index.d.ts +3 -2
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/index.js +3 -2
  40. package/lib/index.js.map +1 -1
  41. package/lib/package.json +1 -1
  42. package/package.json +3 -3
  43. package/src/graph/DependencyManager.ts +4 -0
  44. package/src/graphManager/AbstractPureGraphManager.ts +31 -21
  45. package/src/graphManager/GraphManagerEvent.ts +27 -21
  46. package/src/graphManager/GraphManagerMetrics.ts +93 -0
  47. package/src/graphManager/GraphManagerTelemetry.ts +13 -8
  48. package/src/graphManager/action/changeDetection/GraphObserverHelper.ts +3 -0
  49. package/src/graphManager/protocol/pure/v1/V1_PureGraphManager.ts +245 -102
  50. package/src/graphManager/protocol/pure/v1/engine/V1_Engine.ts +9 -1
  51. package/src/graphManager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementThirdPassBuilder.ts +2 -2
  52. package/src/graphManager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_MilestoneBuilderHelper.ts +6 -6
  53. package/src/index.ts +3 -2
  54. package/tsconfig.json +1 -1
  55. package/lib/graphManager/GraphBuilderReport.d.ts.map +0 -1
  56. package/lib/graphManager/GraphBuilderReport.js +0 -24
  57. package/lib/graphManager/GraphBuilderReport.js.map +0 -1
  58. package/src/graphManager/GraphBuilderReport.ts +0 -32
@@ -216,7 +216,11 @@ import type { ExternalFormatDescription } from '../../../../graphManager/action/
216
216
  import type { ConfigurationProperty } from '../../../../graph/metamodel/pure/packageableElements/fileGeneration/ConfigurationProperty.js';
217
217
  import { V1_ExternalFormatModelGenerationInput } from './engine/externalFormat/V1_ExternalFormatModelGeneration.js';
218
218
  import { V1_GenerateSchemaInput } from './engine/externalFormat/V1_GenerateSchemaInput.js';
219
- import { GraphBuilderReport } from '../../../../graphManager/GraphBuilderReport.js';
219
+ import {
220
+ createGraphBuilderReport,
221
+ createGraphManagerOperationReport,
222
+ type GraphManagerOperationReport,
223
+ } from '../../../GraphManagerMetrics.js';
220
224
  import type { Package } from '../../../../graph/metamodel/pure/packageableElements/domain/Package.js';
221
225
  import { V1_DataElement } from './model/packageableElements/data/V1_DataElement.js';
222
226
  import {
@@ -316,7 +320,7 @@ const mergePureModelContextData = (
316
320
  };
317
321
 
318
322
  export const V1_indexPureModelContextData = (
319
- report: GraphBuilderReport,
323
+ report: GraphManagerOperationReport,
320
324
  data: V1_PureModelContextData,
321
325
  extensions: V1_GraphBuilderExtensions,
322
326
  ): V1_PureModelContextDataIndex => {
@@ -380,7 +384,8 @@ export const V1_indexPureModelContextData = (
380
384
  });
381
385
 
382
386
  // report
383
- report.elementCount.total = report.elementCount.total + index.elements.length;
387
+ report.elementCount.total =
388
+ (report.elementCount.total ?? 0) + index.elements.length;
384
389
  report.elementCount.other =
385
390
  (report.elementCount.other ?? 0) +
386
391
  otherElementsByClass.size +
@@ -503,9 +508,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
503
508
  systemModel: SystemModel,
504
509
  buildState: ActionState,
505
510
  options?: GraphBuilderOptions,
506
- ): Promise<GraphBuilderReport> {
511
+ _report?: GraphManagerOperationReport,
512
+ ): Promise<void> {
507
513
  const stopWatch = new StopWatch();
508
- const report = new GraphBuilderReport();
514
+ const report = _report ?? createGraphBuilderReport();
509
515
  buildState.reset();
510
516
 
511
517
  // Create a dummy graph for system processing. This is to ensure system model does not depend on the main graph
@@ -527,7 +533,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
527
533
  V1_deserializePureModelContextData(modelContextData),
528
534
  ),
529
535
  );
530
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_DESERIALIZED);
536
+ stopWatch.record(
537
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DESERIALIZE_ELEMENTS__SUCCESS,
538
+ );
531
539
 
532
540
  // prepare build inputs
533
541
  const buildInputs = [
@@ -554,9 +562,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
554
562
  buildState.pass();
555
563
  report.timings = {
556
564
  ...Object.fromEntries(stopWatch.records),
557
- [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_COMPLETED]: stopWatch.elapsed,
565
+ [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_GRAPH__SUCCESS]:
566
+ stopWatch.elapsed,
567
+ total: stopWatch.elapsed,
558
568
  };
559
- return report;
560
569
  } catch (error) {
561
570
  assertErrorThrown(error);
562
571
  buildState.fail();
@@ -577,9 +586,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
577
586
  dependencyEntitiesIndex: Map<string, Entity[]>,
578
587
  buildState: ActionState,
579
588
  options?: GraphBuilderOptions,
580
- ): Promise<GraphBuilderReport> {
589
+ _report?: GraphManagerOperationReport,
590
+ ): Promise<void> {
581
591
  const stopWatch = new StopWatch();
582
- const report = new GraphBuilderReport();
592
+ const report = _report ?? createGraphBuilderReport();
583
593
  buildState.reset();
584
594
 
585
595
  // Create a dummy graph for system processing. This is to ensure dependency models do not depend on the main graph
@@ -612,7 +622,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
612
622
  },
613
623
  ),
614
624
  );
615
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_DESERIALIZED);
625
+ stopWatch.record(
626
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DESERIALIZE_ELEMENTS__SUCCESS,
627
+ );
616
628
 
617
629
  // prepare build inputs
618
630
  const buildInputs: V1_PureGraphBuilderInput[] = Array.from(
@@ -637,12 +649,12 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
637
649
  );
638
650
 
639
651
  buildState.pass();
640
- report.otherStats.projectCount = dependencyEntitiesIndex.size;
641
652
  report.timings = {
642
653
  ...Object.fromEntries(stopWatch.records),
643
- [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_COMPLETED]: stopWatch.elapsed,
654
+ [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_GRAPH__SUCCESS]:
655
+ stopWatch.elapsed,
656
+ total: stopWatch.elapsed,
644
657
  };
645
- return report;
646
658
  } catch (error) {
647
659
  assertErrorThrown(error);
648
660
  this.log.error(
@@ -661,9 +673,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
661
673
  entities: Entity[],
662
674
  buildState: ActionState,
663
675
  options?: GraphBuilderOptions,
664
- ): Promise<GraphBuilderReport> {
676
+ _report?: GraphManagerOperationReport,
677
+ ): Promise<void> {
665
678
  const stopWatch = new StopWatch();
666
- const report = new GraphBuilderReport();
679
+ const report = _report ?? createGraphBuilderReport();
667
680
  buildState.reset();
668
681
 
669
682
  try {
@@ -675,7 +688,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
675
688
  data,
676
689
  this.pluginManager.getPureProtocolProcessorPlugins(),
677
690
  );
678
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_DESERIALIZED);
691
+ stopWatch.record(
692
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DESERIALIZE_ELEMENTS__SUCCESS,
693
+ );
679
694
 
680
695
  // prepare build inputs
681
696
  const buildInputs: V1_PureGraphBuilderInput[] = [
@@ -718,9 +733,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
718
733
  buildState.pass();
719
734
  report.timings = {
720
735
  ...Object.fromEntries(stopWatch.records),
721
- [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_COMPLETED]: stopWatch.elapsed,
736
+ [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_GRAPH__SUCCESS]:
737
+ stopWatch.elapsed,
738
+ total: stopWatch.elapsed,
722
739
  };
723
- return report;
724
740
  } catch (error) {
725
741
  assertErrorThrown(error);
726
742
  this.log.error(
@@ -745,9 +761,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
745
761
  entities: Entity[],
746
762
  buildState: ActionState,
747
763
  options?: GraphBuilderOptions,
748
- ): Promise<GraphBuilderReport> {
764
+ _report?: GraphManagerOperationReport,
765
+ ): Promise<void> {
749
766
  const stopWatch = new StopWatch();
750
- const report = new GraphBuilderReport();
767
+ const report = _report ?? createGraphBuilderReport();
751
768
  buildState.reset();
752
769
 
753
770
  try {
@@ -759,7 +776,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
759
776
  data,
760
777
  this.pluginManager.getPureProtocolProcessorPlugins(),
761
778
  );
762
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_DESERIALIZED);
779
+ stopWatch.record(
780
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DESERIALIZE_ELEMENTS__SUCCESS,
781
+ );
763
782
 
764
783
  // prepare build inputs
765
784
  const buildInputs: V1_PureGraphBuilderInput[] = [
@@ -795,9 +814,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
795
814
  buildState.pass();
796
815
  report.timings = {
797
816
  ...Object.fromEntries(stopWatch.records),
798
- [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_COMPLETED]: stopWatch.elapsed,
817
+ [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_GRAPH__SUCCESS]:
818
+ stopWatch.elapsed,
819
+ total: stopWatch.elapsed,
799
820
  };
800
- return report;
801
821
  } catch (error) {
802
822
  assertErrorThrown(error);
803
823
  this.log.error(
@@ -822,9 +842,10 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
822
842
  generatedEntities: Map<string, Entity[]>,
823
843
  buildState: ActionState,
824
844
  options?: GraphBuilderOptions,
825
- ): Promise<GraphBuilderReport> {
845
+ _report?: GraphManagerOperationReport,
846
+ ): Promise<void> {
826
847
  const stopWatch = new StopWatch();
827
- const report = new GraphBuilderReport();
848
+ const report = _report ?? createGraphBuilderReport();
828
849
  const generatedModel = graph.generationModel;
829
850
  buildState.reset();
830
851
 
@@ -848,7 +869,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
848
869
  },
849
870
  ),
850
871
  );
851
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_DESERIALIZED);
872
+ stopWatch.record(
873
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DESERIALIZE_ELEMENTS__SUCCESS,
874
+ );
852
875
 
853
876
  // prepare build inputs
854
877
  const buildInputs: V1_PureGraphBuilderInput[] = Array.from(
@@ -873,12 +896,12 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
873
896
  );
874
897
 
875
898
  buildState.pass();
876
- report.otherStats.generationCount = generationGraphDataIndex.size;
877
899
  report.timings = {
878
900
  ...Object.fromEntries(stopWatch.records),
879
- [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_COMPLETED]: stopWatch.elapsed,
901
+ [GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_GRAPH__SUCCESS]:
902
+ stopWatch.elapsed,
903
+ total: stopWatch.elapsed,
880
904
  };
881
- return report;
882
905
  } catch (error) {
883
906
  assertErrorThrown(error);
884
907
  this.log.error(
@@ -901,7 +924,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
901
924
  private async buildGraphFromInputs(
902
925
  graph: PureModel,
903
926
  inputs: V1_PureGraphBuilderInput[],
904
- report: GraphBuilderReport,
927
+ report: GraphManagerOperationReport,
905
928
  stopWatch: StopWatch,
906
929
  graphBuilderState: ActionState,
907
930
  options?: GraphBuilderOptions,
@@ -911,57 +934,65 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
911
934
  `Indexing ${report.elementCount.total} elements...`,
912
935
  );
913
936
  await this.initializeAndIndexElements(graph, inputs, options);
914
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_INDEXED);
937
+ stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_INDEX_ELEMENTS__SUCCESS);
915
938
 
916
939
  // build section index
917
940
  graphBuilderState.setMessage(`Building section indices...`);
918
941
  await this.buildSectionIndices(graph, inputs, options);
919
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_SECTION_INDICES_BUILT);
942
+ stopWatch.record(
943
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_SECTION_INDICES__SUCCESS,
944
+ );
920
945
 
921
946
  // build types
922
947
  graphBuilderState.setMessage(`Building domain models...`);
923
948
  await this.buildTypes(graph, inputs, options);
924
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DOMAIN_MODELS_BUILT);
949
+ stopWatch.record(
950
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_DOMAIN_MODELS__SUCCESS,
951
+ );
925
952
 
926
953
  // build stores
927
954
  graphBuilderState.setMessage(`Building stores...`);
928
955
  await this.buildStores(graph, inputs, options);
929
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_STORES_BUILT);
956
+ stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_STORES__SUCCESS);
930
957
 
931
958
  // build mappings
932
959
  graphBuilderState.setMessage(`Building mappings...`);
933
960
  await this.buildMappings(graph, inputs, options);
934
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_MAPPINGS_BUILT);
961
+ stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_MAPPINGS__SUCCESS);
935
962
 
936
963
  // build connections and runtimes
937
964
  graphBuilderState.setMessage(`Building connections and runtimes...`);
938
965
  await this.buildConnectionsAndRuntimes(graph, inputs, options);
939
966
  stopWatch.record(
940
- GRAPH_MANAGER_EVENT.GRAPH_BUILDER_CONNECTIONS_AND_RUNTIMES_BUILT,
967
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_CONNECTIONS_AND_RUNTIMES__SUCCESS,
941
968
  );
942
969
 
943
970
  // build services
944
971
  graphBuilderState.setMessage(`Building services...`);
945
972
  await this.buildServices(graph, inputs, options);
946
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_SERVICES_BUILT);
973
+ stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_SERVICES__SUCCESS);
947
974
 
948
975
  // build data elements
949
976
  graphBuilderState.setMessage(`Building data elements...`);
950
977
  await this.buildDataElements(graph, inputs, options);
951
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_DATA_ELEMENTS_BUILT);
978
+ stopWatch.record(
979
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_DATA_ELEMENTS__SUCCESS,
980
+ );
952
981
 
953
982
  // build other elements
954
983
  graphBuilderState.setMessage(`Building other elements...`);
955
984
  await this.buildFileGenerations(graph, inputs, options);
956
985
  await this.buildGenerationSpecifications(graph, inputs, options);
957
986
  await this.buildOtherElements(graph, inputs, options);
958
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_OTHER_ELEMENTS_BUILT);
987
+ stopWatch.record(
988
+ GRAPH_MANAGER_EVENT.GRAPH_BUILDER_BUILD_OTHER_ELEMENTS__SUCCESS,
989
+ );
959
990
  }
960
991
 
961
992
  private async buildLightGraphFromInputs(
962
993
  graph: PureModel,
963
994
  inputs: V1_PureGraphBuilderInput[],
964
- report: GraphBuilderReport,
995
+ report: GraphManagerOperationReport,
965
996
  stopWatch: StopWatch,
966
997
  graphBuilderState: ActionState,
967
998
  options?: GraphBuilderOptions,
@@ -971,7 +1002,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
971
1002
  `Indexing ${report.elementCount.total} elements...`,
972
1003
  );
973
1004
  await this.initializeAndIndexElements(graph, inputs, options);
974
- stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_ELEMENTS_INDEXED);
1005
+ stopWatch.record(GRAPH_MANAGER_EVENT.GRAPH_BUILDER_INDEX_ELEMENTS__SUCCESS);
975
1006
  }
976
1007
 
977
1008
  private getBuilderContext(
@@ -1520,7 +1551,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1520
1551
  graphData,
1521
1552
  );
1522
1553
  this.log.info(
1523
- LogEvent.create(GRAPH_MANAGER_EVENT.GRAPH_MODEL_TO_GRAMMAR_TRANSFORMED),
1554
+ LogEvent.create(
1555
+ GRAPH_MANAGER_EVENT.TRANSFORM_GRAPH_META_MODEL_TO_GRAMMAR__SUCCESS,
1556
+ ),
1524
1557
  Date.now() - startTime,
1525
1558
  'ms',
1526
1559
  );
@@ -1537,7 +1570,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1537
1570
  await this.entitiesToPureModelContextData(entities),
1538
1571
  );
1539
1572
  this.log.info(
1540
- LogEvent.create(GRAPH_MANAGER_EVENT.GRAPH_MODEL_TO_GRAMMAR_TRANSFORMED),
1573
+ LogEvent.create(
1574
+ GRAPH_MANAGER_EVENT.TRANSFORM_GRAPH_META_MODEL_TO_GRAMMAR__SUCCESS,
1575
+ ),
1541
1576
  Date.now() - startTime,
1542
1577
  'ms',
1543
1578
  );
@@ -1627,15 +1662,31 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1627
1662
  keepSourceInformation?: boolean | undefined;
1628
1663
  }
1629
1664
  | undefined,
1665
+ _report?: GraphManagerOperationReport,
1630
1666
  ): Promise<CompilationResult> {
1667
+ const report = _report ?? createGraphManagerOperationReport();
1668
+ const stopWatch = new StopWatch();
1669
+
1670
+ const graphData = this.getFullGraphModelData(graph, {
1671
+ keepSourceInformation: options?.keepSourceInformation,
1672
+ });
1673
+ stopWatch.record(GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_INPUT__SUCCESS);
1674
+
1631
1675
  const compilationResult = await this.engine.compilePureModelContextData(
1632
- this.getFullGraphModelData(graph, {
1633
- keepSourceInformation: options?.keepSourceInformation,
1634
- }),
1676
+ graphData,
1635
1677
  {
1636
1678
  onError: options?.onError,
1637
1679
  },
1638
1680
  );
1681
+ stopWatch.record(
1682
+ GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_SERVER_CALL__SUCCESS,
1683
+ );
1684
+
1685
+ report.timings = {
1686
+ ...Object.fromEntries(stopWatch.records),
1687
+ total: stopWatch.elapsed,
1688
+ };
1689
+
1639
1690
  return {
1640
1691
  warnings: compilationResult.warnings?.map(
1641
1692
  (warning) =>
@@ -1648,14 +1699,33 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
1648
1699
  graphGrammar: string,
1649
1700
  graph: PureModel,
1650
1701
  options?: { onError?: () => void },
1702
+ _report?: GraphManagerOperationReport,
1651
1703
  ): Promise<TextCompilationResult> {
1704
+ const report = _report ?? createGraphManagerOperationReport();
1705
+ const stopWatch = new StopWatch();
1706
+
1707
+ const graphCompileContext = this.getGraphCompileContext(graph);
1708
+ stopWatch.record(GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_INPUT__SUCCESS);
1709
+
1652
1710
  const compilationResult = await this.engine.compileText(
1653
1711
  graphGrammar,
1654
- this.getGraphCompileContext(graph),
1712
+ report,
1713
+ graphCompileContext,
1655
1714
  options,
1656
1715
  );
1716
+
1717
+ const entities = this.pureModelContextDataToEntities(
1718
+ compilationResult.model,
1719
+ );
1720
+
1721
+ report.timings = {
1722
+ ...report.timings,
1723
+ ...Object.fromEntries(stopWatch.records),
1724
+ total: stopWatch.elapsed,
1725
+ };
1726
+
1657
1727
  return {
1658
- entities: this.pureModelContextDataToEntities(compilationResult.model),
1728
+ entities,
1659
1729
  warnings: compilationResult.warnings?.map(
1660
1730
  (warning) =>
1661
1731
  new CompilationWarning(warning.message, warning.sourceInformation),
@@ -2020,7 +2090,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2020
2090
  input.targetBindingPath = targetBinding;
2021
2091
  const genPMCD = await this.engine.generateSchema(input);
2022
2092
  const genGraph = await this.createEmptyGraph();
2023
- const report = new GraphBuilderReport();
2093
+ const report = createGraphBuilderReport();
2024
2094
  const mainGraphBuilderInput: V1_PureGraphBuilderInput[] = [
2025
2095
  {
2026
2096
  model: genGraph,
@@ -2207,23 +2277,104 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2207
2277
  runtime: Runtime,
2208
2278
  graph: PureModel,
2209
2279
  options?: ExecutionOptions,
2280
+ _report?: GraphManagerOperationReport,
2210
2281
  ): Promise<ExecutionResult> {
2211
- return V1_buildExecutionResult(
2212
- await this.engine.executeMapping(
2213
- this.createExecutionInput(
2214
- graph,
2215
- mapping,
2216
- lambda,
2217
- runtime,
2218
- V1_PureGraphManager.PROD_PROTOCOL_VERSION,
2219
- options?.parameterValues,
2220
- ),
2221
- options,
2222
- ),
2282
+ const report = _report ?? createGraphManagerOperationReport();
2283
+ const stopWatch = new StopWatch();
2284
+
2285
+ const input = this.createExecutionInput(
2286
+ graph,
2287
+ mapping,
2288
+ lambda,
2289
+ runtime,
2290
+ V1_PureGraphManager.PROD_PROTOCOL_VERSION,
2291
+ options?.parameterValues,
2223
2292
  );
2293
+ stopWatch.record(GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_INPUT__SUCCESS);
2294
+
2295
+ const result = V1_buildExecutionResult(
2296
+ await this.engine.executeMapping(input, options),
2297
+ );
2298
+ stopWatch.record(
2299
+ GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_SERVER_CALL__SUCCESS,
2300
+ );
2301
+
2302
+ report.timings = {
2303
+ ...Object.fromEntries(stopWatch.records),
2304
+ total: stopWatch.elapsed,
2305
+ };
2306
+
2307
+ return result;
2224
2308
  }
2225
2309
 
2226
- generateExecuteTestData(
2310
+ async generateExecutionPlan(
2311
+ lambda: RawLambda,
2312
+ mapping: Mapping | undefined,
2313
+ runtime: Runtime | undefined,
2314
+ graph: PureModel,
2315
+ _report?: GraphManagerOperationReport,
2316
+ ): Promise<RawExecutionPlan> {
2317
+ const report = _report ?? createGraphManagerOperationReport();
2318
+ const stopWatch = new StopWatch();
2319
+
2320
+ const input = this.createExecutionInput(
2321
+ graph,
2322
+ mapping,
2323
+ lambda,
2324
+ runtime,
2325
+ V1_PureGraphManager.DEV_PROTOCOL_VERSION,
2326
+ );
2327
+ stopWatch.record(GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_INPUT__SUCCESS);
2328
+
2329
+ const result = await this.engine.generateExecutionPlan(input);
2330
+ stopWatch.record(
2331
+ GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_SERVER_CALL__SUCCESS,
2332
+ );
2333
+
2334
+ report.timings = {
2335
+ ...Object.fromEntries(stopWatch.records),
2336
+ total: stopWatch.elapsed,
2337
+ };
2338
+
2339
+ return result;
2340
+ }
2341
+
2342
+ async debugExecutionPlanGeneration(
2343
+ lambda: RawLambda,
2344
+ mapping: Mapping | undefined,
2345
+ runtime: Runtime | undefined,
2346
+ graph: PureModel,
2347
+ _report?: GraphManagerOperationReport,
2348
+ ): Promise<{ plan: RawExecutionPlan; debug: string }> {
2349
+ const report = _report ?? createGraphManagerOperationReport();
2350
+ const stopWatch = new StopWatch();
2351
+
2352
+ const input = this.createExecutionInput(
2353
+ graph,
2354
+ mapping,
2355
+ lambda,
2356
+ runtime,
2357
+ V1_PureGraphManager.DEV_PROTOCOL_VERSION,
2358
+ );
2359
+ stopWatch.record(GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_INPUT__SUCCESS);
2360
+
2361
+ const result = await this.engine.debugExecutionPlanGeneration(input);
2362
+ stopWatch.record(
2363
+ GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_SERVER_CALL__SUCCESS,
2364
+ );
2365
+
2366
+ report.timings = {
2367
+ ...Object.fromEntries(stopWatch.records),
2368
+ total: stopWatch.elapsed,
2369
+ };
2370
+
2371
+ return {
2372
+ plan: result.plan,
2373
+ debug: result.debug.join('\n'),
2374
+ };
2375
+ }
2376
+
2377
+ async generateExecuteTestData(
2227
2378
  lambda: RawLambda,
2228
2379
  parameters: (string | number | boolean)[],
2229
2380
  mapping: Mapping,
@@ -2232,7 +2383,11 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2232
2383
  options?: {
2233
2384
  anonymizeGeneratedData?: boolean;
2234
2385
  },
2386
+ _report?: GraphManagerOperationReport,
2235
2387
  ): Promise<string> {
2388
+ const report = _report ?? createGraphManagerOperationReport();
2389
+ const stopWatch = new StopWatch();
2390
+
2236
2391
  const testDataGenerationExecuteInput =
2237
2392
  new V1_TestDataGenerationExecutionInput();
2238
2393
  this.buildExecutionInput(
@@ -2247,45 +2402,21 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2247
2402
  testDataGenerationExecuteInput.hashStrings = Boolean(
2248
2403
  options?.anonymizeGeneratedData,
2249
2404
  );
2250
- return this.engine.generateExecuteTestData(testDataGenerationExecuteInput);
2251
- }
2405
+ stopWatch.record(GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_INPUT__SUCCESS);
2252
2406
 
2253
- generateExecutionPlan(
2254
- lambda: RawLambda,
2255
- mapping: Mapping | undefined,
2256
- runtime: Runtime | undefined,
2257
- graph: PureModel,
2258
- ): Promise<RawExecutionPlan> {
2259
- return this.engine.generateExecutionPlan(
2260
- this.createExecutionInput(
2261
- graph,
2262
- mapping,
2263
- lambda,
2264
- runtime,
2265
- V1_PureGraphManager.DEV_PROTOCOL_VERSION,
2266
- ),
2407
+ const result = await this.engine.generateExecuteTestData(
2408
+ testDataGenerationExecuteInput,
2267
2409
  );
2268
- }
2269
-
2270
- async debugExecutionPlanGeneration(
2271
- lambda: RawLambda,
2272
- mapping: Mapping | undefined,
2273
- runtime: Runtime | undefined,
2274
- graph: PureModel,
2275
- ): Promise<{ plan: RawExecutionPlan; debug: string }> {
2276
- const result = await this.engine.debugExecutionPlanGeneration(
2277
- this.createExecutionInput(
2278
- graph,
2279
- mapping,
2280
- lambda,
2281
- runtime,
2282
- V1_PureGraphManager.DEV_PROTOCOL_VERSION,
2283
- ),
2410
+ stopWatch.record(
2411
+ GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_SERVER_CALL__SUCCESS,
2284
2412
  );
2285
- return {
2286
- plan: result.plan,
2287
- debug: result.debug.join('\n'),
2413
+
2414
+ report.timings = {
2415
+ ...Object.fromEntries(stopWatch.records),
2416
+ total: stopWatch.elapsed,
2288
2417
  };
2418
+
2419
+ return result;
2289
2420
  }
2290
2421
 
2291
2422
  buildExecutionPlan(
@@ -2567,9 +2698,19 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2567
2698
 
2568
2699
  // ---------------------------------------- Analysis ----------------------------------------
2569
2700
 
2570
- buildMappingModelCoverageAnalysisInputContextData = (
2701
+ private buildMappingModelCoverageAnalysisInputContextData = (
2571
2702
  graph: PureModel,
2572
2703
  ): V1_PureModelContext => {
2704
+ /**
2705
+ * To lessen network load, we only include relevant part of the pure model context data here
2706
+ *
2707
+ * Graph data models can be classified based on dependency hieararchy:
2708
+ * 1. Building blocks: models that all other models depend on: e.g. domain models, connections, etc.
2709
+ * 2. Consumers: models that depends on other models: e.g. mapping, service, etc.
2710
+ * 3. Unrelated: models that depends on nothing and vice versa: e.g. text
2711
+ *
2712
+ * For analyzing mapping, we choose to include some building blocks and mappings.
2713
+ */
2573
2714
  const graphData = this.getFullGraphModelData(graph);
2574
2715
  const prunedGraphData = new V1_PureModelContextData();
2575
2716
  const extraElements = this.pluginManager
@@ -2699,7 +2840,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2699
2840
  entityFilterFn?: ((entity: Entity) => boolean) | undefined,
2700
2841
  entityProcessorFn?: ((entity: Entity) => Entity) | undefined,
2701
2842
  ): Promise<V1_PureGraphBuilderInput[]> {
2702
- const report = new GraphBuilderReport();
2843
+ const report = createGraphBuilderReport();
2703
2844
 
2704
2845
  // build main graph builder input
2705
2846
  const data = new V1_PureModelContextData();
@@ -2907,7 +3048,7 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2907
3048
  );
2908
3049
  this.log.info(
2909
3050
  LogEvent.create(
2910
- GRAPH_MANAGER_EVENT.GRAPH_META_MODEL_TO_PROTOCOL_TRANSFORMED,
3051
+ GRAPH_MANAGER_EVENT.TRANSFORM_GRAPH_META_MODEL_TO_PROTOCOL__SUCCESS,
2911
3052
  ),
2912
3053
  Date.now() - startTime,
2913
3054
  'ms',
@@ -2927,7 +3068,9 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
2927
3068
  ...generatedModel.allOwnElements,
2928
3069
  ].map((element) => this.elementToProtocol(element));
2929
3070
  this.log.info(
2930
- LogEvent.create(GRAPH_MANAGER_EVENT.GRAPH_COMPILE_CONTEXT_COLLECTED),
3071
+ LogEvent.create(
3072
+ GRAPH_MANAGER_EVENT.COLLECT_GRAPH_COMPILE_CONTEXT__SUCCESS,
3073
+ ),
2931
3074
  Date.now() - startTime,
2932
3075
  'ms',
2933
3076
  );
@@ -26,6 +26,7 @@ import {
26
26
  NetworkClientError,
27
27
  returnUndefOnError,
28
28
  deserializeMap,
29
+ StopWatch,
29
30
  } from '@finos/legend-shared';
30
31
  import type { RawLambda } from '../../../../../graph/metamodel/pure/rawValueSpecification/RawLambda.js';
31
32
  import {
@@ -98,6 +99,7 @@ import type {
98
99
  } from './compilation/V1_CompilationResult.js';
99
100
  import { V1_CompilationWarning } from './compilation/V1_CompilationWarning.js';
100
101
  import { V1_GenerateSchemaInput } from './externalFormat/V1_GenerateSchemaInput.js';
102
+ import type { GraphManagerOperationReport } from '../../../../GraphManagerMetrics.js';
101
103
 
102
104
  class V1_EngineConfig extends TEMPORARY__AbstractEngineConfig {
103
105
  private engine: V1_Engine;
@@ -162,7 +164,7 @@ export class V1_Engine {
162
164
  const startTime = Date.now();
163
165
  const serializedGraph = V1_serializePureModelContextData(graph);
164
166
  this.log.info(
165
- LogEvent.create(GRAPH_MANAGER_EVENT.GRAPH_PROTOCOL_SERIALIZED),
167
+ LogEvent.create(GRAPH_MANAGER_EVENT.SERIALIZE_GRAPH_PROTOCOL__SUCCESS),
166
168
  Date.now() - startTime,
167
169
  'ms',
168
170
  );
@@ -411,6 +413,7 @@ export class V1_Engine {
411
413
 
412
414
  async compileText(
413
415
  graphText: string,
416
+ TEMPORARY__report: GraphManagerOperationReport,
414
417
  compileContext?: V1_PureModelContextData,
415
418
  options?: { onError?: () => void; getCompilationWarnings?: boolean },
416
419
  ): Promise<V1_TextCompilationResult> {
@@ -428,7 +431,12 @@ export class V1_Engine {
428
431
  )
429
432
  : mainGraph;
430
433
  try {
434
+ const stopWatch = new StopWatch();
431
435
  await this.engineServerClient.compile(pureModelContextDataJson);
436
+ TEMPORARY__report.timings[
437
+ GRAPH_MANAGER_EVENT.V1_ENGINE_OPERATION_SERVER_CALL__SUCCESS
438
+ ] = stopWatch.elapsed;
439
+
432
440
  const model = V1_deserializePureModelContextData(mainGraph);
433
441
  const compilationResult = await this.engineServerClient.compile(
434
442
  pureModelContextDataJson,