Skip to content

Commit 45aadf3

Browse files
Sentry stuff?
1 parent 28787e0 commit 45aadf3

File tree

4 files changed

+125
-76
lines changed

4 files changed

+125
-76
lines changed

package-lock.json

Lines changed: 110 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
},
5050
"dependencies": {
5151
"@aws-sdk/client-s3": "^3.178.0",
52-
"@sentry/node": "^7.13.0",
53-
"@sentry/tracing": "^7.13.0",
52+
"@sentry/integrations": "^7.17.2",
53+
"@sentry/node": "^7.17.2",
54+
"@sentry/tracing": "^7.17.2",
5455
"ajv": "^8.6.2",
5556
"ajv-formats": "^2.1.1",
5657
"amqplib": "^0.10.3",

src/bundle/Server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { green, bold, yellow } from "picocolors";
1010
import { Config, initDatabase, BannedWords } from "@fosscord/util";
1111
import * as Sentry from "@sentry/node";
1212
import * as Tracing from "@sentry/tracing";
13+
import * as Integrations from "@sentry/integrations";
1314

1415
const app = express();
1516
const server = http.createServer();
@@ -73,6 +74,9 @@ async function main() {
7374
new Sentry.Integrations.Http({ tracing: true }),
7475
new Tracing.Integrations.Express({ app }),
7576
new Tracing.Integrations.Mysql(),
77+
new Integrations.RewriteFrames({
78+
root: __dirname,
79+
}),
7680
],
7781
tracesSampleRate: Config.get().sentry.traceSampleRate,
7882
environment: Config.get().sentry.environment,

src/gateway/events/Message.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,25 @@ export async function Message(this: WebSocket, buffer: WS.Data) {
4242
return;
4343
}
4444

45-
const transaction = Sentry.startTransaction({
45+
const transaction = data.op != 1 ? Sentry.startTransaction({
4646
op: OPCODES[data.op],
4747
name: `GATEWAY ${OPCODES[data.op]}`,
4848
data: {
4949
...data.d,
5050
token: data?.d?.token ? "[Redacted]" : undefined,
5151
},
52-
});
52+
}) : undefined;
5353

5454
try {
5555
var ret = await OPCodeHandler.call(this, data);
56-
transaction.finish();
56+
transaction?.finish();
5757
return ret;
5858
} catch (error) {
59-
Sentry.captureException(error);
60-
transaction.finish();
59+
Sentry.withScope((scope) => {
60+
scope.setSpan(transaction);
61+
Sentry.captureException(error);
62+
});
63+
transaction?.finish();
6164
console.error(`Error: Op ${data.op}`, error);
6265
// if (!this.CLOSED && this.CLOSING)
6366
return this.close(CLOSECODES.Unknown_error);

0 commit comments

Comments
 (0)