From 233774d5f2278570a502e629d0b36a43fafec054 Mon Sep 17 00:00:00 2001 From: Veselin Nikolov Date: Thu, 16 Nov 2023 15:10:24 +0000 Subject: [PATCH] Capture sub-graph project metrics Co-authored-by: Ioannis Panagiotas --- .../DefaultCatalogBusinessFacade.java | 19 +++++++++++++------ .../projections/ProjectionMetricsService.java | 4 ++++ .../ProjectionMetricsServiceTest.java | 12 ++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/applications/graph-store-catalog/src/main/java/org/neo4j/gds/applications/graphstorecatalog/DefaultCatalogBusinessFacade.java b/applications/graph-store-catalog/src/main/java/org/neo4j/gds/applications/graphstorecatalog/DefaultCatalogBusinessFacade.java index 0829b9615c..e34b135d1c 100644 --- a/applications/graph-store-catalog/src/main/java/org/neo4j/gds/applications/graphstorecatalog/DefaultCatalogBusinessFacade.java +++ b/applications/graph-store-catalog/src/main/java/org/neo4j/gds/applications/graphstorecatalog/DefaultCatalogBusinessFacade.java @@ -387,12 +387,19 @@ public GraphFilterResult subGraphProject( rawConfiguration ); - return subGraphProjectApplication.project( - taskRegistryFactory, - userLogRegistryFactory, - configuration, - originGraphConfiguration.graphStore() - ); + var subGraphMetric = projectionMetricsService.createSubGraph(); + try(subGraphMetric) { + subGraphMetric.start(); + return subGraphProjectApplication.project( + taskRegistryFactory, + userLogRegistryFactory, + configuration, + originGraphConfiguration.graphStore() + ); + } catch (Exception e) { + subGraphMetric.failed(); + throw e; + } } @Override diff --git a/metrics-api/src/main/java/org/neo4j/gds/metrics/projections/ProjectionMetricsService.java b/metrics-api/src/main/java/org/neo4j/gds/metrics/projections/ProjectionMetricsService.java index a8c5d62ee7..406dfc2f42 100644 --- a/metrics-api/src/main/java/org/neo4j/gds/metrics/projections/ProjectionMetricsService.java +++ b/metrics-api/src/main/java/org/neo4j/gds/metrics/projections/ProjectionMetricsService.java @@ -42,4 +42,8 @@ public ExecutionMetric createCypherV2() { return metricRegistrar.create("cypherV2"); } + public ExecutionMetric createSubGraph() { + return metricRegistrar.create("subGraph"); + } + } diff --git a/metrics-api/src/test/java/org/neo4j/gds/metrics/projections/ProjectionMetricsServiceTest.java b/metrics-api/src/test/java/org/neo4j/gds/metrics/projections/ProjectionMetricsServiceTest.java index 8dcf19d7bc..89ebb42b73 100644 --- a/metrics-api/src/test/java/org/neo4j/gds/metrics/projections/ProjectionMetricsServiceTest.java +++ b/metrics-api/src/test/java/org/neo4j/gds/metrics/projections/ProjectionMetricsServiceTest.java @@ -71,6 +71,18 @@ void shouldCreateCypherV2ProjectionMetric() { verifyNoMoreInteractions(registrarMock); } + @Test + void shouldCreateSubGraphProjectionMetric() { + // given + var registrarMock = Mockito.mock(ExecutionMetricRegistrar.class); + var metricsService = new ProjectionMetricsService(registrarMock); + // when + metricsService.createSubGraph(); + + // then + verify(registrarMock, times(1)).create("subGraph"); + verifyNoMoreInteractions(registrarMock); + } }