Hono Support
Problem Statement
Sentry should support Hono.
Solution Brainstorm
A Hono SDK is not needed to start, but docs should available to explain setup for a Hono app.
Potential other steps:
- Sentry platform in product
- wrapper for node SDK where we could add future custom support for Hono framework
Some other information about hono and Sentry:
- Sentry Middleware for Hono, based on 3rd party toucan SDK for cloudflare: https://www.npmjs.com/package/@hono/sentry?activeTab=readme
- related PR: https://github.com/getsentry/sentry-javascript/issues/12424
- https://hono.dev/docs/guides/middleware#third-party-middleware
- https://hono.dev/docs/middleware/third-party#others
Just for context: Third-party docs for hono are already mentioned here https://docs.sentry.io/platforms/#sdks-supported-by-our-community
and about hono + cloudflare workers? I tried
app.use('*', async (c: Context, next) => {
console.log('Environment:', getEnvVar('ENVIRONMENT', c.env));
console.log('Sentry DSN:', getEnvVar('SENTRY_DSN', c.env));
sentry({dsn: getEnvVar('SENTRY_DSN', c.env), environment: getEnvVar('ENVIRONMENT', c.env)});
const { db } = initializeDb(c.env as { DB_URL: string });
c.set('db', db);
c.set('env', c.env);
await next();
});
but no errors or transactions are being captured ( locally via deno start )
We're currently working on a guide for Hono https://github.com/getsentry/sentry-docs/pull/12710. With this PR we'll add setup docs that mention Cloudflare specifically. Here's a link to a preview page (warning: this might not be the final version that goes into our official docs)
@Lms24 does cloudflare handle the source maps or do you use tsc? Wasn't clear from docs as you don't typically use a build script with cloudflare workers.
Uploading source maps is a user concern. If you don't build your worker script, there's no need for source maps :) If you build//transpile/bundle stuff, you need to upload source maps to get the stack trace mapped back to their original source code.
@Lms24 I think cf workers transpiles it, unless they are just running typescript without compilation? But there is no build tool in dev to output a build folder according to wrangler docs.
Oh I see. This reminds me that there's this open issue about source maps on cloudflare: https://github.com/getsentry/sentry-javascript/issues/14841. Maybe your issue and this issue are related.
I believe @AbhiPrasad followed up on this with cloudflare - if CF/wrangler transpiles again, we probably need a way to use Sentry CLI afterwards. Can you think of a way how to achieve this?
Yeah just saying I think that should be addressed in the doc when it goes out considering it says you officially are supporting hono on workers
It should cover all of the main sentry features working with hono and workers and how to get them setup and also what if anything doesn't work.
Source maps is quite an important point in that in my view which isn't currently documented.
If it doesn't work right now for example better just to say that.
Yeah just saying I think that should be addressed in the doc when it goes out considering it says you officially are supporting hono on workers
@lforst can you add a note for this on https://github.com/getsentry/sentry-docs/pull/12710 🙏
Got a ticket for this today. Specifically to also add Hono support for Deno. https://sentry.zendesk.com/agent/tickets/146732
https://sentry.zendesk.com/agent/tickets/154254
We would love to see this implemented in Sentry! We're launching a new project with Hono and Vue and would love to get all of our logging and instrumentation consolidated in Sentry along with error tracking.
Hey! This issue looks interesting — mind if I take a stab at it and open a PR?
@Karibash Thanks for your interest in opening a PR! We have planned to work on it starting around September/October. But we are happy for any contributions on this.
However, "a PR" is probably a bit difficult as this requires a variety of changes and additions. We try to keep our PRs small to make reviewing easier and add things step by step. If you want, you can start by creating a hono E2E test which is using the @sentry/node or @sentry/cloudflare SDK, just to see what's currently possible with it. From then on, we can iterate further :)
~A PR closing this issue has just been released 🚀~
Edit: This only adds a honoIntegration for @sentry/node. We will still work on a specific Hono SDK.
This issue was referenced by PR #17428, which was included in the 10.15.0 release.