Skip to content

Commit

Permalink
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
Browse files Browse the repository at this point in the history
…o action-redesign/toolbar-flag-lift
  • Loading branch information
albinAppsmith committed Nov 5, 2024
2 parents 5ef38fd + 6dc6194 commit fe6715f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/client/src/entities/DataTree/dataTreeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import type {
DependencyMap,
FormEditorConfigs,
} from "utils/DynamicBindingUtils";
import type { DataTreeSeed } from "ee/entities/DataTree/types";

export class DataTreeFactory {
public static metaWidgets(
metaWidgets: MetaWidgetsReduxState,
Expand Down Expand Up @@ -52,11 +54,10 @@ export class DataTreeFactory {
};
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static widgets(
moduleInputs: Module["inputsForm"],
moduleInstances: Record<string, ModuleInstance> | null,
moduleInstanceEntities: null,
moduleInstanceEntities: DataTreeSeed["moduleInstanceEntities"],
widgets: CanvasWidgetsReduxState,
widgetsMeta: MetaState,
loadingEntities: LoadingEntitiesState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.appsmith.server.configurations;

import com.appsmith.server.annotations.ConditionalOnMicrometerMetricsEnabled;
import io.micrometer.common.KeyValue;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.observation.ObservationFilter;
import io.micrometer.observation.ObservationRegistry;
import io.micrometer.observation.aop.ObservedAspect;
import io.opentelemetry.api.OpenTelemetry;
Expand All @@ -18,6 +20,7 @@
import io.opentelemetry.sdk.resources.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -102,4 +105,18 @@ public OpenTelemetry openTelemetry() {
ObservedAspect observedAspect(ObservationRegistry observationRegistry) {
return new ObservedAspect(observationRegistry);
}

@Bean
public ObservationRegistryCustomizer<ObservationRegistry> observationRegistryCustomizer() {
return registry -> registry.observationConfig().observationFilter(addGlobalTags());
}

private ObservationFilter addGlobalTags() {
return (observation) -> {
observation.addLowCardinalityKeyValue(KeyValue.of(DEPLOYMENT_NAME_KEY, deploymentName));
observation.addLowCardinalityKeyValue(KeyValue.of(SERVICE_NAME_KEY, SERVICE_NAME));
observation.addLowCardinalityKeyValue(KeyValue.of(SERVICE_INSTANCE_ID_KEY, serviceInstanceId));
return observation;
};
}
}
27 changes: 27 additions & 0 deletions deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ let mongoDbUrl;
let mongoDumpFile = null;
const EXPORT_ROOT = "/appsmith-stacks/mongo-data";

// The minimum version of the MongoDB changeset that must be present in the mongockChangeLog collection to run this script.
// This is to ensure we are migrating the data from the stable version of MongoDB.
const MINIMUM_MONGO_CHANGESET = "add_empty_policyMap_for_null_entries";
const MONGO_MIGRATION_COLLECTION = "mongockChangeLog";

for (let i = 2; i < process.argv.length; ++i) {
const arg = process.argv[i];
if (arg.startsWith("--mongodb-url=") && !mongoDbUrl) {
Expand Down Expand Up @@ -77,6 +82,15 @@ if (isBaselineMode) {
const collectionNames = await mongoDb.listCollections({}, { nameOnly: true }).toArray();
const sortedCollectionNames = collectionNames.map(collection => collection.name).sort();

// Verify that the MongoDB data has been migrated to a stable version i.e. v1.43 before we start migrating the data to Postgres.
if (!await isMongoDataMigratedToStableVersion(mongoDb)) {
console.error("MongoDB migration check failed: Try upgrading the Appsmith instance to latest before opting for data migration.");
console.error(`Could not find the valid migration execution entry for "${MINIMUM_MONGO_CHANGESET}" in the "${MONGO_MIGRATION_COLLECTION}" collection.`);
await mongoClient.close();
mongoServer?.kill();
process.exit(1);
}

for await (const collectionName of sortedCollectionNames) {

console.log("Collection:", collectionName);
Expand Down Expand Up @@ -183,3 +197,16 @@ function mapClassToType(_class) {
return null;
}
}

/**
* Method to check if MongoDB data has migrated to a stable version before we start migrating the data to Postgres.
* @param {*} mongoDb - The MongoDB client.
* @returns {Promise<boolean>} - A promise that resolves to true if the data has been migrated to a stable version, false otherwise.
*/
async function isMongoDataMigratedToStableVersion(mongoDb) {
const doc = await mongoDb.collection(MONGO_MIGRATION_COLLECTION).findOne({
changeId: MINIMUM_MONGO_CHANGESET,
state: "EXECUTED",
});
return doc !== null;
}

0 comments on commit fe6715f

Please sign in to comment.