Skip to content

Introduce Bun.fetch.stats - #19750

Open
Jarred-Sumner wants to merge 1 commit into
mainfrom
jarred/introduce-bun-fetch-stats
Open

Jarred-Sumner wants to merge 1 commit into
mainfrom
jarred/introduce-bun-fetch-stats

Conversation

@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

What does this PR do?

This provides useful statistics about all fetch() requests.

  • Bun.fetch.stats.requests
  • Bun.fetch.stats.bytesWritten
  • Bun.fetch.stats.bytesRead
  • Bun.fetch.stats.fail
  • Bun.fetch.stats.redirect
  • Bun.fetch.stats.success
  • Bun.fetch.stats.timeout
  • Bun.fetch.stats.refused
  • Bun.fetch.stats.active

How did you verify your code works?

@Jarred-Sumner
Jarred-Sumner requested review from a team and nektro and removed request for a team May 19, 2025 08:22
@Jarred-Sumner
Jarred-Sumner requested a review from Electroid as a code owner May 19, 2025 08:22
@robobun

robobun commented May 19, 2025 •

Copy link
Copy Markdown
Collaborator
Updated 2:04 AM PT - May 19th, 2025

✅ @Jarred-Sumner, your commit f42401a4f22192e1af025fa61bc6a9a93697871f passed in Build #16782! 🎉


🧪   To try this PR locally:

bunx bun-pr 19750

That installs a local version of the PR into your bun-19750 executable, so you can run:

bun-19750 --bun

Comment thread src/http.zig

if (total_requests_succeeded > 0) {
if (needs_space) try writer.writeAll(Output.prettyFmt(" <d>|<r> ", enable_ansi_colors));
needs_space = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

was this meant to be false?

@nektro

nektro commented May 19, 2025

Copy link
Copy Markdown
Contributor

noting that while

❯ ./build/debug/bun-debug -p 'Bun.fetch === fetch'
false

pr description references the former but the latter is exposed and tested

❯ ./build/debug/bun-debug -p 'Bun.fetch.stats'
HTTPStats {

❯ ./build/debug/bun-debug -p 'fetch.stats'
HTTPStats {

@nektro

nektro commented May 19, 2025

Copy link
Copy Markdown
Contributor

small comments, but was the addition driven by an issue or use case you ran into? curious if you have more info on what led you to this api

This branch has not been deployed

No deployments
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.

3 participants