mirror of
https://github.com/makeplane/plane.git
synced 2025-12-29 00:24:56 +01:00
fix: remove sentry from enterprise files
This commit is contained in:
@@ -4,7 +4,6 @@ from django.db import IntegrityError
|
||||
# Third party imports
|
||||
from rest_framework import status
|
||||
from rest_framework.response import Response
|
||||
from sentry_sdk import capture_exception
|
||||
|
||||
# Module imports
|
||||
from plane.app.views import BaseViewSet
|
||||
@@ -73,7 +72,6 @@ class SlackProjectSyncViewSet(BaseViewSet):
|
||||
{"error": "Slack is already installed for the project"},
|
||||
status=status.HTTP_410_GONE,
|
||||
)
|
||||
capture_exception(e)
|
||||
return Response(
|
||||
{"error": "Slack could not be installed. Please try again later"},
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
|
||||
@@ -7,7 +7,6 @@ from django.contrib.auth.hashers import make_password
|
||||
|
||||
# Third Party imports
|
||||
from celery import shared_task
|
||||
from sentry_sdk import capture_exception
|
||||
|
||||
# Module imports
|
||||
from plane.db.models import (
|
||||
@@ -191,5 +190,4 @@ def service_importer(service, importer_id):
|
||||
# Print logs if in DEBUG mode
|
||||
if settings.DEBUG:
|
||||
print(e)
|
||||
capture_exception(e)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,6 @@ from django.conf import settings
|
||||
|
||||
# Third party imports
|
||||
from celery import shared_task
|
||||
from sentry_sdk import capture_exception
|
||||
from slack_sdk import WebClient
|
||||
from slack_sdk.errors import SlackApiError
|
||||
|
||||
@@ -29,5 +28,4 @@ def send_welcome_slack(user_id, created, message):
|
||||
# Print logs if in DEBUG mode
|
||||
if settings.DEBUG:
|
||||
print(e)
|
||||
capture_exception(e)
|
||||
return
|
||||
|
||||
@@ -14,7 +14,6 @@ from django.utils import timezone
|
||||
from django.conf import settings
|
||||
|
||||
# Third party imports
|
||||
from sentry_sdk import capture_exception
|
||||
from slack_sdk import WebClient
|
||||
from slack_sdk.errors import SlackApiError
|
||||
|
||||
@@ -277,6 +276,5 @@ def send_welcome_slack(sender, instance, created, **kwargs):
|
||||
except SlackApiError as e:
|
||||
print(f"Got an error: {e.response['error']}")
|
||||
return
|
||||
except Exception as e:
|
||||
capture_exception(e)
|
||||
except Exception:
|
||||
return
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import requests
|
||||
import re
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from sentry_sdk import capture_exception
|
||||
from urllib.parse import urlparse, urljoin
|
||||
|
||||
|
||||
@@ -104,6 +103,5 @@ def jira_project_issue_summary(email, api_token, project_key, hostname):
|
||||
]
|
||||
),
|
||||
}
|
||||
except Exception as e:
|
||||
capture_exception(e)
|
||||
except Exception:
|
||||
return {"error": "Something went wrong could not fetch information from jira"}
|
||||
|
||||
@@ -69,7 +69,6 @@ x-silo-env: &silo-env
|
||||
PORT: 3000
|
||||
BATCH_SIZE: ${BATCH_SIZE:-60}
|
||||
DEDUP_INTERVAL: ${DEDUP_INTERVAL:-3}
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
PG_SCHEMA: ${PG_SCHEMA:-silo}
|
||||
APP_BASE_URL: ${SERVICE_URL_PLANE}
|
||||
SILO_API_BASE_URL: ${SERVICE_URL_PLANE}
|
||||
@@ -103,8 +102,6 @@ x-silo-env: &silo-env
|
||||
x-app-env: &app-env
|
||||
WEB_URL: ${SERVICE_URL_PLANE}
|
||||
DEBUG: ${DEBUG:-0}
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
SENTRY_ENVIRONMENT: ${SENTRY_ENVIRONMENT:-production}
|
||||
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
|
||||
API_BASE_URL: http://api:8000
|
||||
# Gunicorn Workers
|
||||
|
||||
@@ -72,9 +72,6 @@ x-silo-env: &silo-env
|
||||
WEBHOOK_SECRET: ${WEBHOOK_SECRET:-plane-silo}
|
||||
MQ_PREFETCH_COUNT: ${MQ_PREFETCH_COUNT:-10}
|
||||
|
||||
# Silo Sentry Envs
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
|
||||
# Authentication
|
||||
SILO_HMAC_SECRET_KEY: ${SILO_HMAC_SECRET_KEY:-tnbbvj6ATPvze4zaygdujxg4dpk4hqx0WDW}
|
||||
|
||||
@@ -99,8 +96,6 @@ x-silo-env: &silo-env
|
||||
x-app-env: &app-env
|
||||
WEB_URL: ${WEB_URL:-http://localhost}
|
||||
DEBUG: ${DEBUG:-0}
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
SENTRY_ENVIRONMENT: ${SENTRY_ENVIRONMENT:-production}
|
||||
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
|
||||
API_BASE_URL: ${API_BASE_URL:-http://api:8000}
|
||||
# Gunicorn Workers
|
||||
|
||||
@@ -72,9 +72,6 @@ x-silo-env: &silo-env
|
||||
WEBHOOK_SECRET: ${WEBHOOK_SECRET:-plane-silo}
|
||||
MQ_PREFETCH_COUNT: ${MQ_PREFETCH_COUNT:-10}
|
||||
|
||||
# Silo Sentry Envs
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
|
||||
# Authentication
|
||||
SILO_HMAC_SECRET_KEY: ${SILO_HMAC_SECRET_KEY:-tnbbvj6ATPvze4zaygdujxg4dpk4hqx0WDW}
|
||||
|
||||
@@ -99,8 +96,6 @@ x-silo-env: &silo-env
|
||||
x-app-env: &app-env
|
||||
WEB_URL: ${WEB_URL:-http://localhost}
|
||||
DEBUG: ${DEBUG:-0}
|
||||
SENTRY_DSN: ${SENTRY_DSN}
|
||||
SENTRY_ENVIRONMENT: ${SENTRY_ENVIRONMENT:-production}
|
||||
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS}
|
||||
API_BASE_URL: ${API_BASE_URL:-http://api:8000}
|
||||
# Gunicorn Workers
|
||||
|
||||
@@ -31,8 +31,6 @@ MACHINE_SIGNATURE=
|
||||
|
||||
WEB_URL=http://localhost
|
||||
DEBUG=0
|
||||
SENTRY_DSN=
|
||||
SENTRY_ENVIRONMENT=production
|
||||
CORS_ALLOWED_ORIGINS=http://localhost
|
||||
API_BASE_URL=http://api:8000
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ x-silo-env: &silo-env
|
||||
- DB_URL=${DB_URL:-postgresql://plane:plane@plane-db/silo}
|
||||
- AMQP_URL=${AMQP_URL:-amqp://guest:guest@plane-mq:5672/}
|
||||
- REDIS_URL=${REDIS_URL:-redis://plane-redis:6379/}
|
||||
- SENTRY_DSN=${SENTRY_DSN:-" "}
|
||||
- JIRA_CLIENT_ID=${JIRA_CLIENT_ID:-""}
|
||||
- JIRA_CLIENT_SECRET=${JIRA_CLIENT_SECRET:-""}
|
||||
- LINEAR_CLIENT_ID=${LINEAR_CLIENT_ID:-""}
|
||||
@@ -77,7 +76,7 @@ services:
|
||||
npm --prefix ./silo run db:migrate
|
||||
node silo/start.js
|
||||
"
|
||||
depends_on:
|
||||
depends_on:
|
||||
plane-mq:
|
||||
condition: service_healthy
|
||||
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
"@linear/sdk": "^30.0.0",
|
||||
"@octokit/openapi-webhooks-types": "^8.3.0",
|
||||
"@plane/sdk": "*",
|
||||
"@sentry/cli": "^2.40.0",
|
||||
"@sentry/node": "^8.27.0",
|
||||
"@sentry/profiling-node": "^8.27.0",
|
||||
"@types/cookie-parser": "^1.4.8",
|
||||
"@types/jest": "^29.5.14",
|
||||
"amqplib": "^0.10.4",
|
||||
|
||||
@@ -13,7 +13,6 @@ import { env } from "@/env";
|
||||
import { CONSTANTS } from "@/helpers/constants";
|
||||
import { getReferredIssues, IssueReference, IssueWithReference } from "@/helpers/parser";
|
||||
import { logger } from "@/logger";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { getAPIClient } from "@/services/client";
|
||||
import { verifyEntityConnection } from "@/types";
|
||||
|
||||
@@ -198,7 +197,6 @@ const updateIssue = async (
|
||||
prNumber: number,
|
||||
prUrl: string
|
||||
): Promise<IssueWithReference | null> => {
|
||||
|
||||
let issue: ExIssue | null = null;
|
||||
|
||||
try {
|
||||
@@ -222,7 +220,9 @@ const updateIssue = async (
|
||||
return { reference, issue };
|
||||
} catch (error: any) {
|
||||
if (error?.detail && error?.detail.includes(CONSTANTS.NO_PERMISSION_ERROR)) {
|
||||
logger.info(`[GITHUB] No permission to process event: ${error.detail} ${reference.identifier}-${reference.sequence}`);
|
||||
logger.info(
|
||||
`[GITHUB] No permission to process event: ${error.detail} ${reference.identifier}-${reference.sequence}`
|
||||
);
|
||||
|
||||
if (issue) {
|
||||
return { reference, issue };
|
||||
@@ -232,7 +232,6 @@ const updateIssue = async (
|
||||
}
|
||||
|
||||
logger.error(`[GITHUB] Error updating issue ${reference.identifier}-${reference.sequence}: ${error}`);
|
||||
SentryInstance?.captureException(error);
|
||||
|
||||
if (issue) {
|
||||
return { reference, issue };
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { GithubWebhookPayload } from "@plane/etl/github";
|
||||
import { CONSTANTS } from "@/helpers/constants";
|
||||
import { logger } from "@/logger";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { MQ, Store } from "@/worker/base";
|
||||
import { handleInstallationEvents } from "./event-handlers/installation.handler";
|
||||
@@ -37,14 +36,11 @@ export class GithubWebhookWorker extends TaskHandler {
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
|
||||
// Silently skip events where we don't have permission to process
|
||||
if (error?.detail && error?.detail.includes(CONSTANTS.NO_PERMISSION_ERROR)) {
|
||||
logger.info(`[GITHUB] No permission to process event: ${error.detail} ${data}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
SentryInstance.captureException(error);
|
||||
} finally {
|
||||
logger.info("[GITHUB] Event Processed Successfully");
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { PlaneWebhookPayload } from "@plane/sdk";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { MQ, Store } from "@/worker/base";
|
||||
import { handleIssueCommentWebhook } from "./event-handlers/issue-comment.handler";
|
||||
@@ -15,7 +14,6 @@ export class PlaneGithubWebhookWorker extends TaskHandler {
|
||||
this.store = store;
|
||||
}
|
||||
async handleTask(headers: TaskHeaders, data: PlaneWebhookPayload): Promise<boolean> {
|
||||
|
||||
try {
|
||||
switch (data.event) {
|
||||
case "issue":
|
||||
@@ -28,10 +26,9 @@ export class PlaneGithubWebhookWorker extends TaskHandler {
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
SentryInstance.captureException(error);
|
||||
console.error(`[GITHUB] Error processing plane webhook: ${error}`);
|
||||
} finally {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { logger } from "@/logger";
|
||||
import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { GitlabMergeRequestEvent, GitlabWebhookEvent } from "@plane/etl/gitlab";
|
||||
import { handleMergeRequest } from "./handlers/merge-request.handler";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
|
||||
export class GitlabWebhookWorker extends TaskHandler {
|
||||
mq: MQ;
|
||||
@@ -24,7 +23,7 @@ export class GitlabWebhookWorker extends TaskHandler {
|
||||
await handleMergeRequest(data as GitlabMergeRequestEvent);
|
||||
}
|
||||
} catch (error) {
|
||||
SentryInstance.captureException(error);
|
||||
console.error(`[GITLAB] Error processing gitlab webhook: ${error}`);
|
||||
} finally {
|
||||
logger.info("[GITLAB] Event Processed Successfully");
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,6 @@ import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { PlaneWebhookData, WebhookIssueCommentPayload } from "@plane/sdk";
|
||||
import { handleIssueCommentWebhook } from "./plane-webhook-handlers/handle-comment-webhook";
|
||||
import { logger } from "@/logger";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
|
||||
export class PlaneSlackWebhookWorker extends TaskHandler {
|
||||
mq: MQ;
|
||||
@@ -24,12 +23,10 @@ export class PlaneSlackWebhookWorker extends TaskHandler {
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
SentryInstance.captureException(error);
|
||||
logger.error(error);
|
||||
} finally {
|
||||
logger.info("[SLACK] Event Processed Successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { TSlackPayload } from "@plane/etl/slack";
|
||||
import { logger } from "@/logger";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { MQ, Store } from "@/worker/base";
|
||||
import { handleBlockActions } from "./handlers/block-actions";
|
||||
@@ -45,8 +44,7 @@ export class SlackInteractionHandler extends TaskHandler {
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
SentryInstance.captureException(error);
|
||||
logger.error(error);
|
||||
logger.error(`[SLACK] Error processing slack webhook: ${error}`);
|
||||
} finally {
|
||||
logger.info("[SLACK] Event Processed Successfully");
|
||||
return true;
|
||||
|
||||
@@ -13,10 +13,6 @@ const envSchema = z.object({
|
||||
AMQP_URL: z.string().default("amqp://guest:guest@localhost:5672"),
|
||||
CORS_ALLOWED_ORIGINS: z.string().default("https://app.plane.so"),
|
||||
REDIS_URL: z.string().default("redis://localhost:6379"),
|
||||
SENTRY_DSN: z.string().optional(),
|
||||
SENTRY_ORG: z.string().default("plane-hq"),
|
||||
SENTRY_PROJECT: z.string().default("plane-silo"),
|
||||
SENTRY_RELEASE_VERSION: z.string().default("1.0.0"),
|
||||
PG_SCHEMA: z.string().optional(),
|
||||
APP_BASE_URL: z
|
||||
.string()
|
||||
|
||||
@@ -3,7 +3,6 @@ import { TImportJob } from "@plane/types";
|
||||
import { wait } from "@/helpers/delay";
|
||||
import { updateJobWithReport } from "@/helpers/job";
|
||||
import { logger } from "@/logger";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { getAPIClient } from "@/services/client";
|
||||
import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { MQ, Store } from "@/worker/base";
|
||||
@@ -157,7 +156,7 @@ export abstract class BaseDataMigrator<TJobConfig, TSourceEntity> implements Tas
|
||||
await batchLock.releaseLock();
|
||||
// Inditate that the task has been errored, don't need to requeue, the task
|
||||
// will be requeued manually
|
||||
SentryInstance.captureException(error);
|
||||
console.error(`[ETL] Error processing etl job: ${error}`);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -168,7 +167,7 @@ export abstract class BaseDataMigrator<TJobConfig, TSourceEntity> implements Tas
|
||||
|
||||
// Inditate that the task has been errored, don't need to requeue, the task
|
||||
// will be requeued manually
|
||||
SentryInstance.captureException(error);
|
||||
console.error(`[ETL] Error processing etl job: ${error}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +1,89 @@
|
||||
import { SentryInstance } from '@/sentry-config'
|
||||
import { Response } from 'express'
|
||||
import { Response } from "express";
|
||||
|
||||
const { APP_ENV } = process.env
|
||||
const { APP_ENV } = process.env;
|
||||
|
||||
export const responseHandler = (
|
||||
res: Response,
|
||||
status: number,
|
||||
data: any = {},
|
||||
extras: any = undefined
|
||||
) => {
|
||||
switch (status) {
|
||||
case 200: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Successful',
|
||||
data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 201: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Created',
|
||||
data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 400: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Bad Request',
|
||||
errors: data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 401: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Unauthorized',
|
||||
errors: data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 403: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Permission Denied',
|
||||
errors: data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 404: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Not Found',
|
||||
errors: data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 409: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Conflict Occurred',
|
||||
errors: data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 429: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'You have exceeded the request limit. Try After 1 hr',
|
||||
errors: data,
|
||||
extras
|
||||
})
|
||||
}
|
||||
case 500: {
|
||||
// TODO: sentry push
|
||||
SentryInstance?.captureException(data)
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: 'Internal Server Error',
|
||||
errors: APP_ENV !== 'production' ? data : {},
|
||||
extras
|
||||
})
|
||||
}
|
||||
default: {
|
||||
SentryInstance?.captureException(data)
|
||||
return res.status(status).json({
|
||||
status: 500,
|
||||
message: 'Default Internal Server Error',
|
||||
extras
|
||||
})
|
||||
}
|
||||
export const responseHandler = (res: Response, status: number, data: any = {}, extras: any = undefined) => {
|
||||
switch (status) {
|
||||
case 200: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Successful",
|
||||
data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
}
|
||||
case 201: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Created",
|
||||
data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 400: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Bad Request",
|
||||
errors: data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 401: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Unauthorized",
|
||||
errors: data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 403: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Permission Denied",
|
||||
errors: data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 404: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Not Found",
|
||||
errors: data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 409: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Conflict Occurred",
|
||||
errors: data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 429: {
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "You have exceeded the request limit. Try After 1 hr",
|
||||
errors: data,
|
||||
extras,
|
||||
});
|
||||
}
|
||||
case 500: {
|
||||
console.error(`[SILo] Error processing response: ${data}`);
|
||||
return res.status(status).json({
|
||||
status,
|
||||
message: "Internal Server Error",
|
||||
errors: APP_ENV !== "production" ? data : {},
|
||||
extras,
|
||||
});
|
||||
}
|
||||
default: {
|
||||
console.error(`[SILo] Error processing response: ${data}`);
|
||||
return res.status(status).json({
|
||||
status: 500,
|
||||
message: "Default Internal Server Error",
|
||||
extras,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
// instrument.js
|
||||
import * as Sentry from "@sentry/node";
|
||||
import { nodeProfilingIntegration } from "@sentry/profiling-node";
|
||||
import { env } from "./env";
|
||||
import { logger } from "./logger";
|
||||
import { StartSpanOptions } from "@sentry/core";
|
||||
|
||||
|
||||
export const initializeSentry = () => {
|
||||
if (!env.SENTRY_DSN) {
|
||||
logger.warn("Sentry DSN not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info(`Initializing Sentry | Version:${env.SENTRY_RELEASE_VERSION}`);
|
||||
Sentry.init({
|
||||
dsn: env.SENTRY_DSN,
|
||||
integrations: [
|
||||
Sentry.httpIntegration(),
|
||||
Sentry.expressIntegration(),
|
||||
nodeProfilingIntegration()
|
||||
],
|
||||
tracesSampleRate: 1.0,
|
||||
profilesSampleRate: 1.0,
|
||||
environment: env.NODE_ENV,
|
||||
release: env.SENTRY_RELEASE_VERSION,
|
||||
});
|
||||
};
|
||||
|
||||
export const startSpan = (spanOptions: StartSpanOptions, callback: ((span: Sentry.Span) => unknown) | ((arg0: unknown) => any)) => {
|
||||
const transaction = Sentry.startSpan(spanOptions, callback);
|
||||
try {
|
||||
const result = callback(transaction);
|
||||
transaction.finish(); // Ensure the span is completed
|
||||
return result;
|
||||
} catch (err) {
|
||||
Sentry.captureException(err);
|
||||
transaction.finish();
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
export const captureException = (err: unknown) => {
|
||||
Sentry.captureException(err);
|
||||
};
|
||||
|
||||
export const SentryInstance = Sentry;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// sentry
|
||||
import cookieParser from "cookie-parser";
|
||||
import cors from "cors";
|
||||
import * as dotenv from "dotenv";
|
||||
@@ -33,7 +32,6 @@ import { env } from "./env";
|
||||
import { APIError } from "./lib";
|
||||
import { registerControllers } from "./lib/controller";
|
||||
import { expressLogger, logger } from "./logger";
|
||||
import { initializeSentry, SentryInstance } from "./sentry-config";
|
||||
// types
|
||||
import { APIErrorResponse } from "./types";
|
||||
|
||||
@@ -69,7 +67,6 @@ export default class Server {
|
||||
this.app = express();
|
||||
this.port = Number(env.PORT);
|
||||
|
||||
this.setupSentry();
|
||||
this.setupMiddleware();
|
||||
this.setupControllers();
|
||||
this.setupErrorHandlers();
|
||||
@@ -92,7 +89,7 @@ export default class Server {
|
||||
);
|
||||
}
|
||||
|
||||
this.app.use(express.json({ limit: '25mb' }));
|
||||
this.app.use(express.json({ limit: "25mb" }));
|
||||
this.app.use(cookieParser());
|
||||
this.app.use(express.urlencoded({ extended: true }));
|
||||
this.app.use(this.setupLogger());
|
||||
@@ -119,10 +116,6 @@ export default class Server {
|
||||
this.app.use(env.SILO_BASE_PATH || "/", router);
|
||||
}
|
||||
|
||||
private setupSentry(): void {
|
||||
initializeSentry();
|
||||
}
|
||||
|
||||
private setupErrorHandlers(): void {
|
||||
// Global error handling middleware
|
||||
this.app.use(this.handleError.bind(this));
|
||||
@@ -142,10 +135,6 @@ export default class Server {
|
||||
|
||||
logger.error("Global error handler caught:", logError);
|
||||
|
||||
if (SentryInstance) {
|
||||
SentryInstance.captureException(err);
|
||||
}
|
||||
|
||||
const response: APIErrorResponse = {
|
||||
error: env.NODE_ENV === "production" ? "Internal Server Error" : err.message,
|
||||
status: err instanceof APIError ? err.statusCode : 500,
|
||||
@@ -166,16 +155,10 @@ export default class Server {
|
||||
private setupProcessHandlers(): void {
|
||||
process.on("unhandledRejection", (reason) => {
|
||||
logger.error("Unhandled Rejection at:", reason);
|
||||
if (SentryInstance) {
|
||||
SentryInstance.captureException(reason);
|
||||
}
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (err) => {
|
||||
logger.error("Uncaught Exception thrown:", err);
|
||||
if (SentryInstance) {
|
||||
SentryInstance.captureException(err);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import amqp from "amqplib";
|
||||
import { env } from "@/env";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { TMQEntityOptions } from "./types";
|
||||
|
||||
export class MQActorBase {
|
||||
@@ -67,7 +66,7 @@ export class MQActorBase {
|
||||
return true;
|
||||
} catch {
|
||||
if (attemptCount % 10 === 0) {
|
||||
SentryInstance.captureException(new Error(`RabbitMQ reconnection attempt ${attemptCount} failed`));
|
||||
console.error(`[MQ] RabbitMQ reconnection attempt ${attemptCount} failed`);
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, this.RECONNECT_INTERVAL));
|
||||
console.log(`Attempting to reconnect to RabbitMQ [${attemptCount}]...`);
|
||||
@@ -94,7 +93,7 @@ export class MQActorBase {
|
||||
return;
|
||||
} catch {
|
||||
if (attemptCount % 10 === 0) {
|
||||
SentryInstance.captureException(new Error(`RabbitMQ initial connection attempt ${attemptCount} failed`));
|
||||
console.error(`[MQ] RabbitMQ initial connection attempt ${attemptCount} failed`);
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, this.RECONNECT_INTERVAL));
|
||||
console.log(`Attempting to reconnect to RabbitMQ [${attemptCount}]...`);
|
||||
|
||||
@@ -16,7 +16,6 @@ import { LinearDataMigrator } from "@/apps/linear-importer/migrator/linear.migra
|
||||
import { PlaneSlackWebhookWorker } from "@/apps/slack/worker/plane-worker";
|
||||
import { SlackInteractionHandler } from "@/apps/slack/worker/worker";
|
||||
import { logger } from "@/logger";
|
||||
import { SentryInstance } from "@/sentry-config";
|
||||
import { TaskHandler, TaskHeaders } from "@/types";
|
||||
import { MQ, Store } from "./base";
|
||||
import { Lock } from "./base/lock";
|
||||
@@ -82,14 +81,14 @@ interface JobWorkerConfig {
|
||||
*/
|
||||
type TaskProps =
|
||||
| {
|
||||
type: "mq";
|
||||
headers: TaskHeaders;
|
||||
data: any;
|
||||
}
|
||||
type: "mq";
|
||||
headers: TaskHeaders;
|
||||
data: any;
|
||||
}
|
||||
| {
|
||||
type: "store";
|
||||
event: string;
|
||||
};
|
||||
type: "store";
|
||||
event: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Main task management class that handles worker lifecycle and task distribution
|
||||
@@ -269,7 +268,6 @@ export class TaskManager {
|
||||
msg.properties.headers.retry_count = retryCount;
|
||||
} else {
|
||||
logger.error(`Max retry attempts reached for message: ${msg.content.toString()}`);
|
||||
SentryInstance.captureException(error);
|
||||
await this.mq.ackMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -289,7 +287,6 @@ export class TaskManager {
|
||||
this.workers.set(jobType, WorkerFactory.createWorker(workerType, this.mq!, this.store!));
|
||||
}
|
||||
} catch (error) {
|
||||
SentryInstance.captureException(error);
|
||||
logger.error(`Something went wrong while initiating job worker 🧨, ${error}`);
|
||||
}
|
||||
};
|
||||
@@ -319,15 +316,9 @@ export class TaskManager {
|
||||
public registerStoreTask = async (headers: TaskHeaders, data: any, ttl?: number) => {
|
||||
if (!this.store) return;
|
||||
try {
|
||||
|
||||
const key = `silo:${headers.route}:${headers.type}:${headers.jobId}:${JSON.stringify(data)}`;
|
||||
|
||||
await this.store.set(
|
||||
key,
|
||||
"1",
|
||||
ttl,
|
||||
false
|
||||
);
|
||||
await this.store.set(key, "1", ttl, false);
|
||||
} catch (error) {
|
||||
logger.error("Error pushing to job worker queue:", error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user