From 814fb3d35019c30307c002be26266e3bc6bc4d48 Mon Sep 17 00:00:00 2001 From: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:42:50 +0530 Subject: [PATCH] chore: removed sentry form server (#40990) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 366aaa8596eefbf4c2a399d54460dacf22a550a5 > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Mon, 23 Jun 2025 06:27:29 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Refactor** - Replaced Sentry-based error reporting with enhanced internal logging for exceptions. - Introduced a new logging utility to improve observability and error context in logs. - **Chores** - Removed Sentry integration and related error reporting code from the application. --- .../server/configurations/InstanceConfig.java | 2 - .../exceptions/GlobalExceptionHandler.java | 2 +- .../exceptions/util/ObservabilityLogger.java | 39 +++++++++++++ .../server/exceptions/util/SentryLogger.java | 55 ------------------- 4 files changed, 40 insertions(+), 58 deletions(-) create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/ObservabilityLogger.java delete mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/SentryLogger.java diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java index 88e18173a8..dd918939ea 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/InstanceConfig.java @@ -5,7 +5,6 @@ import com.appsmith.server.helpers.InstanceConfigHelper; import com.appsmith.server.repositories.CacheableRepositoryHelper; import com.appsmith.server.services.ConfigService; import io.micrometer.observation.annotation.Observed; -import io.sentry.Sentry; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -71,7 +70,6 @@ public class InstanceConfig implements ApplicationListener object before diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/ObservabilityLogger.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/ObservabilityLogger.java new file mode 100644 index 0000000000..fac8e458a9 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/ObservabilityLogger.java @@ -0,0 +1,39 @@ +package com.appsmith.server.exceptions.util; + +import com.appsmith.external.exceptions.AppsmithErrorAction; +import com.appsmith.external.exceptions.BaseException; +import lombok.extern.slf4j.Slf4j; + +import java.io.PrintWriter; +import java.io.StringWriter; + +@Slf4j +public class ObservabilityLogger { + public static void doLog(Throwable error) { + if (error instanceof BaseException baseException && baseException.isHideStackTraceInLogs()) { + log.error(baseException.getClass().getSimpleName() + ": " + baseException.getMessage()); + } else { + log.error("", error); + } + + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter(stringWriter); + error.printStackTrace(printWriter); + String stringStackTrace = stringWriter.toString(); + + // Log stack trace for debugging + log.error("Stack Trace: {}", stringStackTrace); + + if (error instanceof BaseException) { + BaseException baseError = (BaseException) error; + if (baseError.getErrorAction() == AppsmithErrorAction.LOG_EXTERNALLY) { + // Log additional context for external logging + log.error( + "Downstream Error - Message: {}, Code: {}", + baseError.getDownstreamErrorMessage(), + baseError.getDownstreamErrorCode()); + baseError.getContextMap().forEach((key, value) -> log.error("Context - {}: {}", key, value)); + } + } + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/SentryLogger.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/SentryLogger.java deleted file mode 100644 index 9e07c04216..0000000000 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/util/SentryLogger.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.appsmith.server.exceptions.util; - -import com.appsmith.external.constants.MDCConstants; -import com.appsmith.external.exceptions.AppsmithErrorAction; -import com.appsmith.external.exceptions.BaseException; -import io.sentry.Sentry; -import io.sentry.SentryLevel; -import io.sentry.protocol.User; -import lombok.extern.slf4j.Slf4j; - -import java.io.PrintWriter; -import java.io.StringWriter; - -@Slf4j -public class SentryLogger { - public static void doLog(Throwable error) { - if (error instanceof BaseException baseException && baseException.isHideStackTraceInLogs()) { - log.error(baseException.getClass().getSimpleName() + ": " + baseException.getMessage()); - } else { - log.error("", error); - } - - StringWriter stringWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(stringWriter); - error.printStackTrace(printWriter); - String stringStackTrace = stringWriter.toString(); - - Sentry.configureScope(scope -> { - /** - * Send stack trace as a string message. This is a work around till it is figured out why raw - * stack trace is not visible on Sentry dashboard. - * */ - scope.setExtra("Stack Trace", stringStackTrace); - scope.setLevel(SentryLevel.ERROR); - scope.setTag("source", "appsmith-internal-server"); - }); - - if (error instanceof BaseException) { - BaseException baseError = (BaseException) error; - if (baseError.getErrorAction() == AppsmithErrorAction.LOG_EXTERNALLY) { - Sentry.configureScope(scope -> { - baseError.getContextMap().forEach(scope::setTag); - scope.setExtra("downstreamErrorMessage", baseError.getDownstreamErrorMessage()); - scope.setExtra("downstreamErrorCode", baseError.getDownstreamErrorCode()); - }); - final User user = new User(); - user.setEmail(baseError.getContextMap().getOrDefault(MDCConstants.USER_EMAIL, "unknownUser")); - Sentry.setUser(user); - Sentry.captureException(error); - } - } else { - Sentry.captureException(error); - } - } -}