From 4117393e553d1a593d8a1fa5c0ab5dfb81d9fbb7 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Fri, 5 Apr 2024 15:24:15 +0530 Subject: [PATCH 1/7] added changes --- .../git/service/ce/GitExecutorCEImpl.java | 30 +++++----- .../external/constants/spans/BaseSpan.java | 2 + .../external/git/constants/GitSpans.java | 57 +++++++++---------- .../external/git/constants/ce/GitSpansCE.java | 32 +++++++++++ .../appsmith/external/git/GitSpansTest.java | 31 ++++++++++ .../base/ApplicationServiceCEImpl.java | 12 +++- .../base/ApplicationServiceImpl.java | 7 ++- .../applications/spans/ApplicationSpans.java | 3 + .../spans/ApplicationSpansCE.java | 13 +++++ .../server/services/ce/GitServiceCEImpl.java | 13 +++-- .../ApplicationServiceCECompatibleImpl.java | 7 ++- 11 files changed, 151 insertions(+), 56 deletions(-) create mode 100644 app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java create mode 100644 app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java index 4ff073d07c0..ec591fa87c5 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java @@ -139,7 +139,7 @@ public Mono commitArtifact( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_COMMIT.getEventName()) + .name(GitSpans.FILE_SYSTEM_COMMIT) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -243,7 +243,7 @@ public Mono pushApplication( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_PUSH.getEventName()) + .name(GitSpans.FILE_SYSTEM_PUSH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -285,7 +285,7 @@ public Mono cloneRemoteIntoArtifactRepo( return branchName; }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_CLONE_REPO.getEventName()) + .name(GitSpans.FILE_SYSTEM_CLONE_REPO) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -315,7 +315,7 @@ public Mono createAndCheckoutToBranch(Path repoSuffix, String branchName } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_CREATE_BRANCH.getEventName()) + .name(GitSpans.FILE_SYSTEM_CREATE_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -345,7 +345,7 @@ public Mono deleteBranch(Path repoSuffix, String branchName) { } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_DELETE_BRANCH.getEventName()) + .name(GitSpans.FILE_SYSTEM_DELETE_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -381,7 +381,7 @@ public Mono checkoutToBranch(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(CHECKOUT_REMOTE, FALSE.toString()) - .name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH.getEventName()) + .name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -443,7 +443,7 @@ public Mono pullApplication( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_PULL.getEventName()) + .name(GitSpans.FILE_SYSTEM_PULL) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -560,7 +560,7 @@ public Mono getStatus(Path repoPath, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .flatMap(response -> response) - .name(GitSpans.FILE_SYSTEM_STATUS.getEventName()) + .name(GitSpans.FILE_SYSTEM_STATUS) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -682,7 +682,7 @@ public Mono mergeBranch(Path repoSuffix, String sourceBranch, String des } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_MERGE.getEventName()) + .name(GitSpans.FILE_SYSTEM_MERGE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -727,7 +727,7 @@ public Mono fetchRemote( return Mono.error(error); }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_FETCH_REMOTE.getEventName()) + .name(GitSpans.FILE_SYSTEM_FETCH_REMOTE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -838,7 +838,7 @@ public Mono checkoutRemoteBranch(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(CHECKOUT_REMOTE, TRUE.toString()) - .name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH.getEventName()) + .name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -873,7 +873,7 @@ private Mono resetToLastCommit(Git git) throws GitAPIException { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(HARD_RESET, Boolean.FALSE.toString()) - .name(GitSpans.FILE_SYSTEM_RESET.getEventName()) + .name(GitSpans.FILE_SYSTEM_RESET) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -909,7 +909,7 @@ public Mono resetHard(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(HARD_RESET, TRUE.toString()) - .name(GitSpans.FILE_SYSTEM_RESET.getEventName()) + .name(GitSpans.FILE_SYSTEM_RESET) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -940,7 +940,7 @@ public Mono rebaseBranch(Path repoSuffix, String branchName) { } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_REBASE.getEventName()) + .name(GitSpans.FILE_SYSTEM_REBASE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -953,7 +953,7 @@ public Mono getBranchTrackingStatus(Path repoPath, String } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_BRANCH_TRACK.getEventName()) + .name(GitSpans.FILE_SYSTEM_BRANCH_TRACK) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/BaseSpan.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/BaseSpan.java index 392f7586b02..b654c484794 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/BaseSpan.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/BaseSpan.java @@ -7,4 +7,6 @@ public class BaseSpan { * This prefix is for all the git flows */ public static final String GIT_SPAN_PREFIX = "git."; + + public static final String APPLICATION_SPAN_PREFIX = "application."; } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java index 20fe0cb7f31..697fe57a71d 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java @@ -1,36 +1,33 @@ package com.appsmith.external.git.constants; -import java.util.Locale; +import com.appsmith.external.git.constants.ce.GitSpansCE; -import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; -import static com.appsmith.external.constants.spans.BaseSpan.GIT_SPAN_PREFIX; +public class GitSpans extends GitSpansCE { + // FILE_SYSTEM_CLONE_REPO, + // FILE_SYSTEM_STATUS, + // FILE_SYSTEM_PULL, + // FILE_SYSTEM_BRANCH_TRACK, + // ADD_FILE_LOCK, + // RELEASE_FILE_LOCK, + // FILE_SYSTEM_COMMIT, + // FILE_SYSTEM_CHECKOUT_BRANCH, + // FILE_SYSTEM_CREATE_BRANCH, + // FILE_SYSTEM_DELETE_BRANCH, + // FILE_SYSTEM_CREATE_REPO, + // FILE_SYSTEM_RESET, + // FILE_SYSTEM_MERGE, + // FILE_SYSTEM_REBASE, + // FILE_SYSTEM_PUSH, + // FILE_SYSTEM_FETCH_REMOTE, + // STATUS, + // COMMIT; + // private final String eventName; -public enum GitSpans { - FILE_SYSTEM_CLONE_REPO, - FILE_SYSTEM_STATUS, - FILE_SYSTEM_PULL, - FILE_SYSTEM_BRANCH_TRACK, - ADD_FILE_LOCK, - RELEASE_FILE_LOCK, - FILE_SYSTEM_COMMIT, - FILE_SYSTEM_CHECKOUT_BRANCH, - FILE_SYSTEM_CREATE_BRANCH, - FILE_SYSTEM_DELETE_BRANCH, - FILE_SYSTEM_CREATE_REPO, - FILE_SYSTEM_RESET, - FILE_SYSTEM_MERGE, - FILE_SYSTEM_REBASE, - FILE_SYSTEM_PUSH, - FILE_SYSTEM_FETCH_REMOTE, - STATUS, - COMMIT; - private final String eventName; + // GitSpans() { + // this.eventName = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + name().toLowerCase(Locale.ROOT); + // } - GitSpans() { - this.eventName = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + name().toLowerCase(Locale.ROOT); - } - - public String getEventName() { - return this.eventName; - } + // public String getEventName() { + // return this.eventName; + // } } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java new file mode 100644 index 00000000000..e6dbf32dd8a --- /dev/null +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java @@ -0,0 +1,32 @@ +package com.appsmith.external.git.constants.ce; + +import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; +import static com.appsmith.external.constants.spans.BaseSpan.GIT_SPAN_PREFIX; + +public class GitSpansCE { + + public static String FILE_SYSTEM_CLONE_REPO = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_clone_repo"; + public static final String FILE_SYSTEM_STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_status"; + public static final String FILE_SYSTEM_PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_pull"; + public static final String FILE_SYSTEM_BRANCH_TRACK = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_branch_track"; + public static final String ADD_FILE_LOCK = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "add_file_lock"; + public static final String RELEASE_FILE_LOCK = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "release_file_lock"; + public static final String FILE_SYSTEM_COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_commit"; + public static final String FILE_SYSTEM_CHECKOUT_BRANCH = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_checkout_branch"; + public static final String FILE_SYSTEM_CREATE_BRANCH = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_create_branch"; + public static final String FILE_SYSTEM_DELETE_BRANCH = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_delete_branch"; + public static final String FILE_SYSTEM_CREATE_REPO = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_create_repo"; + public static final String FILE_SYSTEM_RESET = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_reset"; + public static final String FILE_SYSTEM_MERGE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_merge"; + public static final String FILE_SYSTEM_REBASE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_rebase"; + public static final String FILE_SYSTEM_PUSH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_push"; + public static final String FILE_SYSTEM_FETCH_REMOTE = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_fetch_remote"; + public static final String STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "status"; + public static final String COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "commit"; +} diff --git a/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java b/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java new file mode 100644 index 00000000000..07fd5ed9ef2 --- /dev/null +++ b/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java @@ -0,0 +1,31 @@ +package com.appsmith.external.git; + +import com.appsmith.external.git.constants.ce.GitSpansCE; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Field; + +import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; +import static com.appsmith.external.constants.spans.BaseSpan.GIT_SPAN_PREFIX; +import static org.assertj.core.api.Assertions.assertThat; + +@Slf4j +public class GitSpansTest { + + @Test + public void enforceCorrectNameUsage_InGitSpansCE() throws IllegalAccessException { + Class gitSpansClass = GitSpansCE.class; + Field[] fields = gitSpansClass.getDeclaredFields(); + for (Field field : fields) { + if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { + // Allow access to private fields + field.setAccessible(true); + String prefix = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX; + String propertyName = field.getName(); + String propertyValue = (String) field.get(null); + assertThat(propertyValue).isEqualTo(prefix + propertyName.toLowerCase()); + } + } + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java index 5daa38c2793..2c4019f33f9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java @@ -4,6 +4,7 @@ import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Policy; import com.appsmith.server.acl.AclPermission; +import com.appsmith.server.applications.spans.ApplicationSpans; import com.appsmith.server.constants.ApplicationConstants; import com.appsmith.server.constants.Assets; import com.appsmith.server.constants.FieldName; @@ -44,6 +45,7 @@ import com.appsmith.server.solutions.DatasourcePermission; import com.appsmith.server.solutions.PolicySolution; import com.appsmith.server.solutions.WorkspacePermission; +import io.micrometer.observation.ObservationRegistry; import jakarta.validation.Validator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; @@ -53,6 +55,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; +import reactor.core.observability.micrometer.Micrometer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -90,6 +93,7 @@ public class ApplicationServiceCEImpl extends BaseService getSshKey(String applicationId) { public Mono findByBranchNameAndDefaultApplicationId( String branchName, String defaultApplicationId, AclPermission aclPermission) { - return findByBranchNameAndDefaultApplicationId(branchName, defaultApplicationId, null, aclPermission); + return findByBranchNameAndDefaultApplicationId(branchName, defaultApplicationId, null, aclPermission) + .name(ApplicationSpans.FETCH_BY_DEFAULT_ID_AND_BRANCH) + .tap(Micrometer.observation(observationRegistry)); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java index 13a30ec536b..aae3b6fb08e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java @@ -15,6 +15,7 @@ import com.appsmith.server.solutions.DatasourcePermission; import com.appsmith.server.solutions.PolicySolution; import com.appsmith.server.solutions.WorkspacePermission; +import io.micrometer.observation.ObservationRegistry; import jakarta.validation.Validator; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -38,7 +39,8 @@ public ApplicationServiceImpl( SessionUserService sessionUserService, UserDataService userDataService, WorkspaceService workspaceService, - WorkspacePermission workspacePermission) { + WorkspacePermission workspacePermission, + ObservationRegistry observationRegistry) { super( validator, @@ -55,6 +57,7 @@ public ApplicationServiceImpl( sessionUserService, userDataService, workspaceService, - workspacePermission); + workspacePermission, + observationRegistry); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java new file mode 100644 index 00000000000..dbb12d9b2cb --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java @@ -0,0 +1,3 @@ +package com.appsmith.server.applications.spans; + +public class ApplicationSpans extends ApplicationSpansCE {} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java new file mode 100644 index 00000000000..8965e98acd7 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java @@ -0,0 +1,13 @@ +package com.appsmith.server.applications.spans; + +import static com.appsmith.external.constants.spans.BaseSpan.APPLICATION_SPAN_PREFIX; +import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; + +public class ApplicationSpansCE { + + public static final String FETCH_BY_DEFAULT_ID = + APPSMITH_SPAN_PREFIX + APPLICATION_SPAN_PREFIX + "fetch_by_default_id"; + public static final String FETCH_BY_DEFAULT_ID_AND_BRANCH = + APPSMITH_SPAN_PREFIX + APPLICATION_SPAN_PREFIX + "fetch_by_default_id_and_branch"; + public static final String FETCH_BY_ID = APPSMITH_SPAN_PREFIX + APPLICATION_SPAN_PREFIX + "fetch_by_id"; +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 6c4376869f9..5e71937bb48 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java @@ -14,6 +14,7 @@ import com.appsmith.server.acl.AclPermission; import com.appsmith.server.actioncollections.base.ActionCollectionService; import com.appsmith.server.applications.base.ApplicationService; +import com.appsmith.server.applications.spans.ApplicationSpans; import com.appsmith.server.configurations.EmailConfig; import com.appsmith.server.constants.Assets; import com.appsmith.server.constants.Entity; @@ -625,7 +626,7 @@ private Mono commitApplication( childApplication.getGitApplicationMetadata().getIsRepoPrivate(), isSystemGenerated)) .thenReturn(status) - .name(COMMIT.getEventName()) + .name(COMMIT) .tap(Micrometer.observation(observationRegistry)); }); @@ -1591,7 +1592,9 @@ public Mono getApplicationById(String applicationId, AclPermission return applicationService .findById(applicationId, aclPermission) .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId))); + AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId))) + .name(ApplicationSpans.FETCH_BY_ID) + .tap(Micrometer.observation(observationRegistry)); } @Deprecated @@ -2000,7 +2003,7 @@ private Mono getStatus( throwable); return Mono.error(new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, throwable.getMessage())); }) - .name(STATUS.getEventName()) + .name(STATUS) .tap(Micrometer.observation(observationRegistry)); return Mono.zip(statusMono, sessionUserService.getCurrentUser(), branchedAppMono) @@ -3279,14 +3282,14 @@ private Mono addFileLock(String defaultApplicationId) { .onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> { throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE); })) - .name(GitSpans.ADD_FILE_LOCK.getEventName()) + .name(GitSpans.ADD_FILE_LOCK) .tap(Micrometer.observation(observationRegistry)); } private Mono releaseFileLock(String defaultApplicationId) { return redisUtils .releaseFileLock(defaultApplicationId) - .name(GitSpans.RELEASE_FILE_LOCK.getEventName()) + .name(GitSpans.RELEASE_FILE_LOCK) .tap(Micrometer.observation(observationRegistry)); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java index e25ce51901e..793a842c79b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java @@ -15,6 +15,7 @@ import com.appsmith.server.solutions.DatasourcePermission; import com.appsmith.server.solutions.PolicySolution; import com.appsmith.server.solutions.WorkspacePermission; +import io.micrometer.observation.ObservationRegistry; import jakarta.validation.Validator; import org.springframework.stereotype.Service; @@ -36,7 +37,8 @@ public ApplicationServiceCECompatibleImpl( SessionUserService sessionUserService, UserDataService userDataService, WorkspaceService workspaceService, - WorkspacePermission workspacePermission) { + WorkspacePermission workspacePermission, + ObservationRegistry observationRegistry) { super( validator, repository, @@ -52,6 +54,7 @@ public ApplicationServiceCECompatibleImpl( sessionUserService, userDataService, workspaceService, - workspacePermission); + workspacePermission, + observationRegistry); } } From 2f423f5eceac040f5af08149b26ae936af632e2c Mon Sep 17 00:00:00 2001 From: sondermanish Date: Fri, 5 Apr 2024 15:36:00 +0530 Subject: [PATCH 2/7] removed commented code --- .../external/git/constants/GitSpans.java | 30 +------------------ .../base/ApplicationServiceCEImpl.java | 6 +++- .../server/services/ce/GitServiceCEImpl.java | 5 +--- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java index 697fe57a71d..acb50aec2fe 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java @@ -2,32 +2,4 @@ import com.appsmith.external.git.constants.ce.GitSpansCE; -public class GitSpans extends GitSpansCE { - // FILE_SYSTEM_CLONE_REPO, - // FILE_SYSTEM_STATUS, - // FILE_SYSTEM_PULL, - // FILE_SYSTEM_BRANCH_TRACK, - // ADD_FILE_LOCK, - // RELEASE_FILE_LOCK, - // FILE_SYSTEM_COMMIT, - // FILE_SYSTEM_CHECKOUT_BRANCH, - // FILE_SYSTEM_CREATE_BRANCH, - // FILE_SYSTEM_DELETE_BRANCH, - // FILE_SYSTEM_CREATE_REPO, - // FILE_SYSTEM_RESET, - // FILE_SYSTEM_MERGE, - // FILE_SYSTEM_REBASE, - // FILE_SYSTEM_PUSH, - // FILE_SYSTEM_FETCH_REMOTE, - // STATUS, - // COMMIT; - // private final String eventName; - - // GitSpans() { - // this.eventName = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + name().toLowerCase(Locale.ROOT); - // } - - // public String getEventName() { - // return this.eventName; - // } -} +public class GitSpans extends GitSpansCE {} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java index 2c4019f33f9..0a275bedec1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java @@ -177,7 +177,11 @@ public Mono findById(String id) { @Override @Deprecated public Mono findById(String id, AclPermission aclPermission) { - return repository.findById(id, aclPermission).flatMap(this::setTransientFields); + return repository + .findById(id, aclPermission) + .flatMap(this::setTransientFields) + .name(ApplicationSpans.FETCH_BY_ID) + .tap(Micrometer.observation(observationRegistry)); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 5e71937bb48..8040c0fcb12 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java @@ -14,7 +14,6 @@ import com.appsmith.server.acl.AclPermission; import com.appsmith.server.actioncollections.base.ActionCollectionService; import com.appsmith.server.applications.base.ApplicationService; -import com.appsmith.server.applications.spans.ApplicationSpans; import com.appsmith.server.configurations.EmailConfig; import com.appsmith.server.constants.Assets; import com.appsmith.server.constants.Entity; @@ -1592,9 +1591,7 @@ public Mono getApplicationById(String applicationId, AclPermission return applicationService .findById(applicationId, aclPermission) .switchIfEmpty(Mono.error(new AppsmithException( - AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId))) - .name(ApplicationSpans.FETCH_BY_ID) - .tap(Micrometer.observation(observationRegistry)); + AppsmithError.ACL_NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId))); } @Deprecated From 54080a43c46262d8187be2952d1ab722ff4b88d1 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Mon, 8 Apr 2024 16:32:09 +0530 Subject: [PATCH 3/7] added more tappings --- .../external/git/constants/ce/GitSpansCE.java | 11 +++- .../server/services/ce/GitServiceCEImpl.java | 56 +++++++++++++------ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java index e6dbf32dd8a..a096ffb3bd5 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java @@ -5,7 +5,8 @@ public class GitSpansCE { - public static String FILE_SYSTEM_CLONE_REPO = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_clone_repo"; + public static final String FILE_SYSTEM_CLONE_REPO = + APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_clone_repo"; public static final String FILE_SYSTEM_STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_status"; public static final String FILE_SYSTEM_PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_pull"; public static final String FILE_SYSTEM_BRANCH_TRACK = @@ -29,4 +30,12 @@ public class GitSpansCE { APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_fetch_remote"; public static final String STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "status"; public static final String COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "commit"; + public static final String PUSH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "push"; + public static final String PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "pull"; + public static final String CREATE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "create_branch"; + public static final String CHECKOUT_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "checkout_branch"; + public static final String DELETE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "delete_branch"; + public static final String FETCH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fetch_remote"; + public static final String DETACH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "detach_remote"; + public static final String DISCARD_CHANGES = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "discard_changes"; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 8040c0fcb12..94a0e403498 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java @@ -7,6 +7,7 @@ import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; import com.appsmith.external.git.GitExecutor; +import com.appsmith.external.git.constants.GitConstants; import com.appsmith.external.git.constants.GitSpans; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceStorage; @@ -116,6 +117,7 @@ import static com.appsmith.server.helpers.DefaultResourcesUtils.createDefaultIdsOrUpdateWithGivenResourceIds; import static com.appsmith.server.helpers.GitUtils.MAX_RETRIES; import static com.appsmith.server.helpers.GitUtils.RETRY_DELAY; +import static java.lang.Boolean.FALSE; import static java.lang.Boolean.TRUE; import static org.apache.commons.lang.ObjectUtils.defaultIfNull; @@ -219,10 +221,10 @@ public Mono> updateOrCreateGitProfileForCurrentUser( // 2. Updating or creating repo specific profile and user want to use repo specific profile but provided empty // values for authorName and email - if ((DEFAULT.equals(defaultApplicationId) || Boolean.FALSE.equals(gitProfile.getUseGlobalProfile())) + if ((DEFAULT.equals(defaultApplicationId) || FALSE.equals(gitProfile.getUseGlobalProfile())) && StringUtils.isEmptyOrNull(gitProfile.getAuthorName())) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "Author Name")); - } else if ((DEFAULT.equals(defaultApplicationId) || Boolean.FALSE.equals(gitProfile.getUseGlobalProfile())) + } else if ((DEFAULT.equals(defaultApplicationId) || FALSE.equals(gitProfile.getUseGlobalProfile())) && StringUtils.isEmptyOrNull(gitProfile.getAuthorEmail())) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "Author Email")); } else if (StringUtils.isEmptyOrNull(defaultApplicationId)) { @@ -232,7 +234,7 @@ public Mono> updateOrCreateGitProfileForCurrentUser( if (DEFAULT.equals(defaultApplicationId)) { gitProfile.setUseGlobalProfile(null); } else if (!TRUE.equals(gitProfile.getUseGlobalProfile())) { - gitProfile.setUseGlobalProfile(Boolean.FALSE); + gitProfile.setUseGlobalProfile(FALSE); } return sessionUserService @@ -458,7 +460,7 @@ private Mono commitApplication( .flatMap(application -> gitPrivateRepoHelper.isRepoLimitReached(workspaceId, false)) .flatMap(isRepoLimitReached -> { - if (Boolean.FALSE.equals(isRepoLimitReached)) { + if (FALSE.equals(isRepoLimitReached)) { return Mono.just(defaultApplication); } throw new AppsmithException(AppsmithError.GIT_APPLICATION_LIMIT_ERROR); @@ -738,7 +740,7 @@ public Mono connectApplicationToGit( return gitPrivateRepoHelper .isRepoLimitReached(application.getWorkspaceId(), true) .flatMap(isRepoLimitReached -> { - if (Boolean.FALSE.equals(isRepoLimitReached)) { + if (FALSE.equals(isRepoLimitReached)) { return Mono.just(application); } return addAnalyticsForGitOperation( @@ -1092,7 +1094,9 @@ private Mono pushApplication(String applicationId, boolean doPublish, bo application, application.getGitApplicationMetadata().getIsRepoPrivate()) .thenReturn(pushStatus); - }); + }) + .name(GitSpans.PUSH) + .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> pushStatusMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } @@ -1236,7 +1240,9 @@ public Mono detachRemote(String defaultApplicationId) { .collectList() .flatMapMany(actionCollectionService::saveAll)) .then(addAnalyticsForGitOperation(AnalyticsEvents.GIT_DISCONNECT, application, false)) - .map(responseUtils::updateApplicationWithDefaultResources)); + .map(responseUtils::updateApplicationWithDefaultResources)) + .name(GitSpans.DETACH_REMOTE) + .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> disconnectMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } @@ -1377,7 +1383,9 @@ public Mono createBranch(String defaultApplicationId, GitBranchDTO AnalyticsEvents.GIT_CREATE_BRANCH, application, application.getGitApplicationMetadata().getIsRepoPrivate()))) - .map(responseUtils::updateApplicationWithDefaultResources); + .map(responseUtils::updateApplicationWithDefaultResources) + .name(GitSpans.CREATE_BRANCH) + .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> createBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } @@ -1447,6 +1455,9 @@ public Mono checkoutBranch(String defaultApplicationId, String bran } return Mono.just(result); }) + .tag(GitConstants.GitMetricConstants.CHECKOUT_REMOTE, FALSE.toString()) + .name(GitSpans.CHECKOUT_BRANCH) + .tap(Micrometer.observation(observationRegistry)) .onErrorResume(throwable -> { return Mono.error(throwable); }); @@ -1559,7 +1570,10 @@ private Mono checkoutRemoteBranch(String defaultApplicationId, Stri .map(responseUtils::updateApplicationWithDefaultResources) .flatMap(application1 -> releaseFileLock(defaultApplicationId).then(Mono.just(application1))); - }); + }) + .tag(GitConstants.GitMetricConstants.CHECKOUT_REMOTE, TRUE.toString()) + .name(GitSpans.CHECKOUT_BRANCH) + .tap(Micrometer.observation(observationRegistry)); return Mono.create( sink -> checkoutRemoteBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1648,7 +1662,9 @@ public Mono pullApplication(String defaultApplicationId, String bran // Release file lock after the pull operation .flatMap(gitPullDTO -> releaseFileLock(defaultApplicationId).then(Mono.just(gitPullDTO))); - }); + }) + .name(GitSpans.PULL) + .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> pullMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } @@ -1857,7 +1873,7 @@ private Mono> getBranchListWithDefaultBranchName( } return branchDTOList; }) - .flatMap(gitBranchDTOList -> Boolean.FALSE.equals(pruneBranches) + .flatMap(gitBranchDTOList -> FALSE.equals(pruneBranches) ? Mono.just(gitBranchDTOList) : addAnalyticsForGitOperation( AnalyticsEvents.GIT_PRUNE, @@ -2134,7 +2150,9 @@ public Mono fetchRemoteChanges( return sendUnitExecutionTimeAnalyticsEvent( AnalyticsEvents.GIT_FETCH.getEventName(), elapsedTime, currentUser, app) .thenReturn(branchTrackingStatus); - }); + }) + .name(GitSpans.FETCH_REMOTE) + .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> { fetchRemoteStatusMono.subscribe(sink::success, sink::error, null, sink.currentContext()); @@ -2572,7 +2590,7 @@ public Mono importApplicationFromGit(String workspaceId, G return gitPrivateRepoHelper .isRepoLimitReached(workspaceId, true) .flatMap(isRepoLimitReached -> { - if (Boolean.FALSE.equals(isRepoLimitReached)) { + if (FALSE.equals(isRepoLimitReached)) { return Mono.just(gitAuth).zipWith(applicationMono); } return addAnalyticsForGitOperation( @@ -2853,7 +2871,7 @@ public Mono deleteBranch(String defaultApplicationId, String branch .flatMap(isBranchDeleted -> releaseFileLock(defaultApplicationId).map(status -> isBranchDeleted)) .flatMap(isBranchDeleted -> { - if (Boolean.FALSE.equals(isBranchDeleted)) { + if (FALSE.equals(isBranchDeleted)) { return Mono.error(new AppsmithException( AppsmithError.GIT_ACTION_FAILED, " delete branch. Branch does not exists in the repo")); @@ -2889,7 +2907,9 @@ public Mono deleteBranch(String defaultApplicationId, String branch AnalyticsEvents.GIT_DELETE_BRANCH, application, application.getGitApplicationMetadata().getIsRepoPrivate())) - .map(responseUtils::updateApplicationWithDefaultResources); + .map(responseUtils::updateApplicationWithDefaultResources) + .name(GitSpans.DELETE_BRANCH) + .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> deleteBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); } @@ -2952,7 +2972,9 @@ public Mono discardChanges(String defaultApplicationId, String bran }) .flatMap(application -> releaseFileLock(defaultApplicationId) .then(this.addAnalyticsForGitOperation(AnalyticsEvents.GIT_DISCARD_CHANGES, application, null))) - .map(responseUtils::updateApplicationWithDefaultResources); + .map(responseUtils::updateApplicationWithDefaultResources) + .name(GitSpans.DISCARD_CHANGES) + .tap(Micrometer.observation(observationRegistry)); return Mono.create( sink -> discardChangeMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -3364,7 +3386,7 @@ public Mono toggleAutoCommitEnabled(String defaultApplicationId) { AutoCommitConfig autoCommitConfig = gitArtifactMetadata.getAutoCommitConfig(); if (autoCommitConfig.getEnabled()) { - autoCommitConfig.setEnabled(Boolean.FALSE); + autoCommitConfig.setEnabled(FALSE); } else { autoCommitConfig.setEnabled(TRUE); } From 538410358aeee44dfd54141eb1af25e60a4c681a Mon Sep 17 00:00:00 2001 From: sondermanish Date: Tue, 9 Apr 2024 11:50:59 +0530 Subject: [PATCH 4/7] remove application changes --- .../base/ApplicationServiceCEImpl.java | 18 +++--------------- .../base/ApplicationServiceImpl.java | 7 ++----- .../ApplicationServiceCECompatibleImpl.java | 7 ++----- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java index 0a275bedec1..5daa38c2793 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java @@ -4,7 +4,6 @@ import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Policy; import com.appsmith.server.acl.AclPermission; -import com.appsmith.server.applications.spans.ApplicationSpans; import com.appsmith.server.constants.ApplicationConstants; import com.appsmith.server.constants.Assets; import com.appsmith.server.constants.FieldName; @@ -45,7 +44,6 @@ import com.appsmith.server.solutions.DatasourcePermission; import com.appsmith.server.solutions.PolicySolution; import com.appsmith.server.solutions.WorkspacePermission; -import io.micrometer.observation.ObservationRegistry; import jakarta.validation.Validator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; @@ -55,7 +53,6 @@ import org.springframework.stereotype.Service; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; -import reactor.core.observability.micrometer.Micrometer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -93,7 +90,6 @@ public class ApplicationServiceCEImpl extends BaseService findById(String id) { @Override @Deprecated public Mono findById(String id, AclPermission aclPermission) { - return repository - .findById(id, aclPermission) - .flatMap(this::setTransientFields) - .name(ApplicationSpans.FETCH_BY_ID) - .tap(Micrometer.observation(observationRegistry)); + return repository.findById(id, aclPermission).flatMap(this::setTransientFields); } @Override @@ -861,9 +851,7 @@ public Mono getSshKey(String applicationId) { public Mono findByBranchNameAndDefaultApplicationId( String branchName, String defaultApplicationId, AclPermission aclPermission) { - return findByBranchNameAndDefaultApplicationId(branchName, defaultApplicationId, null, aclPermission) - .name(ApplicationSpans.FETCH_BY_DEFAULT_ID_AND_BRANCH) - .tap(Micrometer.observation(observationRegistry)); + return findByBranchNameAndDefaultApplicationId(branchName, defaultApplicationId, null, aclPermission); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java index aae3b6fb08e..13a30ec536b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceImpl.java @@ -15,7 +15,6 @@ import com.appsmith.server.solutions.DatasourcePermission; import com.appsmith.server.solutions.PolicySolution; import com.appsmith.server.solutions.WorkspacePermission; -import io.micrometer.observation.ObservationRegistry; import jakarta.validation.Validator; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -39,8 +38,7 @@ public ApplicationServiceImpl( SessionUserService sessionUserService, UserDataService userDataService, WorkspaceService workspaceService, - WorkspacePermission workspacePermission, - ObservationRegistry observationRegistry) { + WorkspacePermission workspacePermission) { super( validator, @@ -57,7 +55,6 @@ public ApplicationServiceImpl( sessionUserService, userDataService, workspaceService, - workspacePermission, - observationRegistry); + workspacePermission); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java index 793a842c79b..e25ce51901e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce_compatible/ApplicationServiceCECompatibleImpl.java @@ -15,7 +15,6 @@ import com.appsmith.server.solutions.DatasourcePermission; import com.appsmith.server.solutions.PolicySolution; import com.appsmith.server.solutions.WorkspacePermission; -import io.micrometer.observation.ObservationRegistry; import jakarta.validation.Validator; import org.springframework.stereotype.Service; @@ -37,8 +36,7 @@ public ApplicationServiceCECompatibleImpl( SessionUserService sessionUserService, UserDataService userDataService, WorkspaceService workspaceService, - WorkspacePermission workspacePermission, - ObservationRegistry observationRegistry) { + WorkspacePermission workspacePermission) { super( validator, repository, @@ -54,7 +52,6 @@ public ApplicationServiceCECompatibleImpl( sessionUserService, userDataService, workspaceService, - workspacePermission, - observationRegistry); + workspacePermission); } } From 98c9607bd2ff7e53d11f1a58ffb9884a0237cb95 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Tue, 9 Apr 2024 12:43:03 +0530 Subject: [PATCH 5/7] name refactor --- .../git/service/ce/GitExecutorCEImpl.java | 32 +++++++++---------- .../external/git/constants/GitSpan.java | 5 +++ .../external/git/constants/GitSpans.java | 5 --- .../ce/{GitSpansCE.java => GitSpanCE.java} | 2 +- .../appsmith/external/git/GitSpansTest.java | 4 +-- .../server/services/ce/GitServiceCEImpl.java | 28 ++++++++-------- 6 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpan.java delete mode 100644 app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java rename app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/{GitSpansCE.java => GitSpanCE.java} (99%) diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java index ec591fa87c5..0418b4e0a29 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java @@ -7,7 +7,7 @@ import com.appsmith.external.dtos.GitStatusDTO; import com.appsmith.external.dtos.MergeStatusDTO; import com.appsmith.external.git.GitExecutor; -import com.appsmith.external.git.constants.GitSpans; +import com.appsmith.external.git.constants.GitSpan; import com.appsmith.external.helpers.Stopwatch; import com.appsmith.git.configurations.GitServiceConfig; import com.appsmith.git.constants.AppsmithBotAsset; @@ -139,7 +139,7 @@ public Mono commitArtifact( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_COMMIT) + .name(GitSpan.FILE_SYSTEM_COMMIT) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -243,7 +243,7 @@ public Mono pushApplication( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_PUSH) + .name(GitSpan.FILE_SYSTEM_PUSH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -285,7 +285,7 @@ public Mono cloneRemoteIntoArtifactRepo( return branchName; }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_CLONE_REPO) + .name(GitSpan.FILE_SYSTEM_CLONE_REPO) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -315,7 +315,7 @@ public Mono createAndCheckoutToBranch(Path repoSuffix, String branchName } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_CREATE_BRANCH) + .name(GitSpan.FILE_SYSTEM_CREATE_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -345,7 +345,7 @@ public Mono deleteBranch(Path repoSuffix, String branchName) { } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_DELETE_BRANCH) + .name(GitSpan.FILE_SYSTEM_DELETE_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -381,7 +381,7 @@ public Mono checkoutToBranch(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(CHECKOUT_REMOTE, FALSE.toString()) - .name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH) + .name(GitSpan.FILE_SYSTEM_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -443,7 +443,7 @@ public Mono pullApplication( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_PULL) + .name(GitSpan.FILE_SYSTEM_PULL) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -560,7 +560,7 @@ public Mono getStatus(Path repoPath, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .flatMap(response -> response) - .name(GitSpans.FILE_SYSTEM_STATUS) + .name(GitSpan.FILE_SYSTEM_STATUS) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -682,7 +682,7 @@ public Mono mergeBranch(Path repoSuffix, String sourceBranch, String des } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_MERGE) + .name(GitSpan.FILE_SYSTEM_MERGE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -727,7 +727,7 @@ public Mono fetchRemote( return Mono.error(error); }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_FETCH_REMOTE) + .name(GitSpan.FILE_SYSTEM_FETCH_REMOTE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -838,7 +838,7 @@ public Mono checkoutRemoteBranch(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(CHECKOUT_REMOTE, TRUE.toString()) - .name(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH) + .name(GitSpan.FILE_SYSTEM_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -873,7 +873,7 @@ private Mono resetToLastCommit(Git git) throws GitAPIException { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(HARD_RESET, Boolean.FALSE.toString()) - .name(GitSpans.FILE_SYSTEM_RESET) + .name(GitSpan.FILE_SYSTEM_RESET) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -909,7 +909,7 @@ public Mono resetHard(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(HARD_RESET, TRUE.toString()) - .name(GitSpans.FILE_SYSTEM_RESET) + .name(GitSpan.FILE_SYSTEM_RESET) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -940,7 +940,7 @@ public Mono rebaseBranch(Path repoSuffix, String branchName) { } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_REBASE) + .name(GitSpan.FILE_SYSTEM_REBASE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -953,7 +953,7 @@ public Mono getBranchTrackingStatus(Path repoPath, String } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpans.FILE_SYSTEM_BRANCH_TRACK) + .name(GitSpan.FILE_SYSTEM_BRANCH_TRACK) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpan.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpan.java new file mode 100644 index 00000000000..d72a6bc5d3e --- /dev/null +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpan.java @@ -0,0 +1,5 @@ +package com.appsmith.external.git.constants; + +import com.appsmith.external.git.constants.ce.GitSpanCE; + +public class GitSpan extends GitSpanCE {} diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java deleted file mode 100644 index acb50aec2fe..00000000000 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.appsmith.external.git.constants; - -import com.appsmith.external.git.constants.ce.GitSpansCE; - -public class GitSpans extends GitSpansCE {} diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java similarity index 99% rename from app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java rename to app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java index a096ffb3bd5..58900b0266f 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpansCE.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java @@ -3,7 +3,7 @@ import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; import static com.appsmith.external.constants.spans.BaseSpan.GIT_SPAN_PREFIX; -public class GitSpansCE { +public class GitSpanCE { public static final String FILE_SYSTEM_CLONE_REPO = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_clone_repo"; diff --git a/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java b/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java index 07fd5ed9ef2..80c517301fc 100644 --- a/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java +++ b/app/server/appsmith-interfaces/src/test/java/com/appsmith/external/git/GitSpansTest.java @@ -1,6 +1,6 @@ package com.appsmith.external.git; -import com.appsmith.external.git.constants.ce.GitSpansCE; +import com.appsmith.external.git.constants.ce.GitSpanCE; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -15,7 +15,7 @@ public class GitSpansTest { @Test public void enforceCorrectNameUsage_InGitSpansCE() throws IllegalAccessException { - Class gitSpansClass = GitSpansCE.class; + Class gitSpansClass = GitSpanCE.class; Field[] fields = gitSpansClass.getDeclaredFields(); for (Field field : fields) { if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 94a0e403498..20a8216f7b0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java @@ -8,7 +8,7 @@ import com.appsmith.external.dtos.MergeStatusDTO; import com.appsmith.external.git.GitExecutor; import com.appsmith.external.git.constants.GitConstants; -import com.appsmith.external.git.constants.GitSpans; +import com.appsmith.external.git.constants.GitSpan; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceStorage; import com.appsmith.git.service.GitExecutorImpl; @@ -108,8 +108,8 @@ import static com.appsmith.external.git.constants.GitConstants.GIT_CONFIG_ERROR; import static com.appsmith.external.git.constants.GitConstants.GIT_PROFILE_ERROR; import static com.appsmith.external.git.constants.GitConstants.MERGE_CONFLICT_BRANCH_NAME; -import static com.appsmith.external.git.constants.GitSpans.COMMIT; -import static com.appsmith.external.git.constants.GitSpans.STATUS; +import static com.appsmith.external.git.constants.GitSpan.COMMIT; +import static com.appsmith.external.git.constants.GitSpan.STATUS; import static com.appsmith.git.constants.AppsmithBotAsset.APPSMITH_BOT_USERNAME; import static com.appsmith.server.constants.ArtifactType.APPLICATION; import static com.appsmith.server.constants.FieldName.DEFAULT; @@ -1095,7 +1095,7 @@ private Mono pushApplication(String applicationId, boolean doPublish, bo application.getGitApplicationMetadata().getIsRepoPrivate()) .thenReturn(pushStatus); }) - .name(GitSpans.PUSH) + .name(GitSpan.PUSH) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> pushStatusMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1241,7 +1241,7 @@ public Mono detachRemote(String defaultApplicationId) { .flatMapMany(actionCollectionService::saveAll)) .then(addAnalyticsForGitOperation(AnalyticsEvents.GIT_DISCONNECT, application, false)) .map(responseUtils::updateApplicationWithDefaultResources)) - .name(GitSpans.DETACH_REMOTE) + .name(GitSpan.DETACH_REMOTE) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> disconnectMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1384,7 +1384,7 @@ public Mono createBranch(String defaultApplicationId, GitBranchDTO application, application.getGitApplicationMetadata().getIsRepoPrivate()))) .map(responseUtils::updateApplicationWithDefaultResources) - .name(GitSpans.CREATE_BRANCH) + .name(GitSpan.CREATE_BRANCH) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> createBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1456,7 +1456,7 @@ public Mono checkoutBranch(String defaultApplicationId, String bran return Mono.just(result); }) .tag(GitConstants.GitMetricConstants.CHECKOUT_REMOTE, FALSE.toString()) - .name(GitSpans.CHECKOUT_BRANCH) + .name(GitSpan.CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .onErrorResume(throwable -> { return Mono.error(throwable); @@ -1572,7 +1572,7 @@ private Mono checkoutRemoteBranch(String defaultApplicationId, Stri releaseFileLock(defaultApplicationId).then(Mono.just(application1))); }) .tag(GitConstants.GitMetricConstants.CHECKOUT_REMOTE, TRUE.toString()) - .name(GitSpans.CHECKOUT_BRANCH) + .name(GitSpan.CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)); return Mono.create( @@ -1663,7 +1663,7 @@ public Mono pullApplication(String defaultApplicationId, String bran .flatMap(gitPullDTO -> releaseFileLock(defaultApplicationId).then(Mono.just(gitPullDTO))); }) - .name(GitSpans.PULL) + .name(GitSpan.PULL) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> pullMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -2151,7 +2151,7 @@ public Mono fetchRemoteChanges( AnalyticsEvents.GIT_FETCH.getEventName(), elapsedTime, currentUser, app) .thenReturn(branchTrackingStatus); }) - .name(GitSpans.FETCH_REMOTE) + .name(GitSpan.FETCH_REMOTE) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> { @@ -2908,7 +2908,7 @@ public Mono deleteBranch(String defaultApplicationId, String branch application, application.getGitApplicationMetadata().getIsRepoPrivate())) .map(responseUtils::updateApplicationWithDefaultResources) - .name(GitSpans.DELETE_BRANCH) + .name(GitSpan.DELETE_BRANCH) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> deleteBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -2973,7 +2973,7 @@ public Mono discardChanges(String defaultApplicationId, String bran .flatMap(application -> releaseFileLock(defaultApplicationId) .then(this.addAnalyticsForGitOperation(AnalyticsEvents.GIT_DISCARD_CHANGES, application, null))) .map(responseUtils::updateApplicationWithDefaultResources) - .name(GitSpans.DISCARD_CHANGES) + .name(GitSpan.DISCARD_CHANGES) .tap(Micrometer.observation(observationRegistry)); return Mono.create( @@ -3301,14 +3301,14 @@ private Mono addFileLock(String defaultApplicationId) { .onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> { throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE); })) - .name(GitSpans.ADD_FILE_LOCK) + .name(GitSpan.ADD_FILE_LOCK) .tap(Micrometer.observation(observationRegistry)); } private Mono releaseFileLock(String defaultApplicationId) { return redisUtils .releaseFileLock(defaultApplicationId) - .name(GitSpans.RELEASE_FILE_LOCK) + .name(GitSpan.RELEASE_FILE_LOCK) .tap(Micrometer.observation(observationRegistry)); } From 60d265ab55b3373a73f48cc1fb6e3124027dd000 Mon Sep 17 00:00:00 2001 From: sondermanish Date: Tue, 9 Apr 2024 13:21:28 +0530 Subject: [PATCH 6/7] removed application span --- .../server/applications/spans/ApplicationSpans.java | 3 --- .../applications/spans/ApplicationSpansCE.java | 13 ------------- 2 files changed, 16 deletions(-) delete mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java delete mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java deleted file mode 100644 index dbb12d9b2cb..00000000000 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpans.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.appsmith.server.applications.spans; - -public class ApplicationSpans extends ApplicationSpansCE {} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java deleted file mode 100644 index 8965e98acd7..00000000000 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/applications/spans/ApplicationSpansCE.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.appsmith.server.applications.spans; - -import static com.appsmith.external.constants.spans.BaseSpan.APPLICATION_SPAN_PREFIX; -import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; - -public class ApplicationSpansCE { - - public static final String FETCH_BY_DEFAULT_ID = - APPSMITH_SPAN_PREFIX + APPLICATION_SPAN_PREFIX + "fetch_by_default_id"; - public static final String FETCH_BY_DEFAULT_ID_AND_BRANCH = - APPSMITH_SPAN_PREFIX + APPLICATION_SPAN_PREFIX + "fetch_by_default_id_and_branch"; - public static final String FETCH_BY_ID = APPSMITH_SPAN_PREFIX + APPLICATION_SPAN_PREFIX + "fetch_by_id"; -} From bd52debd8dd1ffdf350c793ace9dd0b27c9ed6cc Mon Sep 17 00:00:00 2001 From: sondermanish Date: Tue, 9 Apr 2024 19:41:36 +0530 Subject: [PATCH 7/7] made required changes --- .../git/service/ce/GitExecutorCEImpl.java | 30 +++++----- .../external/git/constants/ce/GitSpanCE.java | 55 ++++++++----------- .../server/services/ce/GitServiceCEImpl.java | 26 ++++----- 3 files changed, 52 insertions(+), 59 deletions(-) diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java index 0418b4e0a29..9d4cfd00bfd 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/service/ce/GitExecutorCEImpl.java @@ -139,7 +139,7 @@ public Mono commitArtifact( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_COMMIT) + .name(GitSpan.FS_COMMIT) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -243,7 +243,7 @@ public Mono pushApplication( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_PUSH) + .name(GitSpan.FS_PUSH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -285,7 +285,7 @@ public Mono cloneRemoteIntoArtifactRepo( return branchName; }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_CLONE_REPO) + .name(GitSpan.FS_CLONE_REPO) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -315,7 +315,7 @@ public Mono createAndCheckoutToBranch(Path repoSuffix, String branchName } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_CREATE_BRANCH) + .name(GitSpan.FS_CREATE_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -345,7 +345,7 @@ public Mono deleteBranch(Path repoSuffix, String branchName) { } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_DELETE_BRANCH) + .name(GitSpan.FS_DELETE_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -381,7 +381,7 @@ public Mono checkoutToBranch(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(CHECKOUT_REMOTE, FALSE.toString()) - .name(GitSpan.FILE_SYSTEM_CHECKOUT_BRANCH) + .name(GitSpan.FS_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -443,7 +443,7 @@ public Mono pullApplication( } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_PULL) + .name(GitSpan.FS_PULL) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -560,7 +560,7 @@ public Mono getStatus(Path repoPath, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .flatMap(response -> response) - .name(GitSpan.FILE_SYSTEM_STATUS) + .name(GitSpan.FS_STATUS) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -682,7 +682,7 @@ public Mono mergeBranch(Path repoSuffix, String sourceBranch, String des } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_MERGE) + .name(GitSpan.FS_MERGE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -727,7 +727,7 @@ public Mono fetchRemote( return Mono.error(error); }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_FETCH_REMOTE) + .name(GitSpan.FS_FETCH_REMOTE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -838,7 +838,7 @@ public Mono checkoutRemoteBranch(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(CHECKOUT_REMOTE, TRUE.toString()) - .name(GitSpan.FILE_SYSTEM_CHECKOUT_BRANCH) + .name(GitSpan.FS_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -873,7 +873,7 @@ private Mono resetToLastCommit(Git git) throws GitAPIException { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(HARD_RESET, Boolean.FALSE.toString()) - .name(GitSpan.FILE_SYSTEM_RESET) + .name(GitSpan.FS_RESET) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -909,7 +909,7 @@ public Mono resetHard(Path repoSuffix, String branchName) { }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) .tag(HARD_RESET, TRUE.toString()) - .name(GitSpan.FILE_SYSTEM_RESET) + .name(GitSpan.FS_RESET) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -940,7 +940,7 @@ public Mono rebaseBranch(Path repoSuffix, String branchName) { } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_REBASE) + .name(GitSpan.FS_REBASE) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } @@ -953,7 +953,7 @@ public Mono getBranchTrackingStatus(Path repoPath, String } }) .timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS)) - .name(GitSpan.FILE_SYSTEM_BRANCH_TRACK) + .name(GitSpan.FS_BRANCH_TRACK) .tap(Micrometer.observation(observationRegistry)) .subscribeOn(scheduler); } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java index 58900b0266f..8fa9e59107f 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java @@ -5,37 +5,30 @@ public class GitSpanCE { - public static final String FILE_SYSTEM_CLONE_REPO = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_clone_repo"; - public static final String FILE_SYSTEM_STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_status"; - public static final String FILE_SYSTEM_PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_pull"; - public static final String FILE_SYSTEM_BRANCH_TRACK = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_branch_track"; + public static final String FS_CLONE_REPO = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_clone_repo"; + public static final String FS_STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_status"; + public static final String FS_PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_pull"; + public static final String FS_BRANCH_TRACK = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_branch_track"; public static final String ADD_FILE_LOCK = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "add_file_lock"; public static final String RELEASE_FILE_LOCK = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "release_file_lock"; - public static final String FILE_SYSTEM_COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_commit"; - public static final String FILE_SYSTEM_CHECKOUT_BRANCH = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_checkout_branch"; - public static final String FILE_SYSTEM_CREATE_BRANCH = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_create_branch"; - public static final String FILE_SYSTEM_DELETE_BRANCH = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_delete_branch"; - public static final String FILE_SYSTEM_CREATE_REPO = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_create_repo"; - public static final String FILE_SYSTEM_RESET = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_reset"; - public static final String FILE_SYSTEM_MERGE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_merge"; - public static final String FILE_SYSTEM_REBASE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_rebase"; - public static final String FILE_SYSTEM_PUSH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_push"; - public static final String FILE_SYSTEM_FETCH_REMOTE = - APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "file_system_fetch_remote"; - public static final String STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "status"; - public static final String COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "commit"; - public static final String PUSH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "push"; - public static final String PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "pull"; - public static final String CREATE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "create_branch"; - public static final String CHECKOUT_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "checkout_branch"; - public static final String DELETE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "delete_branch"; - public static final String FETCH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fetch_remote"; - public static final String DETACH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "detach_remote"; - public static final String DISCARD_CHANGES = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "discard_changes"; + public static final String FS_COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_commit"; + public static final String FS_CHECKOUT_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_checkout_branch"; + public static final String FS_CREATE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_create_branch"; + public static final String FS_DELETE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_delete_branch"; + public static final String FS_CREATE_REPO = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_create_repo"; + public static final String FS_RESET = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_reset"; + public static final String FS_MERGE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_merge"; + public static final String FS_REBASE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_rebase"; + public static final String FS_PUSH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_push"; + public static final String FS_FETCH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "fs_fetch_remote"; + public static final String OPS_STATUS = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_status"; + public static final String OPS_COMMIT = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_commit"; + public static final String OPS_PUSH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_push"; + public static final String OPS_PULL = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_pull"; + public static final String OPS_CREATE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_create_branch"; + public static final String OPS_CHECKOUT_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_checkout_branch"; + public static final String OPS_DELETE_BRANCH = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_delete_branch"; + public static final String OPS_FETCH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_fetch_remote"; + public static final String OPS_DETACH_REMOTE = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_detach_remote"; + public static final String OPS_DISCARD_CHANGES = APPSMITH_SPAN_PREFIX + GIT_SPAN_PREFIX + "ops_discard_changes"; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 20a8216f7b0..a964d78abb5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java @@ -108,8 +108,8 @@ import static com.appsmith.external.git.constants.GitConstants.GIT_CONFIG_ERROR; import static com.appsmith.external.git.constants.GitConstants.GIT_PROFILE_ERROR; import static com.appsmith.external.git.constants.GitConstants.MERGE_CONFLICT_BRANCH_NAME; -import static com.appsmith.external.git.constants.GitSpan.COMMIT; -import static com.appsmith.external.git.constants.GitSpan.STATUS; +import static com.appsmith.external.git.constants.GitSpan.OPS_COMMIT; +import static com.appsmith.external.git.constants.GitSpan.OPS_STATUS; import static com.appsmith.git.constants.AppsmithBotAsset.APPSMITH_BOT_USERNAME; import static com.appsmith.server.constants.ArtifactType.APPLICATION; import static com.appsmith.server.constants.FieldName.DEFAULT; @@ -627,7 +627,7 @@ private Mono commitApplication( childApplication.getGitApplicationMetadata().getIsRepoPrivate(), isSystemGenerated)) .thenReturn(status) - .name(COMMIT) + .name(OPS_COMMIT) .tap(Micrometer.observation(observationRegistry)); }); @@ -1095,7 +1095,7 @@ private Mono pushApplication(String applicationId, boolean doPublish, bo application.getGitApplicationMetadata().getIsRepoPrivate()) .thenReturn(pushStatus); }) - .name(GitSpan.PUSH) + .name(GitSpan.OPS_PUSH) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> pushStatusMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1241,7 +1241,7 @@ public Mono detachRemote(String defaultApplicationId) { .flatMapMany(actionCollectionService::saveAll)) .then(addAnalyticsForGitOperation(AnalyticsEvents.GIT_DISCONNECT, application, false)) .map(responseUtils::updateApplicationWithDefaultResources)) - .name(GitSpan.DETACH_REMOTE) + .name(GitSpan.OPS_DETACH_REMOTE) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> disconnectMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1384,7 +1384,7 @@ public Mono createBranch(String defaultApplicationId, GitBranchDTO application, application.getGitApplicationMetadata().getIsRepoPrivate()))) .map(responseUtils::updateApplicationWithDefaultResources) - .name(GitSpan.CREATE_BRANCH) + .name(GitSpan.OPS_CREATE_BRANCH) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> createBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -1456,7 +1456,7 @@ public Mono checkoutBranch(String defaultApplicationId, String bran return Mono.just(result); }) .tag(GitConstants.GitMetricConstants.CHECKOUT_REMOTE, FALSE.toString()) - .name(GitSpan.CHECKOUT_BRANCH) + .name(GitSpan.OPS_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)) .onErrorResume(throwable -> { return Mono.error(throwable); @@ -1572,7 +1572,7 @@ private Mono checkoutRemoteBranch(String defaultApplicationId, Stri releaseFileLock(defaultApplicationId).then(Mono.just(application1))); }) .tag(GitConstants.GitMetricConstants.CHECKOUT_REMOTE, TRUE.toString()) - .name(GitSpan.CHECKOUT_BRANCH) + .name(GitSpan.OPS_CHECKOUT_BRANCH) .tap(Micrometer.observation(observationRegistry)); return Mono.create( @@ -1663,7 +1663,7 @@ public Mono pullApplication(String defaultApplicationId, String bran .flatMap(gitPullDTO -> releaseFileLock(defaultApplicationId).then(Mono.just(gitPullDTO))); }) - .name(GitSpan.PULL) + .name(GitSpan.OPS_PULL) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> pullMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -2016,7 +2016,7 @@ private Mono getStatus( throwable); return Mono.error(new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, throwable.getMessage())); }) - .name(STATUS) + .name(OPS_STATUS) .tap(Micrometer.observation(observationRegistry)); return Mono.zip(statusMono, sessionUserService.getCurrentUser(), branchedAppMono) @@ -2151,7 +2151,7 @@ public Mono fetchRemoteChanges( AnalyticsEvents.GIT_FETCH.getEventName(), elapsedTime, currentUser, app) .thenReturn(branchTrackingStatus); }) - .name(GitSpan.FETCH_REMOTE) + .name(GitSpan.OPS_FETCH_REMOTE) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> { @@ -2908,7 +2908,7 @@ public Mono deleteBranch(String defaultApplicationId, String branch application, application.getGitApplicationMetadata().getIsRepoPrivate())) .map(responseUtils::updateApplicationWithDefaultResources) - .name(GitSpan.DELETE_BRANCH) + .name(GitSpan.OPS_DELETE_BRANCH) .tap(Micrometer.observation(observationRegistry)); return Mono.create(sink -> deleteBranchMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -2973,7 +2973,7 @@ public Mono discardChanges(String defaultApplicationId, String bran .flatMap(application -> releaseFileLock(defaultApplicationId) .then(this.addAnalyticsForGitOperation(AnalyticsEvents.GIT_DISCARD_CHANGES, application, null))) .map(responseUtils::updateApplicationWithDefaultResources) - .name(GitSpan.DISCARD_CHANGES) + .name(GitSpan.OPS_DISCARD_CHANGES) .tap(Micrometer.observation(observationRegistry)); return Mono.create(