Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactor Codebase to Remove Telemetry from CE #39421

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/client/packages/rts/src/ce/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import http from "http";
import express from "express";
import type { LogLevelDesc } from "loglevel";
import log from "loglevel";
import { VERSION as buildVersion } from "../version"; // release version of the api

// routes
import ast_routes from "../routes/ast_routes";
import dsl_routes from "../routes/dsl_routes";
import health_check_routes from "../routes/health_check_routes";

import { RTS_BASE_API_PATH } from "@constants/routes";

// Setting the logLevel for all log messages
const logLevel: LogLevelDesc = (process.env.APPSMITH_LOG_LEVEL ||
"debug") as LogLevelDesc;

log.setLevel(logLevel);

const APPSMITH_RTS_PORT = process.env.APPSMITH_RTS_PORT || 8091;

//Disable x-powered-by header to prevent information disclosure
const app = express();

app.disable("x-powered-by");
const server = new http.Server(app);

// parse incoming json requests
app.use(express.json({ limit: "5mb" }));

app.use(`${RTS_BASE_API_PATH}/ast`, ast_routes);
app.use(`${RTS_BASE_API_PATH}/dsl`, dsl_routes);
app.use(`${RTS_BASE_API_PATH}`, health_check_routes);

server.headersTimeout = 61000;
server.keepAliveTimeout = 60000;
// Run the server
server.listen(APPSMITH_RTS_PORT, () => {
log.info(
`RTS version ${buildVersion} running at http://localhost:${APPSMITH_RTS_PORT}`,
);
});

export default server;
1 change: 1 addition & 0 deletions app/client/packages/rts/src/ee/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../ce/server.ts";
54 changes: 0 additions & 54 deletions app/client/packages/rts/src/instrumentation.ts

This file was deleted.

46 changes: 1 addition & 45 deletions app/client/packages/rts/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1 @@
import "./instrumentation";
import http from "http";
import express from "express";
import type { LogLevelDesc } from "loglevel";
import log from "loglevel";
import { VERSION as buildVersion } from "./version"; // release version of the api

// routes
import ast_routes from "./routes/ast_routes";
import dsl_routes from "./routes/dsl_routes";
import health_check_routes from "./routes/health_check_routes";

import { RTS_BASE_API_PATH } from "@constants/routes";

// Setting the logLevel for all log messages
const logLevel: LogLevelDesc = (process.env.APPSMITH_LOG_LEVEL ||
"debug") as LogLevelDesc;

log.setLevel(logLevel);

const APPSMITH_RTS_PORT = process.env.APPSMITH_RTS_PORT || 8091;

//Disable x-powered-by header to prevent information disclosure
const app = express();

app.disable("x-powered-by");
const server = new http.Server(app);

// parse incoming json requests
app.use(express.json({ limit: "5mb" }));

app.use(`${RTS_BASE_API_PATH}/ast`, ast_routes);
app.use(`${RTS_BASE_API_PATH}/dsl`, dsl_routes);
app.use(`${RTS_BASE_API_PATH}`, health_check_routes);

server.headersTimeout = 61000;
server.keepAliveTimeout = 60000;
// Run the server
server.listen(APPSMITH_RTS_PORT, () => {
log.info(
`RTS version ${buildVersion} running at http://localhost:${APPSMITH_RTS_PORT}`,
);
});

export default server;
import "./ee/server.ts";
2 changes: 1 addition & 1 deletion app/client/packages/rts/src/test/server.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import app from "../server";
import app from "../ce/server";
import { RTS_BASE_API_PATH } from "@constants/routes";
import supertest from "supertest";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ private boolean saveActionCollection(Object sourceEntity, String body, String re
Path bodyPath = path.resolve(resourceName + CommonConstants.JS_EXTENSION);
String resourceType = ACTION_COLLECTION_BODY;
span.tag(RESOURCE_TYPE, resourceType);
observationHelper.startSpan(span, true);
observationHelper.startSpan(span);
writeStringToFile(body, bodyPath);
}

Expand All @@ -637,7 +637,7 @@ private boolean saveActionCollection(Object sourceEntity, String body, String re
} catch (IOException e) {
log.debug(e.getMessage());
} finally {
observationHelper.endSpan(span, true);
observationHelper.endSpan(span);
}
return false;
}
Expand All @@ -663,7 +663,7 @@ private boolean saveActions(Object sourceEntity, String body, String resourceNam
Path bodyPath = path.resolve(resourceName + CommonConstants.TEXT_FILE_EXTENSION);
String resourceType = NEW_ACTION_BODY;
span.tag(RESOURCE_TYPE, resourceType);
observationHelper.startSpan(span, true);
observationHelper.startSpan(span);
writeStringToFile(body, bodyPath);
}

Expand All @@ -673,7 +673,7 @@ private boolean saveActions(Object sourceEntity, String body, String resourceNam
} catch (IOException e) {
log.error("Error while reading file {} with message {} with cause", path, e.getMessage(), e.getCause());
} finally {
observationHelper.endSpan(span, true);
observationHelper.endSpan(span);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public void saveWidgets(JSONObject sourceEntity, String resourceName, Path path)
Files.createDirectories(path);
String resourceType = WIDGETS;
span.tag(RESOURCE_TYPE, resourceType);
observationHelper.startSpan(span, true);
observationHelper.startSpan(span);

writeToFile(
objectReader.readTree(sourceEntity.toString()),
path.resolve(resourceName + CommonConstants.JSON_EXTENSION));
} catch (IOException e) {
log.debug("Error while writings widgets data to file, {}", e.getMessage());
} finally {
observationHelper.endSpan(span, true);
observationHelper.endSpan(span);
}
}

