Skip to content

feat: Upgrade JS SDK to 9.16.1 and add durable objects instrumentation #165

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

Merged
merged 5 commits into from
May 7, 2025

Conversation

AbhiPrasad
Copy link
Member

Durable objects instrumentation support was added in 9.16.0 of the JS SDK. This PR upgrades sentry-mcp to get instrumented with durable objects.

Docs PR for durable objects is here: getsentry/sentry-docs#13626.

In packages/mcp-cloudflare/src/server/lib/mcp-transport.ts I had to comment out the wrapMcpServerWithSentry usage, because this breaks locally with miniflare. We're following up with the cloudflare team about this (more details here in linear: https://linear.app/getsentry/issue/JS-398/9150-breaks-cloudflare-sdk-usage-in-sentry-mcp#comment-7ce26edb). When we fix this, we'll come back and re-enable it.

9.16.0 also added support for logs in the Cloudflare SDK, so I enabled that, and added the consoleLoggingIntegration (integration is optional while logs is experimental in the SDK) to flush logs from console.X calls to Sentry.

@AbhiPrasad AbhiPrasad requested a review from dcramer May 7, 2025 17:44
@dcramer dcramer force-pushed the abhi-upgrade-js-sdk-9.16.1 branch from 8a76040 to d033bdf Compare May 7, 2025 18:05
@@ -25,8 +34,27 @@ export default class SentryMCP extends McpAgent<Env, unknown, WorkerProps> {
userId: this.props.id,
},
onToolComplete: () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually n eed this flush at this point? still no idea why it didnt do anything before

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't need this flush now that we have durable objects instrumentation. We can keep it around for now, let me test quickly to make sure everything is okay - I'll open another PR in a sec.

_experiments: {
enableLogs: true,
},
integrations: [Sentry.consoleLoggingIntegration()],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this make console.error go to sentry as a new issue? if so prob gonna remove it as i prefer the more explicit abstraction

Copy link
Member Author

@AbhiPrasad AbhiPrasad May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this make console.error go to sentry as a new issue

Right now it only records it as a error level log.

Once the SDK is not experimental, we'll merge consoleLoggingIntegration with the regular console instrumentation (which is enabled by default), which give users the option to create issues from console errors. For now it will stay separate, and only create logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thats what i want (I dont ever want console to create issues, generally speaking)

maybe sometimes id want things showing up as logs to be issues, but by default logger integrations are noisey

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe sometimes id want things showing up as logs to be issues, but by default logger integrations are noisey

yeah we're debating between just a boolean option to forward everything, or some callback that allows you to create issues on log message. We'll have this implemented by GA.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id just have the server handle it - no reason we cant have a thing that says "turn logs that look like X into issues"

@@ -1,4 +1,4 @@
import { captureException, captureMessage, withScope } from "@sentry/core";
import { captureException, captureMessage, withScope } from "@sentry/node";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mcp-server is used on multi-env which is why im not binding this to node

@dcramer
Copy link
Member

dcramer commented May 7, 2025

Gonna ship and address comments async.

I reverted the @sentry/node changes to the shared package (except in stdio where its always node). It just doesnt feel right to me to suggest node when we have framework bindings, so prefer core.

@dcramer dcramer merged commit f19320e into main May 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants