From 77d20adff71717cab2dcf03a9895b922662b0d05 Mon Sep 17 00:00:00 2001 From: Rishabh Rathod Date: Tue, 22 Oct 2024 14:22:29 +0530 Subject: [PATCH] chore: Add spans attributes for no of lines and action count (#37001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Fixes #36995 ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 7285f3f04c37b0a78cf7fa8b9106c0fb5175bc29 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Tue, 22 Oct 2024 08:35:48 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Added new constants for layout operations and data extraction to improve functionality. - Introduced observability tracking for various methods to enhance monitoring and performance insights. - **Bug Fixes** - Enhanced error handling and logging for action updates and layout modifications. - **Refactor** - Improved clarity and maintainability of methods related to action collections and layout updates. - **Chores** - Updated method signatures to include new observability parameters for better tracking. - Added metrics for line and action counts in action collection updates. --- .../external/constants/spans/OnLoadSpan.java | 5 ++ .../constants/spans/ce/LayoutSpanCE.java | 4 +- .../constants/spans/ce/OnLoadSpanCE.java | 22 ++++++ .../layouts/UpdateLayoutServiceCEImpl.java | 35 +++++++-- .../layouts/UpdateLayoutServiceImpl.java | 7 +- .../internal/OnLoadExecutablesUtilCEImpl.java | 75 ++++++++++++++----- .../ce/LayoutActionServiceCEImpl.java | 10 +++ .../ce/LayoutCollectionServiceCEImpl.java | 13 ++++ 8 files changed, 142 insertions(+), 29 deletions(-) create mode 100644 appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java create mode 100644 appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java diff --git a/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java b/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java new file mode 100644 index 000000000000..a77fbef0797f --- /dev/null +++ b/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java @@ -0,0 +1,5 @@ +package com.appsmith.external.constants.spans; + +import com.appsmith.external.constants.spans.ce.OnLoadSpanCE; + +public class OnLoadSpan extends OnLoadSpanCE {} diff --git a/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java b/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java index be0660b5f544..f8fb95a6a2d0 100644 --- a/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java +++ b/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java @@ -15,7 +15,9 @@ public class LayoutSpanCE { APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.updateExecutablesExecuteOnLoad"; public static final String FIND_AND_UPDATE_LAYOUT = APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.findAndUpdateLayout"; - + public static final String UNESCAPE_MONGO_SPECIAL_CHARS = APPSMITH_SPAN_PREFIX + "unescapeMongoSpecialCharacters"; + public static final String EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL = + APPSMITH_SPAN_PREFIX + "extractAllWidgetNamesAndDynamicBindingsFromDSL"; public static final String EXTRACT_AND_SET_EXECUTABLE_BINDINGS_IN_GRAPH_EDGES = APPSMITH_SPAN_PREFIX + "extractAndSetExecutableBindingsInGraphEdges"; public static final String RECURSIVELY_ADD_EXECUTABLES_AND_THEIR_DEPENDENTS_TO_GRAPH_FROM_BINDINGS = diff --git a/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java b/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java new file mode 100644 index 000000000000..5b7dcc7ea20d --- /dev/null +++ b/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java @@ -0,0 +1,22 @@ +package com.appsmith.external.constants.spans.ce; + +import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; + +public class OnLoadSpanCE { + + public static final String GET_ALL_EXECUTABLES_BY_CREATOR_ID = + APPSMITH_SPAN_PREFIX + "getAllExecutablesByCreatorIdFlux"; + public static final String EXECUTABLE_NAME_TO_EXECUTABLE_MAP = + APPSMITH_SPAN_PREFIX + "executableNameToExecutableMap"; + public static final String EXECUTABLE_IN_CREATOR_CONTEXT = APPSMITH_SPAN_PREFIX + "executablesInCreatorContext"; + public static final String ADD_DIRECTLY_REFERENCED_EXECUTABLES_TO_GRAPH = + APPSMITH_SPAN_PREFIX + "addDirectlyReferencedExecutablesToGraph"; + public static final String GET_POSSIBLE_ENTITY_REFERENCES = APPSMITH_SPAN_PREFIX + "getPossibleEntityReferences"; + public static final String UPDATE_EXECUTABLE_SELF_REFERENCING_PATHS = + APPSMITH_SPAN_PREFIX + "updateExecutableSelfReferencingPaths"; + public static final String GET_POSSIBLE_ENTITY_PARENTS_MAP = APPSMITH_SPAN_PREFIX + "getPossibleEntityParentsMap"; + public static final String ADD_EXPLICIT_USER_SET_ON_LOAD_EXECUTABLES_TO_GRAPH = + APPSMITH_SPAN_PREFIX + "addExplicitUserSetOnLoadExecutablesToGraph"; + public static final String GET_UNPUBLISHED_ON_LOAD_EXECUTABLES_EXPLICIT_SET_BY_USER_IN_CREATOR_CONTEXT = + APPSMITH_SPAN_PREFIX + "getUnpublishedOnLoadExecutablesExplicitSetByUserInCreatorContext"; +} diff --git a/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java b/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java index d9d44d439ff9..b4d159e67b7e 100755 --- a/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java +++ b/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java @@ -17,6 +17,7 @@ import com.appsmith.server.dtos.UpdateMultiplePageLayoutDTO; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; +import com.appsmith.server.helpers.ObservationHelperImpl; import com.appsmith.server.helpers.WidgetSpecificUtils; import com.appsmith.server.newpages.base.NewPageService; import com.appsmith.server.onload.internal.OnLoadExecutablesUtil; @@ -26,6 +27,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.micrometer.observation.ObservationRegistry; +import io.micrometer.tracing.Span; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.minidev.json.JSONObject; @@ -48,6 +50,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import static com.appsmith.external.constants.spans.LayoutSpan.EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL; import static com.appsmith.external.constants.spans.LayoutSpan.FIND_ALL_ON_LOAD_EXECUTABLES; import static com.appsmith.external.constants.spans.LayoutSpan.FIND_AND_UPDATE_LAYOUT; import static com.appsmith.external.constants.spans.LayoutSpan.UPDATE_EXECUTABLES_EXECUTE_ONLOAD; @@ -70,6 +73,7 @@ public class UpdateLayoutServiceCEImpl implements UpdateLayoutServiceCE { private final ApplicationService applicationService; private final ObjectMapper objectMapper; private final ObservationRegistry observationRegistry; + private final ObservationHelperImpl observationHelper; private final String layoutOnLoadActionErrorToastMessage = "A cyclic dependency error has been encountered on current page, \nqueries on page load will not run. \n Please check debugger and Appsmith documentation for more information"; @@ -127,6 +131,12 @@ private Mono updateLayoutDsl( Set widgetNames = new HashSet<>(); Map> widgetDynamicBindingsMap = new HashMap<>(); Set escapedWidgetNames = new HashSet<>(); + + Span extractAllWidgetNamesAndDynamicBindingsFromDSLSpan = + observationHelper.createSpan(EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL); + + observationHelper.startSpan(extractAllWidgetNamesAndDynamicBindingsFromDSLSpan, true); + try { dsl = extractAllWidgetNamesAndDynamicBindingsFromDSL( dsl, widgetNames, widgetDynamicBindingsMap, creatorId, layoutId, escapedWidgetNames, creatorType); @@ -136,6 +146,8 @@ private Mono updateLayoutDsl( .then(Mono.error(t)); } + observationHelper.endSpan(extractAllWidgetNamesAndDynamicBindingsFromDSLSpan, true); + layout.setWidgetNames(widgetNames); if (!escapedWidgetNames.isEmpty()) { @@ -151,7 +163,8 @@ private Mono updateLayoutDsl( AtomicReference validOnLoadExecutables = new AtomicReference<>(Boolean.TRUE); - // setting the layoutOnLoadActionActionErrors to empty to remove the existing errors before new DAG calculation. + // setting the layoutOnLoadActionActionErrors to empty to remove the existing + // errors before new DAG calculation. layout.setLayoutOnLoadActionErrors(new ArrayList<>()); Mono>> allOnLoadExecutablesMono = onLoadExecutablesUtil @@ -180,14 +193,18 @@ private Mono updateLayoutDsl( // First update the actions and set execute on load to true JSONObject finalDsl = dsl; - return allOnLoadExecutablesMono + + Mono layoutDTOMono = allOnLoadExecutablesMono .flatMap(allOnLoadExecutables -> { - // If there has been an error (e.g. cyclical dependency), then don't update any actions. - // This is so that unnecessary updates don't happen to actions while the page is in invalid state. + // If there has been an error (e.g. cyclical dependency), then don't update any + // actions. + // This is so that unnecessary updates don't happen to actions while the page is + // in invalid state. if (!validOnLoadExecutables.get()) { return Mono.just(allOnLoadExecutables); } - // Update these executables to be executed on load, unless the user has touched the executeOnLoad + // Update these executables to be executed on load, unless the user has touched + // the executeOnLoad // setting for this return onLoadExecutablesUtil .updateExecutablesExecuteOnLoad( @@ -201,12 +218,15 @@ private Mono updateLayoutDsl( layout.setLayoutOnLoadActions(onLoadExecutables); layout.setAllOnPageLoadActionNames(executableNames); layout.setActionsUsedInDynamicBindings(executablesUsedInDSL); - // The below field is to ensure that we record if the page load actions computation was + // The below field is to ensure that we record if the page load actions + // computation was // valid when last stored in the database. layout.setValidOnPageLoadActions(validOnLoadExecutables.get()); return onLoadExecutablesUtil .findAndUpdateLayout(creatorId, creatorType, layoutId, layout) + .tag("no_of_widgets", String.valueOf(widgetNames.size())) + .tag("no_of_executables", String.valueOf(executableNames.size())) .name(FIND_AND_UPDATE_LAYOUT) .tap(Micrometer.observation(observationRegistry)); }) @@ -222,6 +242,8 @@ private Mono updateLayoutDsl( return sendUpdateLayoutAnalyticsEvent(creatorId, layoutId, finalDsl, true, null, creatorType) .thenReturn(layoutDTO); }); + + return layoutDTOMono; } @Override @@ -326,6 +348,7 @@ public Mono>> getOnPageLoadActions( Set widgetNames = new HashSet<>(); Map> widgetDynamicBindingsMap = new HashMap<>(); Set escapedWidgetNames = new HashSet<>(); + // observationHelper.createSpan() try { dsl = extractAllWidgetNamesAndDynamicBindingsFromDSL( dsl, widgetNames, widgetDynamicBindingsMap, creatorId, layoutId, escapedWidgetNames, creatorType); diff --git a/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java b/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java index 4d1689947366..a50e3e7c66fe 100644 --- a/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java +++ b/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java @@ -1,6 +1,7 @@ package com.appsmith.server.layouts; import com.appsmith.server.applications.base.ApplicationService; +import com.appsmith.server.helpers.ObservationHelperImpl; import com.appsmith.server.newpages.base.NewPageService; import com.appsmith.server.onload.internal.OnLoadExecutablesUtil; import com.appsmith.server.services.AnalyticsService; @@ -21,7 +22,8 @@ public UpdateLayoutServiceImpl( PagePermission pagePermission, ApplicationService applicationService, ObjectMapper objectMapper, - ObservationRegistry observationRegistry) { + ObservationRegistry observationRegistry, + ObservationHelperImpl observationHelper) { super( onLoadExecutablesUtil, sessionUserService, @@ -30,6 +32,7 @@ public UpdateLayoutServiceImpl( pagePermission, applicationService, objectMapper, - observationRegistry); + observationRegistry, + observationHelper); } } diff --git a/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java b/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java index bb3d599bb147..7f8cc405cfae 100644 --- a/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java +++ b/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java @@ -52,6 +52,14 @@ import static com.appsmith.external.constants.spans.LayoutSpan.EXTRACT_AND_SET_EXECUTABLE_BINDINGS_IN_GRAPH_EDGES; import static com.appsmith.external.constants.spans.LayoutSpan.FILTER_AND_TRANSFORM_SCHEDULING_ORDER_TO_DTO; import static com.appsmith.external.constants.spans.LayoutSpan.RECURSIVELY_ADD_EXECUTABLES_AND_THEIR_DEPENDENTS_TO_GRAPH_FROM_BINDINGS; +import static com.appsmith.external.constants.spans.OnLoadSpan.ADD_DIRECTLY_REFERENCED_EXECUTABLES_TO_GRAPH; +import static com.appsmith.external.constants.spans.OnLoadSpan.ADD_EXPLICIT_USER_SET_ON_LOAD_EXECUTABLES_TO_GRAPH; +import static com.appsmith.external.constants.spans.OnLoadSpan.EXECUTABLE_NAME_TO_EXECUTABLE_MAP; +import static com.appsmith.external.constants.spans.OnLoadSpan.GET_ALL_EXECUTABLES_BY_CREATOR_ID; +import static com.appsmith.external.constants.spans.OnLoadSpan.GET_POSSIBLE_ENTITY_PARENTS_MAP; +import static com.appsmith.external.constants.spans.OnLoadSpan.GET_POSSIBLE_ENTITY_REFERENCES; +import static com.appsmith.external.constants.spans.OnLoadSpan.GET_UNPUBLISHED_ON_LOAD_EXECUTABLES_EXPLICIT_SET_BY_USER_IN_CREATOR_CONTEXT; +import static com.appsmith.external.constants.spans.OnLoadSpan.UPDATE_EXECUTABLE_SELF_REFERENCING_PATHS; import static com.appsmith.external.helpers.MustacheHelper.EXECUTABLE_ENTITY_REFERENCES; import static com.appsmith.external.helpers.MustacheHelper.WIDGET_ENTITY_REFERENCES; import static com.appsmith.external.helpers.MustacheHelper.getPossibleParents; @@ -140,6 +148,8 @@ public Mono>> findAllOnLoadExecutables( .toList(); }) .collectMap(Tuple2::getT1, Tuple2::getT2) + .name(EXECUTABLE_NAME_TO_EXECUTABLE_MAP) + .tap(Micrometer.observation(observationRegistry)) .cache(); Mono> executablesInCreatorContextMono = allExecutablesByCreatorIdFlux @@ -151,14 +161,16 @@ public Mono>> findAllOnLoadExecutables( Mono> directlyReferencedExecutablesToGraphMono = addDirectlyReferencedExecutablesToGraph( - edgesRef, - executablesUsedInDSLRef, - bindingsFromExecutablesRef, - executablesFoundDuringWalkRef, - widgetDynamicBindingsMap, - executableNameToExecutableMapMono, - executableBindingsInDslRef, - evaluatedVersion); + edgesRef, + executablesUsedInDSLRef, + bindingsFromExecutablesRef, + executablesFoundDuringWalkRef, + widgetDynamicBindingsMap, + executableNameToExecutableMapMono, + executableBindingsInDslRef, + evaluatedVersion) + .name(ADD_DIRECTLY_REFERENCED_EXECUTABLES_TO_GRAPH) + .tap(Micrometer.observation(observationRegistry)); // This following `createAllEdgesForPageMono` publisher traverses the executables and widgets to add all // possible edges between all possible entity paths @@ -168,15 +180,17 @@ public Mono>> findAllOnLoadExecutables( Mono> createAllEdgesForPageMono = directlyReferencedExecutablesToGraphMono // Add dependencies of all on page load executables set by the user in the graph .flatMap(updatedEdges -> addExplicitUserSetOnLoadExecutablesToGraph( - creatorId, - updatedEdges, - explicitUserSetOnLoadExecutablesRef, - executablesFoundDuringWalkRef, - bindingsFromExecutablesRef, - executableNameToExecutableMapMono, - executableBindingsInDslRef, - evaluatedVersion, - creatorType)) + creatorId, + updatedEdges, + explicitUserSetOnLoadExecutablesRef, + executablesFoundDuringWalkRef, + bindingsFromExecutablesRef, + executableNameToExecutableMapMono, + executableBindingsInDslRef, + evaluatedVersion, + creatorType) + .name(ADD_EXPLICIT_USER_SET_ON_LOAD_EXECUTABLES_TO_GRAPH) + .tap(Micrometer.observation(observationRegistry))) // For all the executables found so far, recursively walk the dynamic bindings of the executables to // find more relationships with other executables (& widgets) .flatMap(updatedEdges -> recursivelyAddExecutablesAndTheirDependentsToGraphFromBindings( @@ -424,7 +438,10 @@ private List addExecutableUpdatesForExecutableNames( } protected Flux getAllExecutablesByCreatorIdFlux(String creatorId, CreatorContextType creatorType) { - return pageExecutableOnLoadService.getAllExecutablesByCreatorIdFlux(creatorId); + return pageExecutableOnLoadService + .getAllExecutablesByCreatorIdFlux(creatorId) + .name(GET_ALL_EXECUTABLES_BY_CREATOR_ID) + .tap(Micrometer.observation(observationRegistry)); } /** @@ -488,7 +505,9 @@ private Mono>> filterAndTransformSchedulingOrderToDTO */ private Mono> getPossibleEntityReferences( Mono> executableNameToExecutableMapMono, Set bindings, int evalVersion) { - return getPossibleEntityReferences(executableNameToExecutableMapMono, bindings, evalVersion, null); + return getPossibleEntityReferences(executableNameToExecutableMapMono, bindings, evalVersion, null) + .name(GET_POSSIBLE_ENTITY_REFERENCES) + .tap(Micrometer.observation(observationRegistry)); } /** @@ -511,7 +530,9 @@ private Mono> getPossibleEntityReferences( final int entityTypes = EXECUTABLE_ENTITY_REFERENCES | WIDGET_ENTITY_REFERENCES; return executableNameToExecutableMono - .zipWith(getPossibleEntityParentsMap(bindings, entityTypes, evalVersion)) + .zipWith(getPossibleEntityParentsMap(bindings, entityTypes, evalVersion) + .name(GET_POSSIBLE_ENTITY_PARENTS_MAP) + .tap(Micrometer.observation(observationRegistry))) .map(tuple -> { Map executableMap = tuple.getT1(); // For each binding, here we receive a set of possible references to global entities @@ -626,6 +647,8 @@ private Mono> addDirectlyReferencedExecutablesToGr bindingsInWidget, evalVersion, executableBindingsInDslRef) + .name(GET_POSSIBLE_ENTITY_REFERENCES) + .tap(Micrometer.observation(observationRegistry)) .flatMapMany(Flux::fromIterable) // Add dependencies of the executables found in the DSL in the graph // We are ignoring the widget references at this point @@ -638,6 +661,8 @@ private Mono> addDirectlyReferencedExecutablesToGr // for on page load executablesUsedInDSLRef.add(possibleEntity.getValidEntityName()); return updateExecutableSelfReferencingPaths(possibleEntity) + .name(UPDATE_EXECUTABLE_SELF_REFERENCING_PATHS) + .tap(Micrometer.observation(observationRegistry)) .flatMap(executable -> extractAndSetExecutableBindingsInGraphEdges( possibleEntity, edgesRef, @@ -914,11 +939,15 @@ private Mono> recursivelyAddExecutablesAndTheirDep // First fetch all the executables in the page whose name matches the words found in all the dynamic bindings Mono> findAndAddExecutablesInBindingsMono = getPossibleEntityReferences( executableNameToExecutableMapMono, dynamicBindings, evalVersion) + .name(GET_POSSIBLE_ENTITY_REFERENCES) + .tap(Micrometer.observation(observationRegistry)) .flatMapMany(Flux::fromIterable) // Add dependencies of the executables found in the DSL in the graph. .flatMap(possibleEntity -> { if (getExecutableTypes().contains(possibleEntity.getEntityReferenceType())) { return updateExecutableSelfReferencingPaths(possibleEntity) + .name(UPDATE_EXECUTABLE_SELF_REFERENCING_PATHS) + .tap(Micrometer.observation(observationRegistry)) .then(extractAndSetExecutableBindingsInGraphEdges( possibleEntity, edges, @@ -981,6 +1010,8 @@ private Mono> addExplicitUserSetOnLoadExecutablesT // First fetch all the executables which have been tagged as on load by the user explicitly. return getUnpublishedOnLoadExecutablesExplicitSetByUserInCreatorContextFlux(creatorId, creatorType) + .name(GET_UNPUBLISHED_ON_LOAD_EXECUTABLES_EXPLICIT_SET_BY_USER_IN_CREATOR_CONTEXT) + .tap(Micrometer.observation(observationRegistry)) .flatMap(this::fillSelfReferencingPaths) // Add the vertices and edges to the graph for these executables .flatMap(executable -> { @@ -1084,6 +1115,8 @@ private Mono extractAndSetExecutableBindingsInGraphEdges( executableBindingsMap.get(bindingPath), evalVersion, bindingsInDsl) + .name(GET_POSSIBLE_ENTITY_REFERENCES) + .tap(Micrometer.observation(observationRegistry)) .flatMapMany(Flux::fromIterable) .map(relatedDependencyNode -> { bindingsFromExecutables.add(relatedDependencyNode.getReferenceString()); @@ -1114,6 +1147,8 @@ private Mono> addWidgetRelationshipToGraph( return Flux.fromIterable(widgetBindingMap.entrySet()) .flatMap(widgetBindingEntries -> getPossibleEntityParentsMap( widgetBindingEntries.getValue(), entityTypes, evalVersion) + .name(GET_POSSIBLE_ENTITY_PARENTS_MAP) + .tap(Micrometer.observation(observationRegistry)) .map(possibleParentsMap -> { possibleParentsMap.entrySet().stream().forEach(entry -> { if (entry.getValue() == null || entry.getValue().isEmpty()) { diff --git a/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java b/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java index 43a29dcca185..45fe4a882efc 100755 --- a/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java +++ b/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java @@ -79,6 +79,8 @@ public Mono updateAction(String id, ActionDTO actionDTO) { if (actionDTO.getCollectionId() == null) { return this.updateSingleAction(id, actionDTO).flatMap(updatedAction -> updateLayoutService .updatePageLayoutsByPageId(updatedAction.getPageId()) + .name(UPDATE_PAGE_LAYOUT_BY_PAGE_ID) + .tap(Micrometer.observation(observationRegistry)) .thenReturn(updatedAction)); } else if (actionDTO.getCollectionId().length() == 0) { // The Action has been removed from existing collection. @@ -91,6 +93,8 @@ public Mono updateAction(String id, ActionDTO actionDTO) { actionDTO.setCollectionId(null); return this.updateSingleAction(id, actionDTO).flatMap(updatedAction -> updateLayoutService .updatePageLayoutsByPageId(updatedAction.getPageId()) + .name(UPDATE_PAGE_LAYOUT_BY_PAGE_ID) + .tap(Micrometer.observation(observationRegistry)) .thenReturn(updatedAction)); }); } else { @@ -120,6 +124,8 @@ public Mono updateAction(String id, ActionDTO actionDTO) { action1.getId()); return this.updateSingleAction(id, actionDTO).flatMap(updatedAction -> updateLayoutService .updatePageLayoutsByPageId(updatedAction.getPageId()) + .name(UPDATE_PAGE_LAYOUT_BY_PAGE_ID) + .tap(Micrometer.observation(observationRegistry)) .thenReturn(updatedAction)); }); } @@ -276,6 +282,8 @@ public Mono setExecuteOnLoad(String id, Boolean isExecuteOnLoad) { return newActionService.save(newAction).flatMap(savedAction -> updateLayoutService .updatePageLayoutsByPageId( savedAction.getUnpublishedAction().getPageId()) + .name(UPDATE_PAGE_LAYOUT_BY_PAGE_ID) + .tap(Micrometer.observation(observationRegistry)) .thenReturn(newActionService.generateActionByViewMode(savedAction, false))); }); } @@ -289,6 +297,8 @@ public Mono deleteUnpublishedAction(String id) { .deleteUnpublishedAction(id) .flatMap(actionDTO -> Mono.zip( Mono.just(actionDTO), updateLayoutService.updatePageLayoutsByPageId(actionDTO.getPageId()))) + .name(UPDATE_PAGE_LAYOUT_BY_PAGE_ID) + .tap(Micrometer.observation(observationRegistry)) .flatMap(tuple -> { ActionDTO actionDTO = tuple.getT1(); return Mono.just(actionDTO); diff --git a/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java b/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java index d4cc9fcbdf65..aa0d73de132e 100644 --- a/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java +++ b/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java @@ -375,6 +375,17 @@ public Mono updateUnpublishedActionCollection( .name(DELETE_ACTION) .tap(Micrometer.observation(observationRegistry)); + String body = actionCollectionDTO.getBody(); + Number lineCount = 0; + if (body != null && !body.isEmpty()) { + lineCount = body.split("\n").length; + } + Number actionCount = 0; + if (actionCollectionDTO.getActions() != null + && !actionCollectionDTO.getActions().isEmpty()) { + actionCount = actionCollectionDTO.getActions().size(); + } + return deleteNonExistingActionMono .then(newValidActionIdsMono) .flatMap(tuple -> { @@ -392,6 +403,8 @@ public Mono updateUnpublishedActionCollection( }); }) .flatMap(actionCollection -> actionCollectionService.update(actionCollection.getId(), actionCollection)) + .tag("lineCount", lineCount.toString()) + .tag("actionCount", actionCount.toString()) .name(ACTION_COLLECTION_UPDATE) .tap(Micrometer.observation(observationRegistry)) .flatMap(actionCollectionRepository::setUserPermissionsInObject)