Skip to content

Commit

Permalink
name refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sondermanish committed Apr 9, 2024
1 parent 5384103 commit 98c9607
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,7 +139,7 @@ public Mono<String> commitArtifact(
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_COMMIT)
.name(GitSpan.FILE_SYSTEM_COMMIT)
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public Mono<String> pushApplication(
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_PUSH)
.name(GitSpan.FILE_SYSTEM_PUSH)
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
Expand Down Expand Up @@ -285,7 +285,7 @@ public Mono<String> 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);
}
Expand Down Expand Up @@ -315,7 +315,7 @@ public Mono<String> 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);
}
Expand Down Expand Up @@ -345,7 +345,7 @@ public Mono<Boolean> 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);
}
Expand Down Expand Up @@ -381,7 +381,7 @@ public Mono<Boolean> 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);
}
Expand Down Expand Up @@ -443,7 +443,7 @@ public Mono<MergeStatusDTO> pullApplication(
}
})
.timeout(Duration.ofMillis(Constraint.TIMEOUT_MILLIS))
.name(GitSpans.FILE_SYSTEM_PULL)
.name(GitSpan.FILE_SYSTEM_PULL)
.tap(Micrometer.observation(observationRegistry))
.subscribeOn(scheduler);
}
Expand Down Expand Up @@ -560,7 +560,7 @@ public Mono<GitStatusDTO> 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);
}
Expand Down Expand Up @@ -682,7 +682,7 @@ public Mono<String> 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);
}
Expand Down Expand Up @@ -727,7 +727,7 @@ public Mono<String> 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);
}
Expand Down Expand Up @@ -838,7 +838,7 @@ public Mono<String> 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);
}
Expand Down Expand Up @@ -873,7 +873,7 @@ private Mono<Ref> 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);
}
Expand Down Expand Up @@ -909,7 +909,7 @@ public Mono<Boolean> 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);
}
Expand Down Expand Up @@ -940,7 +940,7 @@ public Mono<Boolean> 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);
}
Expand All @@ -953,7 +953,7 @@ public Mono<BranchTrackingStatus> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.appsmith.external.git.constants;

import com.appsmith.external.git.constants.ce.GitSpanCE;

public class GitSpan extends GitSpanCE {}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1095,7 +1095,7 @@ private Mono<String> 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()));
Expand Down Expand Up @@ -1241,7 +1241,7 @@ public Mono<Application> 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()));
Expand Down Expand Up @@ -1384,7 +1384,7 @@ public Mono<Application> 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()));
Expand Down Expand Up @@ -1456,7 +1456,7 @@ public Mono<Application> 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);
Expand Down Expand Up @@ -1572,7 +1572,7 @@ private Mono<Application> 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(
Expand Down Expand Up @@ -1663,7 +1663,7 @@ public Mono<GitPullDTO> 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()));
Expand Down Expand Up @@ -2151,7 +2151,7 @@ public Mono<BranchTrackingStatus> 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 -> {
Expand Down Expand Up @@ -2908,7 +2908,7 @@ public Mono<Application> 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()));
Expand Down Expand Up @@ -2973,7 +2973,7 @@ public Mono<Application> 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(
Expand Down Expand Up @@ -3301,14 +3301,14 @@ private Mono<Boolean> 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<Boolean> releaseFileLock(String defaultApplicationId) {
return redisUtils
.releaseFileLock(defaultApplicationId)
.name(GitSpans.RELEASE_FILE_LOCK)
.name(GitSpan.RELEASE_FILE_LOCK)
.tap(Micrometer.observation(observationRegistry));
}

Expand Down

0 comments on commit 98c9607

Please sign in to comment.