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..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 @@ -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.getEventName()) + .name(GitSpan.FS_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(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(GitSpans.FILE_SYSTEM_CLONE_REPO.getEventName()) + .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(GitSpans.FILE_SYSTEM_CREATE_BRANCH.getEventName()) + .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(GitSpans.FILE_SYSTEM_DELETE_BRANCH.getEventName()) + .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(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH.getEventName()) + .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(GitSpans.FILE_SYSTEM_PULL.getEventName()) + .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(GitSpans.FILE_SYSTEM_STATUS.getEventName()) + .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(GitSpans.FILE_SYSTEM_MERGE.getEventName()) + .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(GitSpans.FILE_SYSTEM_FETCH_REMOTE.getEventName()) + .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(GitSpans.FILE_SYSTEM_CHECKOUT_BRANCH.getEventName()) + .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(GitSpans.FILE_SYSTEM_RESET.getEventName()) + .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(GitSpans.FILE_SYSTEM_RESET.getEventName()) + .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(GitSpans.FILE_SYSTEM_REBASE.getEventName()) + .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(GitSpans.FILE_SYSTEM_BRANCH_TRACK.getEventName()) + .name(GitSpan.FS_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/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 20fe0cb7f31..00000000000 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/GitSpans.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.appsmith.external.git.constants; - -import java.util.Locale; - -import static com.appsmith.external.constants.spans.BaseSpan.APPSMITH_SPAN_PREFIX; -import static com.appsmith.external.constants.spans.BaseSpan.GIT_SPAN_PREFIX; - -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); - } - - public String getEventName() { - return this.eventName; - } -} 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 new file mode 100644 index 00000000000..8fa9e59107f --- /dev/null +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitSpanCE.java @@ -0,0 +1,34 @@ +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 GitSpanCE { + + 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 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-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..80c517301fc --- /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.GitSpanCE; +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 = GitSpanCE.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/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 6c4376869f9..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 @@ -7,7 +7,8 @@ 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.GitConstants; +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; @@ -107,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.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; @@ -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); @@ -625,7 +627,7 @@ private Mono commitApplication( childApplication.getGitApplicationMetadata().getIsRepoPrivate(), isSystemGenerated)) .thenReturn(status) - .name(COMMIT.getEventName()) + .name(OPS_COMMIT) .tap(Micrometer.observation(observationRegistry)); }); @@ -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(GitSpan.OPS_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(GitSpan.OPS_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(GitSpan.OPS_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(GitSpan.OPS_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(GitSpan.OPS_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(GitSpan.OPS_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, @@ -2000,7 +2016,7 @@ private Mono getStatus( throwable); return Mono.error(new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, throwable.getMessage())); }) - .name(STATUS.getEventName()) + .name(OPS_STATUS) .tap(Micrometer.observation(observationRegistry)); return Mono.zip(statusMono, sessionUserService.getCurrentUser(), branchedAppMono) @@ -2134,7 +2150,9 @@ public Mono fetchRemoteChanges( return sendUnitExecutionTimeAnalyticsEvent( AnalyticsEvents.GIT_FETCH.getEventName(), elapsedTime, currentUser, app) .thenReturn(branchTrackingStatus); - }); + }) + .name(GitSpan.OPS_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(GitSpan.OPS_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(GitSpan.OPS_DISCARD_CHANGES) + .tap(Micrometer.observation(observationRegistry)); return Mono.create( sink -> discardChangeMono.subscribe(sink::success, sink::error, null, sink.currentContext())); @@ -3279,14 +3301,14 @@ private Mono addFileLock(String defaultApplicationId) { .onRetryExhaustedThrow((retryBackoffSpec, retrySignal) -> { throw new AppsmithException(AppsmithError.GIT_FILE_IN_USE); })) - .name(GitSpans.ADD_FILE_LOCK.getEventName()) + .name(GitSpan.ADD_FILE_LOCK) .tap(Micrometer.observation(observationRegistry)); } private Mono releaseFileLock(String defaultApplicationId) { return redisUtils .releaseFileLock(defaultApplicationId) - .name(GitSpans.RELEASE_FILE_LOCK.getEventName()) + .name(GitSpan.RELEASE_FILE_LOCK) .tap(Micrometer.observation(observationRegistry)); } @@ -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); }