Expand All @@ -103,13 +103,13 @@ public boolean writeToFile(Object sourceEntity, Path path) throws IOException {
resourceType = METADATA;
}
span.tag(RESOURCE_TYPE, resourceType);
observationHelper.startSpan(span, true);
observationHelper.startSpan(span);

try (BufferedWriter fileWriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
objectWriter.writeValue(fileWriter, sourceEntity);
return true;
} finally {
observationHelper.endSpan(span, true);
observationHelper.endSpan(span);
}
}

Expand All @@ -122,7 +122,7 @@ public boolean writeToFile(Object sourceEntity, Path path) throws IOException {
@Override
public Object readFile(Path filePath) {
Span span = observationHelper.createSpan(GitSpan.FILE_READ);
observationHelper.startSpan(span, true);
observationHelper.startSpan(span);

Object file;
try (FileReader reader = new FileReader(filePath.toFile())) {
Expand All @@ -131,7 +131,7 @@ public Object readFile(Path filePath) {
log.error("Error while reading file {} with message {} with cause", filePath, e.getMessage(), e.getCause());
return null;
} finally {
observationHelper.endSpan(span, true);
observationHelper.endSpan(span);
}
return file;
}
Expand Down Expand Up @@ -289,14 +289,14 @@ public void deleteFile(Path filePath) {
@Override
public String readFileAsString(Path filePath) {
Span span = observationHelper.createSpan(GitSpan.FILE_READ);
observationHelper.startSpan(span, true);
observationHelper.startSpan(span);
String data = CommonConstants.EMPTY_STRING;
try {
data = FileUtils.readFileToString(filePath.toFile(), "UTF-8");
} catch (IOException e) {
log.error("Error while reading the file from git repo {} ", e.getMessage());
} finally {
observationHelper.endSpan(span, true);
observationHelper.endSpan(span);
}
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public interface ObservationHelper {

Span createSpan(String name);

default Span startSpan(Span span, boolean isDetail) {
default Span startSpan(Span span) {
return span;
}

default void endSpan(Span span, boolean isDetail) {}
default void endSpan(Span span) {}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ public class CommonConfig {
@Value("${disable.telemetry:true}")
private boolean isTelemetryDisabled;

@Value("${appsmith.observability.tracing.detail.enabled:false}")
private boolean tracingDetail;

@Value("${appsmith.observability.metrics.detail.enabled:false}")
private boolean metricsDetail;

@Value("${appsmith.observability.metrics.interval.millis:60000}")
private int metricsIntervalMillis;

private List<String> allowedDomains;

private String mongoDBVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class ReactorNettyConfiguration implements WebServerFactoryCustomizer<Net

@Override
public void customize(NettyReactiveWebServerFactory factory) {
if (commonConfig.isMetricsDetail()) {
factory.addServerCustomizers(httpServer -> httpServer.metrics(true, Function.identity()));
}
factory.addServerCustomizers(httpServer -> httpServer.metrics(true, Function.identity()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@ public Span createSpan(String name) {
}

@Override
public Span startSpan(Span span, boolean isDetail) {
if (!isDetail || commonConfig.isTracingDetail()) {
return span.start();
} else {
return span;
}
public Span startSpan(Span span) {
return span.start();
}

@Override
public void endSpan(Span span, boolean isDetail) {
if (!isDetail || commonConfig.isTracingDetail()) {
span.end();
}
public void endSpan(Span span) {
span.end();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private Mono<LayoutDTO> updateLayoutDsl(
Span extractAllWidgetNamesAndDynamicBindingsFromDSLSpan =
observationHelper.createSpan(EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL);

observationHelper.startSpan(extractAllWidgetNamesAndDynamicBindingsFromDSLSpan, true);
observationHelper.startSpan(extractAllWidgetNamesAndDynamicBindingsFromDSLSpan);

try {
dsl = extractAllWidgetNamesAndDynamicBindingsFromDSL(
Expand All @@ -146,7 +146,7 @@ private Mono<LayoutDTO> updateLayoutDsl(
.then(Mono.error(t));
}

observationHelper.endSpan(extractAllWidgetNamesAndDynamicBindingsFromDSLSpan, true);
observationHelper.endSpan(extractAllWidgetNamesAndDynamicBindingsFromDSLSpan);

layout.setWidgetNames(widgetNames);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,15 @@ public Mono<List<Set<DslExecutableDTO>>> findAllOnLoadExecutables(
Span computeOnPageLoadExecutablesSchedulingOrderSpan =
observationHelper.createSpan(COMPUTE_ON_PAGE_LOAD_EXECUTABLES_SCHEDULING_ORDER);

observationHelper.startSpan(computeOnPageLoadExecutablesSchedulingOrderSpan, true);
observationHelper.startSpan(computeOnPageLoadExecutablesSchedulingOrderSpan);

List<Set<String>> executablesList = computeOnPageLoadExecutablesSchedulingOrder(
graph,
onLoadExecutableSetRef,
executableNameToExecutableMap,
explicitUserSetOnLoadExecutablesRef);

observationHelper.endSpan(computeOnPageLoadExecutablesSchedulingOrderSpan, true);
observationHelper.endSpan(computeOnPageLoadExecutablesSchedulingOrderSpan);

return executablesList;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ private boolean isPossibleToCreateQueryWithoutDatasource(Plugin plugin) {
log.error("Error while computing etag for ConsolidatedAPIResponseDTO", e);
return "";
} finally {
observationHelper.endSpan(computeEtagSpan, true);
observationHelper.endSpan(computeEtagSpan);
}
}
}
Loading
Loading