Skip to content

feat(hono): Instrument middlewares app.use()#19611

Open
s1gr1d wants to merge 5 commits intodevelopfrom
sig/hono-middleware
Open

feat(hono): Instrument middlewares app.use()#19611
s1gr1d wants to merge 5 commits intodevelopfrom
sig/hono-middleware

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Mar 3, 2026

Middleware spans are named either after the function name or they are numbered.

Middleware in Hono is onion-shaped (see docs) and technically, this shape would create a nested children-based span structure. This however, is not as intuitive and so I decided (after also talking to @andreiborza and @JPeer264) to create a sibiling-like structure:

image

Closes #19585

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


expect(fakeApp._capturedThis).toBe(fakeApp);
});
});
Copy link

Choose a reason for hiding this comment

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

Missing integration or E2E test for feat PR

Medium Severity

This feat PR introduces middleware span instrumentation but only includes unit tests (patchAppUse.test.ts). No integration or E2E test is added to verify that middleware spans actually appear in transaction payloads sent to Sentry. The existing integration test suite in dev-packages/cloudflare-integration-tests/suites/hono-sdk/ does not include any assertions about middleware spans (e.g., spans with op: 'middleware.hono' in the transaction's span list). An integration or E2E test covering the new behavior is recommended.

Additional Locations (1)

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.62 kB added added
@sentry/browser - with treeshaking flags 24.12 kB added added
@sentry/browser (incl. Tracing) 42.42 kB added added
@sentry/browser (incl. Tracing, Profiling) 47.09 kB added added
@sentry/browser (incl. Tracing, Replay) 81.24 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.86 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 85.94 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 98.2 kB added added
@sentry/browser (incl. Feedback) 42.43 kB added added
@sentry/browser (incl. sendFeedback) 30.29 kB added added
@sentry/browser (incl. FeedbackAsync) 35.34 kB added added
@sentry/browser (incl. Metrics) 26.79 kB added added
@sentry/browser (incl. Logs) 26.93 kB added added
@sentry/browser (incl. Metrics & Logs) 27.61 kB added added
@sentry/react 27.37 kB added added
@sentry/react (incl. Tracing) 44.76 kB added added
@sentry/vue 30.07 kB added added
@sentry/vue (incl. Tracing) 44.29 kB added added
@sentry/svelte 25.64 kB added added
CDN Bundle 28.16 kB added added
CDN Bundle (incl. Tracing) 43.25 kB added added
CDN Bundle (incl. Logs, Metrics) 29 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 44.09 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 68.08 kB added added
CDN Bundle (incl. Tracing, Replay) 80.13 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.99 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 85.64 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.53 kB added added
CDN Bundle - uncompressed 82.34 kB added added
CDN Bundle (incl. Tracing) - uncompressed 128.06 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.18 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.89 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.84 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.94 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.76 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.85 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.66 kB added added
@sentry/nextjs (client) 47.17 kB added added
@sentry/sveltekit (client) 42.88 kB added added
@sentry/node-core 52.18 kB added added
@sentry/node 174.48 kB added added
@sentry/node - without tracing 97.33 kB added added
@sentry/aws-serverless 113.13 kB added added

Copy link
Member

@logaretm logaretm left a comment

Choose a reason for hiding this comment

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

+1 for peeling the onion, I did the same in Nitro's SDK for h3 instrumentation.

I got a question tho, based on the screenshot doesn't this show the spans executing in parallel rather than in serial?

Base automatically changed from sig/hono-parametrized-errors to develop March 4, 2026 09:44
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.

[Hono] Record middleware spans

2 participants