{"@attributes":{"version":"2.0"},"channel":{"title":"DEV Community: Aditya Reddy","description":"The latest articles on DEV Community by Aditya Reddy (@adityareddy_dev).","link":"https:\/\/dev.to\/adityareddy_dev","image":{"url":"https:\/\/media2.dev.to\/dynamic\/image\/width=90,height=90,fit=cover,gravity=auto,format=auto\/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4158587%2F45f6422d-df7c-41a5-848a-7b0c815491c5.png","title":"DEV Community: Aditya Reddy","link":"https:\/\/dev.to\/adityareddy_dev"},"language":"en","item":[{"title":"There's a Judge for Algorithms. I Built One for System Design","pubDate":"Fri, 13 Nov 2026 12:39:24 +0000","link":"https:\/\/dev.to\/adityareddy_dev\/i-ran-a-url-shortener-through-24-hours-of-traffic-2lg9","guid":"https:\/\/dev.to\/adityareddy_dev\/i-ran-a-url-shortener-through-24-hours-of-traffic-2lg9","description":"<p><em>You draw the system, press Start, and a full day of traffic hits it in about two and a half minutes. Then it tells you what broke and what it cost.<\/em><\/p>\n\n<p><strong>TL;DR:<\/strong> I built System Designer, a free and open-source game for practicing system design in your browser. You pick a problem (82 of them, from 15 industries), draw the architecture with 99 parts, press Start, and a full 24-hour day of traffic runs through it in about two and a half minutes. Flash crowds at 7 pm, a database failover, bots, the works. Then the debrief scores uptime, speed, data safety and cost out of 1,000 and tells you in plain words where the points went. There's a daily challenge, and \"beat my design\" links for your group chat. You can play for free as a guest. Sign in to sync progress or post a score. Public guides and lessons show a preview and ask for an email to read the rest. Play it at <a href=\"https:\/\/systemdesigner.io\" rel=\"noopener noreferrer\">systemdesigner.io<\/a>.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3f3hjidcfd5lxpazssif.webp\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3f3hjidcfd5lxpazssif.webp\" alt=\"Concert tickets go on sale at 10:00. This is what 25 times the normal traffic looks like.\" width=\"759\" height=\"475\"><\/a><\/p>\n\n<p><em>Concert tickets go on sale at 10:00. This is what 25 times the normal traffic looks like.<\/em><\/p>\n\n<h2>\n  \n  \n  Why I made it a game\n<\/h2>\n\n<p>For algorithms there's LeetCode. You get a problem, write code, a judge runs it and a few seconds later you know. System design has nothing like that. You read a chapter on caching, draw a load balancer and three boxes on a whiteboard, nod, and move on. Nobody ever sends 8x traffic at your three boxes at 7 pm to check if they hold.<\/p>\n\n<p>That's the bit I wanted, so I built System Designer. Think of it as a judge for system design where the test case is a whole simulated day of traffic.<\/p>\n\n<p>It covers the whole industry on purpose, link shorteners, bank ledgers, the login code your bank texts you. And it had to look good. Watching your own design light up and then go red when the flash crowd hits sticks with you way longer than a static diagram does.<\/p>\n\n<p>Anyone can play it for free, whether you're a student, prepping for interviews, a senior engineer or a product person who just wants to know why the app went down last Friday. Got a good score? Send the link to a friend and make them beat it.<\/p>\n\n<h2>\n  \n  \n  What a round looks like\n<\/h2>\n\n<p>Every problem walks you through five steps, roughly the order you'd answer a system design interview in.<\/p>\n\n<ol>\n<li>\n<strong>Clarify.<\/strong> You read the brief and tap questions. The answers matter. \"A few hundred titles get most of the viewing\" changes how you'd build a video service.<\/li>\n<li>\n<strong>Numbers.<\/strong> You guess the big figures on a slider. Peak requests per second, bandwidth, whatever the problem hinges on. Within 2x of the worked answer counts as a good guess, and then it shows you the math.<\/li>\n<li>\n<strong>Draw.<\/strong> Drag parts in and connect them. A cost meter ticks up as you go, and a little check tells you if it'll hold at peak.<\/li>\n<li>\n<strong>Traffic day.<\/strong> Press Start. The clock runs 00:00 to 24:00 with the problem's traffic curve and its events. At 1x the day is about two and a half minutes. You can pause, or push it to 8x if you're impatient.<\/li>\n<li>\n<strong>Debrief.<\/strong> You get a score out of 1,000, stars, and the story of each event.<\/li>\n<\/ol>\n\n<p>A first try takes about 5 to 8 minutes and a retry about 3. Stuck? There are three levels of hints, they're free, and they don't touch your score.<\/p>\n\n<h2>\n  \n  \n  Video streaming is a bandwidth problem\n<\/h2>\n\n<p>The Video streaming problem is \"a video service like Netflix\": 400 thousand subscribers, a peak of about 600 requests a second, and 80 percent of that is video chunks. The uptime target is 99.9 percent and the budget is $108,000 a month.<\/p>\n\n<p>The Numbers step makes you do the math that actually matters here:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"mi\">600<\/span> <span class=\"n\">req<\/span><span class=\"o\">\/<\/span><span class=\"n\">s<\/span> <span class=\"n\">x<\/span> <span class=\"mf\">0.8<\/span>             <span class=\"o\">=<\/span> <span class=\"mi\">480<\/span> <span class=\"n\">video<\/span> <span class=\"n\">chunks<\/span> <span class=\"n\">a<\/span> <span class=\"n\">second<\/span>\n<span class=\"mi\">480<\/span> <span class=\"n\">chunks<\/span> <span class=\"n\">x<\/span> <span class=\"mi\">2<\/span> <span class=\"no\">MB<\/span>           <span class=\"o\">=<\/span> <span class=\"mi\">960<\/span> <span class=\"no\">MB<\/span><span class=\"o\">\/<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"n\">about<\/span> <span class=\"mf\">7.7<\/span> <span class=\"nc\">Gbps<\/span>\n<span class=\"o\">~<\/span><span class=\"mf\">0.5<\/span> <span class=\"no\">GB<\/span><span class=\"o\">\/<\/span><span class=\"n\">s<\/span> <span class=\"n\">average<\/span> <span class=\"n\">x<\/span> <span class=\"n\">a<\/span> <span class=\"n\">month<\/span> <span class=\"o\">=<\/span> <span class=\"n\">about<\/span> <span class=\"mi\">1<\/span><span class=\"p\">,<\/span><span class=\"mi\">300<\/span> <span class=\"no\">TB<\/span> <span class=\"n\">sent<\/span> <span class=\"n\">to<\/span> <span class=\"n\">viewers<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Through a CDN at about 4 cents a gigabyte, that's over $50,000 a month on bandwidth alone, before a single server (approx.). And the day isn't calm. There's a cache stampede at noon and a cost blowout at 21:00, and at 19:00 a new season drops and traffic goes to 8 times normal in 30 seconds.<\/p>\n\n<p>This design puts a CDN in front of every viewer. When a video chunk misses, it goes to an origin shield, which merges misses from every edge so object storage sees one request per chunk and not thousands. App servers only handle sign-in, browsing and play events, with a cache and a read replica in front of the database. Before the day even starts the game projects about $78,406 a month plus usage, and says it holds at the normal peak and in the 8x flash crowd.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmfipappgh111n58dewny.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmfipappgh111n58dewny.png\" alt=\"Traffic day at 19:06, in the middle of the flash crowd: 100% success.\" width=\"800\" height=\"622\"><\/a><\/p>\n\n<p><em>Traffic day at 19:06, in the middle of the flash crowd: 100% success.<\/em><\/p>\n\n<p>Every part has a bar that fills up as it gets busy. When one hits its limit it turns red and shows how many requests it's rejecting. At 19:07, right in the flash crowd, this design is at 100 percent success with a p99 of 249 ms.<\/p>\n\n<h2>\n  \n  \n  What under-building looks like\n<\/h2>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F38bx4zrmsc67rxp3zu6r.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F38bx4zrmsc67rxp3zu6r.png\" alt=\"The weak design at 19:06, six minutes in. The app servers are already turning requests away.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>The weak design at 19:06, six minutes in. The app servers are already turning requests away.<\/em><\/p>\n\n<p>Now the same problem with a weak design. Two app servers, object storage and one SQL database, no CDN. At 19:28, almost half an hour into the flash crowd, the app servers are overloaded. Only 76.6 percent of requests get through against a 99.9 percent target, and p99 is 1.7 s when reads should come back in 300 ms.<\/p>\n\n<p>And it costs more. The meter reads about $148,172 a month, way over the $108,000 budget, cause sending video straight from storage to the internet is about 9 cents a gigabyte and through a CDN it's about 4 (approx.). So here the bigger design is actually the cheaper one.<\/p>\n\n<h2>\n  \n  \n  The debrief explains every number\n<\/h2>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0hyg2jexzw9lethym1o2.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0hyg2jexzw9lethym1o2.png\" alt=\"The debrief after a full day. This one held.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>The debrief after a full day. This one held.<\/em><\/p>\n\n<p>The score is out of 1,000. Reliability is 400 of that, and speed, data safety and cost are 200 each. The reference design gets 1,000 here. Reads were inside their 300 ms target for 90 percent of requests and peaked at 378 ms. That's inside the allowance, so it still gets full points on speed. Cost gets full points at about $97,434 a month, and the card shows where the money went (about $70,083 of it is CDN usage).<\/p>\n\n<p>The badge under the stars says \"Reference design: not saved to your results\". If you load the editorial's design and run it you still get the full debrief, it just doesn't count as your result.<\/p>\n\n<p>To pass, the design has to meet the problem's uptime, latency and data safety targets and stay within budget. Duplicate work fails the run. A pass is one star, 800 or more is two, 920 or more is three.<\/p>\n\n<p>Below the cards is the day itself: a traffic curve with the failed minutes marked, and a card for each event. The noon cache stampede card says the hit rate fell to zero, and that the CDN and the origin shield each let one request refill a key while the rest waited, so nothing broke. It also gives the real-world number behind it. With a 90 percent hit rate, an empty cache sends 10 times the normal load to the database (approx.). The 21:00 cost blowout ran usage costs at 3 times normal until midnight and added about $1,664 to the month.<\/p>\n\n<h2>\n  \n  \n  The editorial, after you've tried\n<\/h2>\n\n<p>Once you've finished one day, the editorial opens (with a spoiler warning if you haven't passed yet). It has one to three strong designs with the reasoning, the worked numbers, the monthly cost and the trade-offs, and every design was measured by playing it through a full day in the same engine. You can load one onto your canvas, or load it and run it straight away.<\/p>\n\n<p>The trade-offs are the part worth reading. For video, one of them is \"Bandwidth cost dominates. Doubling the app servers barely changes the bill. Doubling the viewers doubles it.\"<\/p>\n\n<h2>\n  \n  \n  Tickets go on sale at 10:00\n<\/h2>\n\n<p>The concert ticket drop is one of the hard ones. 40,000 seats, and a normal day is flat at about 600 requests a second. Then at 10:00 sharp it jumps to about 25 times that and stays there for 15 minutes. The bots are already there, they showed up at 09:50. At 10:07 the page stalls and everyone starts hitting refresh, which makes it worse.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiill4i89kpgoqxdohsfv.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiill4i89kpgoqxdohsfv.png\" alt=\"10:05 with a load balancer, three app servers and one database.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>10:05 with a load balancer, three app servers and one database.<\/em><\/p>\n\n<p>The obvious first design is a load balancer, a few app servers and a database. It's cheap, about $1,407 a month against a budget of about $16,000. Five minutes into the sale it's serving 7 percent of what arrives.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn4c6a16g5p5ybtvixalc.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn4c6a16g5p5ybtvixalc.png\" alt=\"Same minute with a waiting room in front of the seat database.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>Same minute with a waiting room in front of the seat database.<\/em><\/p>\n\n<p>You could add app servers, but one database primary takes about 2,000 writes a second and the rush wants about 3,600 seat holds a second. The game says it straight in the editorial, \"You cannot buy your way out of a 25 times jump that lasts 15 minutes.\" So the design there puts people in a line. Seat holds go into a queue and workers drain it at the speed the database can take, with a CDN serving the event page and a rate limiter turning the bots away. At 10:05 that one has served 99.999 percent of the day's requests and costs about $9,995 a month.<\/p>\n\n<h2>\n  \n  \n  82 problems from across the industry\n<\/h2>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9yzkmzcls9vf6xed3h31.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9yzkmzcls9vf6xed3h31.png\" alt=\"Medium only, one click. 33 of the 82 problems.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>Medium only, one click. 33 of the 82 problems.<\/em><\/p>\n\n<p>Every problem is a real kind of product with real requirements. The card tells you the users, the peak requests per second, the mix of request types, a p99 latency target, an uptime target, a data safety rule and a monthly budget. Real companies show up only as comparisons, \"a video service like Netflix\", nothing more.<\/p>\n\n<p>Today there are 19 Easy, 33 Medium and 30 Hard, and every industry has at least one Hard. You can filter by difficulty, industry, concept and status. Or skip the filters and follow a study path like \"Surviving spikes\" or \"Money and safety\", which pull problems from different industries.<\/p>\n\n<h2>\n  \n  \n  Learn: one idea, one live demo\n<\/h2>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fehd3rejxriq20twbfucy.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fehd3rejxriq20twbfucy.png\" alt=\"Lessons are live demos. Here the cache is in and the database has calmed down.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>Lessons are live demos. Here the cache is in and the database has calmed down.<\/em><\/p>\n\n<p>Never touched a load balancer? Learn is where to start. 24 short lessons, one idea each: caching, load balancing, replication lag, sharding, queues and backpressure, consistency, idempotency and retries, rate limiting, CDNs, multi-region, observability, cost, AI serving and some more. Each is about 3 minutes and the demo runs on the same engine as the game. There are also 17 longer lessons, 5 to 8 minutes each, under Go deeper and Lead the design.<\/p>\n\n<p>In the caching lesson 12,000 requests a second hit 14 app servers and one SQL database, and 95 percent of them are reads. The database is nearly full. You drop a cache in between, and the goal is to keep the database at or under 70 percent busy for a full minute. It sneaks the numbers in while you play:<\/p>\n\n<ul>\n<li>a read from memory in the same zone is about 0.5 ms, a database read about 5 ms (approx.)<\/li>\n<li>read-heavy data usually gets an 85 to 95 percent hit rate<\/li>\n<li>at 90 percent only misses reach the database, so about 11,400 reads a second turns into about 1,140<\/li>\n<\/ul>\n\n<p>Then a three-question check. One of them asks what a long TTL costs you. Answer: you might hand back stale data.<\/p>\n\n<h2>\n  \n  \n  Interview mode and twists\n<\/h2>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fan3ps61mkcdt9e3hs0jn.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fan3ps61mkcdt9e3hs0jn.png\" alt=\"Interview mode. The clock starts at 45 minutes.\" width=\"800\" height=\"500\"><\/a><\/p>\n\n<p><em>Interview mode. The clock starts at 45 minutes.<\/em><\/p>\n\n<p>Hints are free in the normal game. That's fine when you're learning, but in an interview nobody hands you the clarifying questions, so Medium and Hard problems have an Interview mode where you type your own, with a 45-minute clock running and no hints. You write the requirements and the estimates too, and you have to defend the design in writing.<\/p>\n\n<p>Twists are the other part. After a finished day you can ask for one and it changes the demand and the budget on the design you just built. For video streaming it's \"Demand has settled at about 150 requests\/s\" with a new ceiling of about $43,000 a month. Pass a twist without hints and the problem counts as mastered.<\/p>\n\n<h2>\n  \n  \n  Challenge: show off to your friends\n<\/h2>\n\n<p>Every day there's a new seeded challenge, and it's the same for everyone that day. The date picks the problem and a twist. On 3 November it was Real-time fraud detection, card fraud checks at a bank that have to answer in about 150 ms, with every event moved 45 minutes earlier, 23 percent stronger, and a surprise cold start thrown in. You can't edit during the day in Challenge, so it's a pure design test, and you get personal bests and a streak.<\/p>\n\n<p>Then the fun part. After any finished day, Share makes a \"beat my design\" link. The whole architecture, the seed and the score are in the URL itself, and nothing gets uploaded. The one for the card below is 538 characters. Your friend sees your score as the target and can show your design as a faint ghost while they build. When they finish, their browser replays your design on the same traffic and marks your score verified if it matches, so nobody gets to just type in 1,000.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu73o4pxryp6fim9rbh4m.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu73o4pxryp6fim9rbh4m.png\" alt=\"The 1200 by 630 result card, drawn in the browser.\" width=\"800\" height=\"420\"><\/a><\/p>\n\n<p><em>The 1200 by 630 result card, drawn in the browser.<\/em><\/p>\n\n<p>The card is a 1200 by 630 image drawn right in the browser. This one held the day at 999 out of 1,000: about 100 percent success against a 99.9 percent target, nothing lost and about $97,574 a month against a $108,000 budget, with a thumbnail of all 17 parts. It uses your phone's share sheet when there is one, or you can download it.<\/p>\n\n<h2>\n  \n  \n  Signing in\n<\/h2>\n\n<p>You can play System Designer for free without an account. Sign in with Google or GitHub to sync your progress across devices or post a score to the public leaderboard. The guides and public lesson pages show the first part and ask for an email to read the rest.<\/p>\n\n<p>The leaderboard doesn't trust any score a browser sends. The server takes the same payload a \"beat my design\" link carries, rebuilds that day's exact scenario, replays the full day with the game's own engine and keeps its own score. The editorial's designs aren't listed, and neither is anything with the same wiring, so loading the answer and changing a few sizes won't get you on the board. It can't tell who drew a design though, so one copied from a friend's link still counts, and the board says that plainly.<\/p>\n\n<p>Signing in stores your provider id, a display name, your avatar link, your progress and your scores, and you can delete all of it any time.<\/p>\n\n<h2>\n  \n  \n  About the numbers\n<\/h2>\n\n<p>Accuracy comes before flash in this game. Every price, capacity and latency is a rounded real-world approximation, shown with \u2248 and labelled as one. Prices follow the public list prices of the big cloud providers, and capacities and latencies follow commonly published figures. Problem budgets and targets were measured by playing each reference design through a full simulated day. Real systems vary a lot, so treat them as a sense of scale and not a quote.<\/p>\n\n<p>A few of the figures the game uses:<\/p>\n\n<div class=\"table-wrapper-paragraph\"><table>\n<thead>\n<tr>\n<th>Part<\/th>\n<th>Rough price<\/th>\n<th>Rough capacity<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>App server (4 vCPU, 16 GB)<\/td>\n<td>\u2248 $140 a month<\/td>\n<td>\u2248 1,000 requests a second for a typical JSON API<\/td>\n<\/tr>\n<tr>\n<td>Cache node (about 13 GB)<\/td>\n<td>\u2248 $150 a month<\/td>\n<td>\u2248 100,000 operations a second<\/td>\n<\/tr>\n<tr>\n<td>SQL primary (4 vCPU, 32 GB)<\/td>\n<td>\u2248 $450 a month<\/td>\n<td>\u2248 8,000 simple indexed queries a second<\/td>\n<\/tr>\n<tr>\n<td>CDN<\/td>\n<td>\u2248 $0.04 per GB sent<\/td>\n<td>\u2248 2 million requests a second<\/td>\n<\/tr>\n<tr>\n<td>Idempotency store<\/td>\n<td>\u2248 $100 a month<\/td>\n<td>\u2248 50,000 checks a second<\/td>\n<\/tr>\n<tr>\n<td>WebSocket gateway node<\/td>\n<td>\u2248 $200 a month<\/td>\n<td>\u2248 100,000 open connections<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<p>The traffic engine is a flow model that moves in fixed 10-second ticks. It treats traffic as rates rather than individual requests, and the lessons say so. It's also deterministic, which is what lets a friend's browser, and the leaderboard, replay your design and check your score.<\/p>\n\n<h2>\n  \n  \n  How to play\n<\/h2>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkio1yiotf18l34418p8a.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkio1yiotf18l34418p8a.png\" alt=\"It works on a phone too.\" width=\"800\" height=\"1731\"><\/a><\/p>\n\n<p><em>It works on a phone too.<\/em><\/p>\n\n<p>Play it at <a href=\"https:\/\/systemdesigner.io\" rel=\"noopener noreferrer\">https:\/\/systemdesigner.io<\/a>. If you've never heard of a load balancer, start with the 3-minute intro. If you have, try the URL shortener first and then go break video streaming. And if you hold the concert ticket drop, send the link to a friend and make them try.<\/p>\n\n<p>The code is on GitHub under the MIT license: <a href=\"https:\/\/github.com\/adityareddy-dev\/system-designer\" rel=\"noopener noreferrer\">https:\/\/github.com\/adityareddy-dev\/system-designer<\/a>. It's a static site with no build step.<\/p>\n\n","category":["systemdesign","webdev","javascript","opensource"]},{"title":"The pagehide listener that never ran","pubDate":"Sat, 07 Nov 2026 20:29:54 +0000","link":"https:\/\/dev.to\/adityareddy_dev\/the-pagehide-listener-that-never-ran-3k3e","guid":"https:\/\/dev.to\/adityareddy_dev\/the-pagehide-listener-that-never-ran-3k3e","description":"<p>TL;DR: I removed a dead <code>pagehide<\/code> listener from OpenTelemetry's browser batch processors. Moving it to <code>window<\/code> would have made it run, but it would also have introduced an earlier logs flush that could miss final web-vitals records. The removal shipped in <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/releases\/tag\/v3.0.0\" rel=\"noopener noreferrer\">OpenTelemetry JS 3.0.0<\/a>.<\/p>\n\n<h2>\n  \n  \n  I found it reading the code\n<\/h2>\n\n<p>The browser <code>BatchSpanProcessor<\/code> and <code>BatchLogRecordProcessor<\/code> already flushed when <code>document.visibilityState<\/code> became <code>hidden<\/code>. They also registered a <code>pagehide<\/code> listener as a fallback for an old Safari bug. That listener was attached to <code>document<\/code>:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code>    <span class=\"nb\">document<\/span><span class=\"p\">.<\/span><span class=\"nf\">addEventListener<\/span><span class=\"p\">(<\/span><span class=\"s1\">'pagehide'<\/span><span class=\"p\">,<\/span> <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_pageHideListener<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>That line comes from the <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/pull\/7153\/files\" rel=\"noopener noreferrer\">removed code in my PR<\/a>. The browser dispatches <code>pagehide<\/code> at <code>window<\/code>, so the document listener never received it during real navigation. The <a href=\"https:\/\/html.spec.whatwg.org\/multipage\/nav-history-apis.html#fire-a-page-transition-event\" rel=\"noopener noreferrer\">HTML page-transition event definition<\/a> specifies the window dispatch.<\/p>\n\n<p>My first version moved the listener to <code>window<\/code>. I had checked a navigation in Chromium 151, Firefox 153 and WebKit 26.5: the window listener ran in each, and the document listener didn't. Those results are recorded in <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/pull\/7153\" rel=\"noopener noreferrer\">the PR<\/a>.<\/p>\n\n<p>The browser review caught a problem with that change: a working listener would start flushing the logs queue earlier.<\/p>\n\n<h2>\n  \n  \n  The test sent the event to the same wrong place\n<\/h2>\n\n<p>The old logs test created an event:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code>    <span class=\"n\">pageHideEvent<\/span> <span class=\"o\">=<\/span> <span class=\"k\">new<\/span> <span class=\"nc\">Event<\/span><span class=\"p\">(<\/span><span class=\"s1\">'pagehide'<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Then it dispatched that event directly on the document:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code>    <span class=\"nf\">describe<\/span><span class=\"p\">(<\/span><span class=\"s1\">'by the pagehide event'<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n      <span class=\"nf\">testDocumentHide<\/span><span class=\"p\">(<\/span><span class=\"p\">(<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n        <span class=\"nb\">document<\/span><span class=\"p\">.<\/span><span class=\"nf\">dispatchEvent<\/span><span class=\"p\">(<\/span><span class=\"n\">pageHideEvent<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n      <span class=\"p\">}<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n    <span class=\"p\">}<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>These are excerpts from the <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/blob\/4148e2190d6ff5cc68be40932bee22a0e1e63ab7\/packages\/sdk-logs\/test\/browser\/export\/BatchLogRecordProcessor.test.ts#L93-L97\" rel=\"noopener noreferrer\">test before the change<\/a>. The synthetic event reached the handler because the test chose <code>document<\/code> as its destination. It exercised the handler without checking where the browser sends <code>pagehide<\/code>.<\/p>\n\n<h2>\n  \n  \n  Navigate away and keep the callbacks\n<\/h2>\n\n<p>For the navigation check, the small demo has three observation listeners: <code>pagehide<\/code> on both objects, plus <code>visibilitychange<\/code> on <code>document<\/code>. A link loads a second page in the same tab. Each departing-page callback writes its fields to <code>sessionStorage<\/code>; the destination displays those saved rows.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu1dajccetiz96xjxc4w8.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu1dajccetiz96xjxc4w8.png\" alt=\"The demo start page with three observation listeners and a link to page two\" width=\"800\" height=\"556\"><\/a><\/p>\n\n<p><em>Before navigation: one listener on each candidate object, plus the visibility listener. No SDK or exporter is loaded.<\/em><\/p>\n\n<p>The fresh run on November 7, 2026, at 14:14:39 America\/Chicago (-06:00), used Chrome 156.0.8078.73 in headless mode. It produced these callbacks:<\/p>\n\n<div class=\"table-wrapper-paragraph\"><table>\n<thead>\n<tr>\n<th>Order<\/th>\n<th>Listener that ran<\/th>\n<th><code>currentTarget<\/code><\/th>\n<th>Visibility<\/th>\n<th><code>isTrusted<\/code><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td><code>window:pagehide<\/code><\/td>\n<td><code>window<\/code><\/td>\n<td><code>visible<\/code><\/td>\n<td><code>true<\/code><\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td><code>document:visibilitychange<\/code><\/td>\n<td><code>document<\/code><\/td>\n<td><code>hidden<\/code><\/td>\n<td><code>true<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<p>The document <code>pagehide<\/code> listener produced zero callbacks.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj82438wo09nyuvpdicdy.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj82438wo09nyuvpdicdy.png\" alt=\"Page two showing the two retained browser-generated lifecycle callbacks\" width=\"800\" height=\"556\"><\/a><\/p>\n\n<p><em>Actual destination page from that run. The saved rows came from the departing document; this page doesn't dispatch replacement events.<\/em><\/p>\n\n<p>In the <code>pagehide<\/code> row, <code>event.target<\/code> says <code>document<\/code>, even though the callback ran on the window listener. <code>event.currentTarget<\/code> says <code>window<\/code>. The <a href=\"https:\/\/html.spec.whatwg.org\/multipage\/nav-history-apis.html#fire-a-page-transition-event\" rel=\"noopener noreferrer\">HTML event algorithm<\/a> uses a legacy target override; the <a href=\"https:\/\/dom.spec.whatwg.org\/#concept-event-dispatch\" rel=\"noopener noreferrer\">DOM dispatch algorithm<\/a> sets that target to the document. The target field alone doesn't tell you which listener ran.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9wbl569h52six51ojvrp.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9wbl569h52six51ojvrp.png\" alt=\"Expanded retained output showing the event target and currentTarget fields\" width=\"800\" height=\"864\"><\/a><\/p>\n\n<p><em>The retained event fields include <code>target: document<\/code>, <code>currentTarget: window<\/code> and <code>isTrusted: true<\/code> for <code>pagehide<\/code>.<\/em><\/p>\n\n<p>This demo observes event dispatch and order. It doesn't run a telemetry exporter or measure record delivery.<\/p>\n\n<h2>\n  \n  \n  Moving to window starts another flush\n<\/h2>\n\n<p>In <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/pull\/7153#pullrequestreview-5449510837\" rel=\"noopener noreferrer\">the browser review<\/a>, @overbalance pointed out the hard-navigation sequence: <code>pagehide<\/code> arrives before <code>visibilitychange<\/code>. A window listener would start flushing the existing logs before the application's final hidden-state records arrive. The review named final INP, CLS and LCP records as examples.<\/p>\n\n<p>I had treated the overlap as a narrow case involving a log written by another <code>pagehide<\/code> handler. In <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/pull\/7153#issuecomment-6049608289\" rel=\"noopener noreferrer\">my follow-up<\/a>, I corrected that: records emitted on <code>visibilitychange<\/code> could hit it too.<\/p>\n\n<p>The logs processor's existing <code>_flushAll()<\/code> explains why. This excerpt is from the <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/blob\/4148e2190d6ff5cc68be40932bee22a0e1e63ab7\/packages\/sdk-logs\/src\/export\/BatchLogRecordProcessorBase.ts#L221-L280\" rel=\"noopener noreferrer\">source at the PR base<\/a>:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code>    <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_flushing<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n      <span class=\"k\">return<\/span><span class=\"p\">;<\/span>\n    <span class=\"p\">}<\/span>\n    <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_flushing<\/span> <span class=\"o\">=<\/span> <span class=\"kc\">true<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>A concurrent call returns without waiting for the running flush. That running flush has already taken its set of records:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code>    <span class=\"kd\">let<\/span> <span class=\"n\">toFlush<\/span> <span class=\"o\">=<\/span> <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_finishedLogRecords<\/span><span class=\"p\">;<\/span>\n    <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_finishedLogRecords<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span><span class=\"p\">]<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>New records enter the fresh queue, outside the snapshot the earlier flush took.<\/p>\n\n<h2>\n  \n  \n  Follow one late record\n<\/h2>\n\n<p>In the review's scenario, the first flush is still running when the application emits its final record. Assume that record arrives before the SDK's hidden-state handler calls flush:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>pagehide on window\n  proposed listener starts forceFlush()\n  earlier records move into the flush snapshot\n  export remains in flight\n\nvisibilitychange to hidden\n  application emits final record into the fresh queue\n  SDK calls forceFlush()\n  _flushing is still true, so the call returns\n\npage leaves\n  final record can remain outside the earlier export\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p><em>Sequence from the PR review and queue implementation. This is an explanation of the proposed change, not captured exporter output.<\/em><\/p>\n\n<p>The second call doesn't delete the final record. It leaves that record queued while the first export handles its earlier snapshot. If the page leaves before another export opportunity, the record can miss delivery. The <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/blob\/4148e2190d6ff5cc68be40932bee22a0e1e63ab7\/packages\/sdk-logs\/src\/export\/BatchLogRecordProcessorBase.ts#L221-L280\" rel=\"noopener noreferrer\">guard and snapshot code<\/a> explain that behavior for logs; this isn't a description of the trace processor's concurrency handling.<\/p>\n\n<p>The fresh Chrome run above has the event order discussed in the review. Other browsers and transitions need their own captures before treating that order as universal.<\/p>\n\n<h2>\n  \n  \n  The merged change removes the fallback\n<\/h2>\n\n<p>I removed the <code>pagehide<\/code> handler, registration and cleanup from both browser processors, along with the synthetic <code>pagehide<\/code> tests. The <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/pull\/7153\/files\" rel=\"noopener noreferrer\">merged diff<\/a> keeps the existing <code>visibilitychange<\/code> path.<\/p>\n\n<p>The logs handler at the final PR head still reads:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code>    <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_visibilityChangeListener<\/span> <span class=\"o\">=<\/span> <span class=\"p\">(<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\n      <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"nb\">document<\/span><span class=\"p\">.<\/span><span class=\"n\">visibilityState<\/span> <span class=\"o\">===<\/span> <span class=\"s1\">'hidden'<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n        <span class=\"k\">void<\/span> <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"nf\">forceFlush<\/span><span class=\"p\">(<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n      <span class=\"p\">}<\/span>\n    <span class=\"p\">}<\/span><span class=\"p\">;<\/span>\n    <span class=\"nb\">document<\/span><span class=\"p\">.<\/span><span class=\"nf\">addEventListener<\/span><span class=\"p\">(<\/span>\n      <span class=\"s1\">'visibilitychange'<\/span><span class=\"p\">,<\/span>\n      <span class=\"kc\">this<\/span><span class=\"p\">.<\/span><span class=\"n\">_visibilityChangeListener<\/span>\n    <span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p><a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/blob\/a2d077c2ed065bf1c791bf569b66e59d68ac0aff\/packages\/sdk-logs\/src\/platform\/browser\/export\/BatchLogRecordProcessor.ts#L36-L45\" rel=\"noopener noreferrer\">Source at the final PR head<\/a>. The release also includes separate error handling for that flush, listed as <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/releases\/tag\/v3.0.0\" rel=\"noopener noreferrer\">another change in the release notes<\/a>.<\/p>\n\n<p>The old Safari fallback no longer needed reviving either. The <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/pull\/7153#pullrequestreview-5449510837\" rel=\"noopener noreferrer\">browser review<\/a> records that its underlying Safari bug was fixed in 2020, before the project's supported browser baseline.<\/p>\n\n<p><a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/releases\/tag\/v3.0.0\" rel=\"noopener noreferrer\">JS 3.0.0 lists the removal for both processors under Internal<\/a>. The old document listener never ran on real navigation, so removing it preserved the existing hidden-state flush and avoided introducing the earlier window flush. It didn't redesign the queue or establish a delivery guarantee for every shutdown path.<\/p>\n\n<h2>\n  \n  \n  Check the record after the handler runs\n<\/h2>\n\n<p>When testing telemetry on navigation, put observation listeners on the actual browser dispatch objects and leave the page through a real navigation. Preserve the callback fields across that transition, including <code>currentTarget<\/code>, visibility state and <code>isTrusted<\/code>.<\/p>\n\n<p>Then test a record emitted late, while an export is still running. Check whether its ID reaches the exporter and whether it belongs to the snapshot the flush took. If the application emits on <code>visibilitychange<\/code>, check its ordering against the SDK's own handler too.<\/p>\n\n","category":["opentelemetry","javascript","webdev","observability"]},{"title":"What broke when I moved Grafana Faro to OpenTelemetry JS 3.0","pubDate":"Wed, 04 Nov 2026 01:51:43 +0000","link":"https:\/\/dev.to\/adityareddy_dev\/what-broke-when-i-moved-grafana-faro-to-opentelemetry-js-30-imb","guid":"https:\/\/dev.to\/adityareddy_dev\/what-broke-when-i-moved-grafana-faro-to-opentelemetry-js-30-imb","description":"<p><strong>TL;DR:<\/strong> I opened the three PRs that move <a href=\"https:\/\/github.com\/grafana\/faro-web-sdk\" rel=\"noopener noreferrer\">Grafana Faro's web SDK<\/a> onto OpenTelemetry JS SDK 3.0. The version bump was the easy part. What took the time was a deep import the new <code>exports<\/code> maps reject, and then the tests. Jest was quietly running the Node build, and a disabled XHR instrumentation turned out to still be making spans. All three PRs are open and waiting on review.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi2ri4kjfqm9tdd0u4o11.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi2ri4kjfqm9tdd0u4o11.png\" alt=\"The Faro epic on GitHub, Migrate to OpenTelemetry JS SDK 3.x, with the plan split into three steps\" width=\"799\" height=\"571\"><\/a><\/p>\n\n<h2>\n  \n  \n  Why Faro had to move at all\n<\/h2>\n\n<p>OpenTelemetry JS SDK 3.0, experimental 0.300 and API 1.10 came out on Oct 20. They only work with each other, so you can't take one and leave the rest. Faro was on 2.x, 0.223 and API 1.9.<\/p>\n\n<p>That sounds like something you can sit on for a while, and for the stable 2.x packages you can, they're supported until about Oct 2027. The problem showed up somewhere else. The contrib browser instrumentations (document load, user interaction, long task) had already moved to core <code>^3.0.0<\/code>. Install one of those next to <code>@grafana\/faro-web-tracing<\/code> and npm resolves <code>@opentelemetry\/api<\/code> to 1.9.1, cause Faro asks for <code>&lt;1.10.0<\/code>. Instrumentation 0.300 imports <code>logs<\/code> from the API, and 1.9.1 doesn't have it. So your app breaks on a package you didn't even touch.<\/p>\n\n<p>The Faro team wrote this up as an <a href=\"https:\/\/github.com\/grafana\/faro-web-sdk\/issues\/2341\" rel=\"noopener noreferrer\">epic with the plan<\/a>. I picked up the steps.<\/p>\n\n<h2>\n  \n  \n  Three PRs, stacked\n<\/h2>\n\n<p>I could have done it in one PR. It would have been one big diff touching about 30 files, and nobody wants to review that.<\/p>\n\n<div class=\"table-wrapper-paragraph\"><table>\n<thead>\n<tr>\n<th>PR<\/th>\n<th>What it does<\/th>\n<th>Ships in<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/github.com\/grafana\/faro-web-sdk\/pull\/2358\" rel=\"noopener noreferrer\">#2358<\/a><\/td>\n<td>Moves tracing setup to <code>@opentelemetry\/sdk-trace<\/code>\n<\/td>\n<td>any 2.x minor<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/github.com\/grafana\/faro-web-sdk\/pull\/2363\" rel=\"noopener noreferrer\">#2363<\/a><\/td>\n<td>Removes deep imports into OTel packages<\/td>\n<td>any 2.x minor<\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/github.com\/grafana\/faro-web-sdk\/pull\/2364\" rel=\"noopener noreferrer\">#2364<\/a><\/td>\n<td>The actual 3.0 \/ 0.300 \/ 1.10 bump<\/td>\n<td>open decision<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<p>The first two change nothing for users and work on 2.x, so they can merge whenever. Only the last one raises what your build needs. Stacking them means the risky diff is small and the boring ones can go first.<\/p>\n\n<h2>\n  \n  \n  WebTracerProvider is gone\n<\/h2>\n\n<p>SDK 3.x drops <code>@opentelemetry\/sdk-trace-web<\/code> and <code>@opentelemetry\/sdk-trace-base<\/code>. Everything Faro used from them is already in <code>@opentelemetry\/sdk-trace<\/code> 2.12, which is why this step can land on 2.x.<\/p>\n\n<p>The one real change is that <code>WebTracerProvider.register()<\/code> used to do several things for you. With the plain <code>TracerProvider<\/code> you do them yourself, in order:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight diff\"><code><span class=\"gd\">-    provider.register({<\/span>\n<span class=\"gd\">-      propagator: new FaroPausablePropagator(\/* ... *\/),<\/span>\n<span class=\"gd\">-      contextManager: options.contextManager,<\/span>\n<span class=\"gd\">-    });<\/span>\n<span class=\"gi\">+    trace.setGlobalTracerProvider(provider);<\/span>\n<span class=\"gi\">+    propagation.setGlobalPropagator(new FaroPausablePropagator(\/* ... *\/));<\/span>\n<span class=\"gi\">+<\/span>\n<span class=\"gi\">+    const contextManager = options.contextManager ?? new StackContextManager();<\/span>\n<span class=\"gi\">+    contextManager.enable();<\/span>\n<span class=\"gi\">+    context.setGlobalContextManager(contextManager);<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>The order matters more than it looks. The context manager has to be enabled before it's registered, and a second Faro instance must not register again over the first. I wrote tests for each of those paths, cause that's exactly the kind of thing that works on the happy path and breaks for the one app that passes its own propagator.<\/p>\n\n<p>Side effect I didn't plan for: the tracing IIFE went from 90,474 to 87,299 bytes minified. Dropping a package you don't use is a nice way to lose 3 KB.<\/p>\n\n<h2>\n  \n  \n  The exports map says no\n<\/h2>\n\n<p>This is the one that would have broken the upgrade if you just bumped versions.<\/p>\n\n<p>All the 0.300 packages declare an <code>exports<\/code> map in <code>package.json<\/code>. Faro had imports straight into <code>build\/src<\/code> of <code>@opentelemetry\/otlp-transformer<\/code>, for the OTLP payload types and for <code>createExportTraceServiceRequest<\/code> and <code>JSON_ENCODER<\/code>. With an exports map, any subpath that isn't listed fails to resolve. It doesn't matter if the file is sitting right there.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjnafmudxmahotqkurayk.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjnafmudxmahotqkurayk.png\" alt=\"Node fails with ERR_PACKAGE_PATH_NOT_EXPORTED and tsc fails with TS2307 when importing from otlp-transformer 0.300's build\/src\" width=\"800\" height=\"237\"><\/a><\/p>\n\n<p>Pointing the paths at the new <code>dist\/<\/code> layout doesn't help either. Unlisted is unlisted.<\/p>\n\n<p>So I moved the OTLP types (<code>IResourceSpans<\/code>, <code>IKeyValue<\/code>, <code>ESpanKind<\/code> and the rest) into <code>@grafana\/faro-core<\/code>, and swapped the exporter over to the public <code>JsonTraceSerializer<\/code>:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight diff\"><code><span class=\"gd\">- import { JSON_ENCODER } from '@opentelemetry\/otlp-transformer\/build\/src\/common\/utils';<\/span>\n<span class=\"gd\">- import { createExportTraceServiceRequest } from '@opentelemetry\/otlp-transformer\/build\/src\/trace\/internal';<\/span>\n<span class=\"gi\">+ import { JsonTraceSerializer } from '@opentelemetry\/otlp-transformer';<\/span>\n\n<span class=\"gd\">- const traceEvent = createExportTraceServiceRequest(spans, JSON_ENCODER);<\/span>\n<span class=\"gi\">+ const traceEvent: TraceEvent = JSON.parse(<\/span>\n<span class=\"gi\">+   new TextDecoder().decode(JsonTraceSerializer.serializeRequest(spans))<\/span>\n<span class=\"gi\">+ );<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>That's one extra encode and parse per batch. I don't love it, though it's the public API in both 0.223 and 0.300 and the payload that goes out is the same. A snapshot test of the trace payload and the derived <code>faro.tracing.*<\/code> event now pins that down.<\/p>\n\n<p>One detail I'd point out to anyone doing the same thing. I didn't copy <code>ESpanKind<\/code> as a TypeScript enum. <code>TraceEvent<\/code> is public through <code>faro.api.pushTraces<\/code>, and enums from two different declarations aren't assignable to each other. If Faro shipped its own enum, any app building payloads with otlp-transformer's enum would stop compiling. A const object with a numeric union type keeps both working.<\/p>\n\n<p>This step also took <code>@opentelemetry\/otlp-transformer<\/code> out of core and the OTLP transport, they only used its types. Without that, every Faro user would pick up 0.300's <code>engines.node &gt;=22.15.0<\/code>, not just the ones using tracing.<\/p>\n\n<h2>\n  \n  \n  The bump, and what it found\n<\/h2>\n\n<p>The version change itself is a few lines in <code>package.json<\/code>. <code>core<\/code>, <code>resources<\/code> and <code>sdk-trace<\/code> to <code>^3.0.0<\/code>, the experimental packages to <code>^0.300.0<\/code>, the API to <code>^1.10.0<\/code>. Typecheck passed without a single change. That was honestly a bit suspicious.<\/p>\n\n<h3>\n  \n  \n  Jest was running the Node build\n<\/h3>\n\n<p>Then Jest. Under Jest 30 with jsdom, OTel's packages resolve to their Node builds, not the browser ones. Nothing fails. You just test the wrong code. This is a one-line test that prints <code>SDK_INFO<\/code> from <code>@opentelemetry\/core<\/code> 3.0, run once without the resolver and once with it:<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv16rv1calx6fgazapi7l.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv16rv1calx6fgazapi7l.png\" alt=\"The same jsdom test reports telemetry.sdk.language nodejs without the resolver and webjs with it, and passes both times\" width=\"800\" height=\"399\"><\/a><\/p>\n\n<p><code>SDK_INFO<\/code> reporting <code>nodejs<\/code> inside a browser test environment is the tell. The <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-js\/blob\/main\/doc\/3.x\/migration-guide.md\" rel=\"noopener noreferrer\">3.x migration guide<\/a> has a Jest resolver for this, and adding it flips it to <code>webjs<\/code>. If you have your own Jest setup with OTel 3.x and jsdom, check this before you trust your green tests.<\/p>\n\n<h3>\n  \n  \n  A disabled instrumentation that kept tracing\n<\/h3>\n\n<p>Running the tests against the real <code>XMLHttpRequestInstrumentation<\/code> (the old ones mocked it) turned up a bug that wasn't about 3.0 at all. <code>FaroXhrInstrumentation<\/code> overrides <code>_patchOpen<\/code>, and the override didn't check <code>_enabled<\/code> like the parent does. <code>disable()<\/code> leaves <code>open<\/code> patched, so a disabled Faro XHR instrumentation kept creating spans.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjy5qxp0k4sr4lcvgvtt2.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjy5qxp0k4sr4lcvgvtt2.png\" alt=\"The new XHR test fails on the #2363 tree with one span after disable(), and all three tests pass on #2364\" width=\"800\" height=\"558\"><\/a><\/p>\n\n<p>It's a one-line check. It's also the kind of bug that lives for years cause the unit tests mock the exact thing that would catch it.<\/p>\n\n<h3>\n  \n  \n  Size and tests\n<\/h3>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbt286nxo6434bfc2l73y.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbt286nxo6434bfc2l73y.png\" alt=\"yarn build output for the tracing IIFE: 74.82 kB and 22.19 kB gzipped on #2363, 76.68 kB and 22.55 kB on #2364\" width=\"799\" height=\"258\"><\/a><\/p>\n\n<p>The tracing bundle grows from 74.8 kB to 76.7 kB (22.1 to 22.5 kB gzipped) against #2363. The web-sdk and core bundles stay the same size, and there's no Node platform code in the browser bundle.<\/p>\n\n<p>On the #2364 head the full suite passes, 1,218 unit tests across seven packages with one skipped.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftuz0dics2mw71nz5s8ww.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftuz0dics2mw71nz5s8ww.png\" alt=\"yarn quality:test on #2364: every package passes, 204, 56, 82, 193, 646, 31 and 6 tests\" width=\"800\" height=\"659\"><\/a><\/p>\n\n<h2>\n  \n  \n  What I checked outside the repo\n<\/h2>\n\n<p>Unit tests only tell you so much for a change like this, so I packed the packages and tried them in real apps:<\/p>\n\n<ul>\n<li>A webpack 5.54 app and a Vite 7 app both build and run. Fetch and XHR spans get exported with <code>telemetry.sdk.language<\/code> set to <code>webjs<\/code>, and the <code>faro.tracing.*<\/code> events still go out.<\/li>\n<li>The <code>.d.ts<\/code> files typecheck with both <code>bundler<\/code> and <code>node16<\/code> module resolution.<\/li>\n<li>On the other end, Alloy's <code>faro.receiver<\/code> uses the collector's <code>ptrace.JSONUnmarshaler<\/code>, so span attributes with object, array and bytes values still parse.<\/li>\n<\/ul>\n\n<p>I also ran my own <a href=\"https:\/\/github.com\/adityareddy-dev\/otel-js-upgrade\" rel=\"noopener noreferrer\"><code>otel-js-upgrade<\/code><\/a> codemod as a dry run on the #2363 tree. It proposed the same version bumps and no code changes. Which is the right answer, and kind of the point of this post: the parts that took time are the ones no codemod can see.<\/p>\n\n<h2>\n  \n  \n  What's still open\n<\/h2>\n\n<p>The 3.0 PR has no <code>!<\/code> in the title on purpose. Whether this ships as Faro v3 or a 2.x minor is still an open call in the epic. Faro's own API doesn't change, but the floor for your build does: webpack 5.54+, Jest 29.4+ or Parcel with <code>packageExports<\/code>, and Node 22.15+ for installs. Those are old versions to still be on, though a minor release breaking someone's build is still a minor release breaking someone's build.<\/p>\n\n<p>There's one thing I left alone. <code>sendFaroEvents<\/code> turns attribute values into strings with <code>String()<\/code>, so array and object values come out as <code>[object Object]<\/code> in the derived events. Arrays already did that on 2.x, 3.x just lets objects through too. That's a small follow up if the maintainers want JSON there.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxenv9zr92onv04sy6ioa.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxenv9zr92onv04sy6ioa.png\" alt=\"PR #2364 on GitHub, the OpenTelemetry JS SDK 3.0 upgrade, open and waiting on review\" width=\"799\" height=\"571\"><\/a><\/p>\n\n<p>After this, the next step is <a href=\"https:\/\/github.com\/grafana\/faro-web-sdk\/issues\/2340\" rel=\"noopener noreferrer\">#2340<\/a>, replacing Faro's fetch and XHR instrumentations with the ones from the OpenTelemetry Browser SIG. That changes trace data, so it's a bigger conversation.<\/p>\n\n<h2>\n  \n  \n  If you're on Faro today\n<\/h2>\n\n<p>Until the upgrade ships, if you add contrib browser instrumentations next to Faro, pin the last versions on 2.x:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>npm i @opentelemetry\/instrumentation-document-load@0.68.0 \\\n  @opentelemetry\/instrumentation-user-interaction@0.67.0 \\\n  @opentelemetry\/instrumentation-long-task@0.67.0\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>That keeps <code>@opentelemetry\/api<\/code> on one version and your app out of the <code>logs<\/code> import error.<\/p>\n\n","category":["opentelemetry","javascript","grafana","observability"]},{"title":"Why your INP can fall after one more click","pubDate":"Mon, 02 Nov 2026 21:49:13 +0000","link":"https:\/\/dev.to\/adityareddy_dev\/why-your-inp-can-fall-after-one-more-click-2p2k","guid":"https:\/\/dev.to\/adityareddy_dev\/why-your-inp-can-fall-after-one-more-click-2p2k","description":"<p>By Aditya Reddy<\/p>\n\n<p>Say you have a page with 49 interactions. The slowest took 480 ms, followed by 320 ms and 240 ms. Everything else was faster. Your INP is 480 ms.<\/p>\n\n<p>Now click something fast. You have changed no code, and that slow interaction still takes 480 ms. The score for the visit drops to 320 ms anyway.<\/p>\n\n<p>That's the part of INP I wanted to explain in <a href=\"https:\/\/github.com\/w3c\/event-timing\/pull\/175\" rel=\"noopener noreferrer\">my Event Timing specification PR<\/a>. The PR is still open. A single number on a dashboard hides quite a bit of bookkeeping.<\/p>\n\n<h2>\n  \n  \n  What happened at click 50?\n<\/h2>\n\n<p>INP skips one longest interaction for every complete group of 50 interactions. At 49, it picks the longest. At 50, it picks the second longest. The <a href=\"https:\/\/web.dev\/articles\/inp#what-is-inp\" rel=\"noopener noreferrer\">INP guide<\/a> explains the reason for excluding these outliers on pages with lots of interactions.<\/p>\n\n<p>For our example, assuming all the extra interactions are below 240 ms:<\/p>\n\n<div class=\"table-wrapper-paragraph\"><table>\n<thead>\n<tr>\n<th>Interactions so far<\/th>\n<th>Longest values skipped<\/th>\n<th>INP candidate<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>49<\/td>\n<td>0<\/td>\n<td>480 ms<\/td>\n<\/tr>\n<tr>\n<td>50<\/td>\n<td>1<\/td>\n<td>320 ms<\/td>\n<\/tr>\n<tr>\n<td>99<\/td>\n<td>1<\/td>\n<td>320 ms<\/td>\n<\/tr>\n<tr>\n<td>100<\/td>\n<td>2<\/td>\n<td>240 ms<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<p>So you can cross two of these boundaries and go from 480 to 240 ms without fixing the 480 ms interaction. Nice dashboard, same slow click.<\/p>\n\n<p>The <a href=\"https:\/\/github.com\/GoogleChrome\/web-vitals\/blob\/main\/src\/lib\/InteractionManager.ts\" rel=\"noopener noreferrer\">selection code in <code>web-vitals<\/code><\/a> amounts to this, with the latencies sorted from longest to shortest:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight javascript\"><code><span class=\"kd\">const<\/span> <span class=\"n\">skip<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">Math<\/span><span class=\"p\">.<\/span><span class=\"nf\">floor<\/span><span class=\"p\">(<\/span><span class=\"n\">interactionCount<\/span> <span class=\"o\">\/<\/span> <span class=\"mi\">50<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<span class=\"kd\">const<\/span> <span class=\"n\">index<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">Math<\/span><span class=\"p\">.<\/span><span class=\"nf\">min<\/span><span class=\"p\">(<\/span><span class=\"n\">skip<\/span><span class=\"p\">,<\/span> <span class=\"n\">descendingLatencies<\/span><span class=\"p\">.<\/span><span class=\"n\">length<\/span> <span class=\"o\">-<\/span> <span class=\"mi\">1<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<span class=\"kd\">const<\/span> <span class=\"n\">candidate<\/span> <span class=\"o\">=<\/span> <span class=\"n\">descendingLatencies<\/span><span class=\"p\">[<\/span><span class=\"n\">index<\/span><span class=\"p\">]<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>You need at least one candidate for this fragment. It is only the selection step, not a complete collector. <code>web-vitals<\/code> retains up to ten of the longest interactions, so the list can be much shorter than the interaction count.<\/p>\n\n<h2>\n  \n  \n  Count interactions, not event entries\n<\/h2>\n\n<p>There is another place to get the numbers wrong before you even reach that selection.<\/p>\n\n<p>A click can leave several <code>PerformanceEventTiming<\/code> entries. Take these made-up values from one visit:<\/p>\n\n<div class=\"table-wrapper-paragraph\"><table>\n<thead>\n<tr>\n<th>Interaction ID<\/th>\n<th>Event<\/th>\n<th>Duration<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>7<\/td>\n<td>pointerdown<\/td>\n<td>320 ms<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>pointerup<\/td>\n<td>296 ms<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>click<\/td>\n<td>280 ms<\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td>click<\/td>\n<td>480 ms<\/td>\n<\/tr>\n<tr>\n<td>21<\/td>\n<td>keydown<\/td>\n<td>240 ms<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n<p>The first three rows belong to one interaction. Its latency is 320 ms, the longest duration in that group. Adding them gives 896 ms, but those durations overlap.<\/p>\n\n<p>Five rows here give us three interactions, with latencies of 320, 480 and 240 ms. Group by the nonzero <code>interactionId<\/code>. Leave entries with ID zero out of this calculation. The <a href=\"https:\/\/w3c.github.io\/event-timing\/#sec-event-timing-interactions\" rel=\"noopener noreferrer\">Event Timing spec<\/a> describes how those IDs group related events.<\/p>\n\n<h2>\n  \n  \n  Your observer may have missed some of it\n<\/h2>\n\n<p>For entries of type <code>event<\/code>, the default duration threshold is 104 ms. You can register an observer with <code>durationThreshold: 16<\/code> to receive shorter events going forward. That does not bring back all the fast events from before registration.<\/p>\n\n<p>Even with buffered delivery, you only get the earlier entries that were kept under the default threshold. This is covered in the spec's <a href=\"https:\/\/w3c.github.io\/event-timing\/#sec-event-timing-when-measured\" rel=\"noopener noreferrer\">measurement section<\/a>.<\/p>\n\n<p>That's why the total interaction count and your observed list length need to stay separate. A fast interaction can increase the count without appearing in that list. Lowering the threshold late won't recover its duration.<\/p>\n\n<p>I would use <a href=\"https:\/\/github.com\/GoogleChrome\/web-vitals\" rel=\"noopener noreferrer\"><code>web-vitals<\/code><\/a> for production collection. There is first-input handling, page visibility and back\/forward cache restoration to account for too. Code running in one window also cannot see every interaction in an embedded frame.<\/p>\n\n<p>When debugging the score, keep the selected interaction's ID and latency along with the total count. If the score drops, check which interaction it picked. And if you are fixing that 480 ms click, compare the click itself before and after the change under similar conditions.<\/p>\n\n<p>The <a href=\"https:\/\/github.com\/w3c\/event-timing\/pull\/175\/files\" rel=\"noopener noreferrer\">proposed spec section<\/a> puts the grouping, selection, observer threshold and retained-list limit together. The fast click at interaction 50 is a useful example of why those details matter.<\/p>\n\n","category":["webperf","javascript","browsers"]},{"title":"How one Desk Studio job gets from roughs to sign-off","pubDate":"Tue, 20 Oct 2026 04:43:48 +0000","link":"https:\/\/dev.to\/adityareddy_dev\/how-one-desk-studio-job-gets-from-roughs-to-sign-off-4h22","guid":"https:\/\/dev.to\/adityareddy_dev\/how-one-desk-studio-job-gets-from-roughs-to-sign-off-4h22","description":"<p>The awkward part of a design job is deciding whether it's done. A file exists, the headline fits, and it's easy to accept it cause opening another round means deciding what to ask for. I built Desk Studio around that decision. I wanted the roughs and the reason for the pick to stay visible, and I wanted a failed check to send the file back with something specific to fix.<\/p>\n\n<p>Here's how that worked on the studio's own launch card. The <a href=\"https:\/\/github.com\/adityareddy-dev\/deskstudio\/blob\/4f0affa6b0f004ac7a15bdd6102e52ce7695500c\/evals\/golden\/social-card\/desk-studio-launch\/state.json\" rel=\"noopener noreferrer\">saved job state<\/a> has the pick, each round's proof result and scores, and the cost by tier. The <a href=\"https:\/\/github.com\/adityareddy-dev\/deskstudio\/blob\/4f0affa6b0f004ac7a15bdd6102e52ce7695500c\/evals\/golden\/social-card\/desk-studio-launch\/golden.json\" rel=\"noopener noreferrer\">golden record<\/a> keeps the final result. It finished at 8.9 over three polish rounds, costing $1.34 at list price. Those are this job's results, not a promise about the next one.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7by1opjqla52lm0bfdhq.gif\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7by1opjqla52lm0bfdhq.gif\" alt=\"A team of desk robots passes one job along: three roughs, the pick, polish, proof and the sign-off\" width=\"600\" height=\"338\"><\/a><br>\n<em>The whole job as a cartoon: three roughs on Sonnet, the pick on Opus, polish on Haiku, proof with no model, the sign-off on Opus, then every signed-off piece back to you.<\/em><\/p>\n<h2>\n  \n  \n  Give the pick something to choose from\n<\/h2>\n\n<p>The launch card started with three directions: editorial split, type only, and frame. These were separate roughs made by the UI Designer at the senior tier. The point of a rough is to expose a layout decision while changing direction is still cheap. If everything already looks finished, it's tempting to spend the next round adjusting details in a direction that never deserved the pick.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw1106enq8uzzolm3a3lc.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw1106enq8uzzolm3a3lc.png\" alt=\"Rough 1, editorial split\" width=\"800\" height=\"418\"><\/a><br>\n<a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi14zsoyb07n05g5wmc7n.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi14zsoyb07n05g5wmc7n.png\" alt=\"Rough 2, type only\" width=\"800\" height=\"418\"><\/a><br>\n<a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxo4hg8wz2i40qqfxq3ui.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxo4hg8wz2i40qqfxq3ui.png\" alt=\"Rough 3, frame\" width=\"800\" height=\"418\"><\/a><\/p>\n\n<p>The Art Director chose rough 2, the type-only direction. The saved reason is useful: the headline read first at both sizes, the small lamp was the only amber element, and the fixes were type sizes rather than layout. That gives the builder a boundary. Keep the structure that earned the pick and work on the type.<\/p>\n\n<p>The card had LinkedIn and Instagram post sizes. A direction had to work across both, so the pick was made from renders. Reading the source wouldn't show whether the headline actually won attention at each size.<\/p>\n<h2>\n  \n  \n  Put the revisions where they're cheap\n<\/h2>\n\n<p>After the pick, the UI Designer moved to the builder tier for polish. The launch job used Sonnet for roughs, Haiku for the revisions, and Opus for the pick and sign-offs. Those assignments are in the state alongside the completed desk runs.<\/p>\n\n<p>I want the expensive judgment to arrive with a concrete job to do. The builder already has a chosen direction, the notes and a screenshot. It can spend its round revising that file, then hand back something the next check can inspect. Starting from an empty prompt again would lose the decision that was just made.<\/p>\n\n<p>This also makes the cost breakdown interesting. The job's director work cost $0.81, rounded, for the pick and sign-offs. Senior work was $0.43 and builder work $0.10. The underlying total is $1.3354, which rounds to $1.34. These are recorded list-price costs, not a subscription bill or a measured saving against hiring someone. Most of this particular job's cost went into choosing and reviewing.<\/p>\n<h2>\n  \n  \n  Proof gets the rendered file\n<\/h2>\n\n<p>Each polished file goes through proof before the Creative Director scores it. Proof checks the rendered pixels for text contrast, along with checks for overflow, clipping, safe zones, palette, type scale and required copy. There's no model deciding whether to waive a mechanical failure. A failure goes back to the builder with the screenshot.<\/p>\n\n<p>The launch card passed proof in every round. To see an actual rejection, look at the separate <a href=\"https:\/\/github.com\/adityareddy-dev\/deskstudio\/blob\/4f0affa6b0f004ac7a15bdd6102e52ce7695500c\/evals\/golden\/social-card\/desk-studio-floor\/state.json\" rel=\"noopener noreferrer\">dashboard demo card's state<\/a>. Its first polish failed a safe-zone check: \u201cdeskstudio.ai\u201d sat 32px from the top edge on LinkedIn, while the safe zone started at 38px. The state keeps that note and the failed proof result. The following round passed proof and proceeded to sign-off.<\/p>\n\n<p>That's a small error, though it's exactly the sort of thing I want a check to catch before asking for a judgment on composition. The text being present isn't enough. Where it lands in the rendered output matters. Keeping the failed result also means the final screenshot doesn't erase the work needed to reach it.<\/p>\n<h2>\n  \n  \n  An average can still fail\n<\/h2>\n\n<p>The Creative Director scores hierarchy, typography, spacing, colour, composition, originality, brand fit and copy. The <a href=\"https:\/\/github.com\/adityareddy-dev\/deskstudio\/blob\/4f0affa6b0f004ac7a15bdd6102e52ce7695500c\/skills\/desk\/rubric.md\" rel=\"noopener noreferrer\">visual rubric<\/a> requires every axis to reach 8 and the average to reach 8.5. These are the studio's own evaluations. They aren't independent ratings of design quality.<\/p>\n\n<p>The launch card shows why both conditions matter. Its first round averaged 8.4, with originality at 7. The next round reached an average of 8.5, but originality was still 7, so it failed again. An average alone would have accepted that second round.<\/p>\n\n<p><a href=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4fd9iuafjpa7coulzbco.png\" class=\"article-body-image-wrapper\"><img src=\"https:\/\/media2.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4fd9iuafjpa7coulzbco.png\" alt=\"The signed-off card, round three\" width=\"800\" height=\"418\"><\/a><\/p>\n\n<p>The third round passed at 8.9. Originality reached 8 and the other axes were 9. That is a more useful record than a final score on its own, cause it shows which weakness kept the job open. It also keeps proof separate from taste: every launch-card round passed the mechanical checks, and the first two still failed the design review.<\/p>\n<h2>\n  \n  \n  Try a job you can inspect\n<\/h2>\n\n<p>In Claude Code, install the plugin:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>\/plugin install desk --marketplace adityareddy-dev\/deskstudio\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>In Cursor, Codex, Gemini CLI, Copilot, Windsurf or OpenCode, add it to the project:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight shell\"><code>npx deskstudio add\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Then ask your coding agent for a design in plain words. The installer adds the desk briefs and an instruction block so the agent can run the job. The <a href=\"https:\/\/deskstudio.ai\" rel=\"noopener noreferrer\">gallery<\/a> links the outputs, and the <a href=\"https:\/\/github.com\/adityareddy-dev\/deskstudio\" rel=\"noopener noreferrer\">public repository<\/a> retains the records used here.<\/p>\n\n<p>The API-key paths remain unverified end to end. I wouldn't infer that they work just cause the adapters exist. For a first job, use an output you can judge yourself, read the pick reason, and check the weakest axis against the rendered file before accepting the sign-off.<\/p>\n\n","category":["ai","design","opensource","webdev"]},{"title":"Why the OpenTelemetry browser SDK wouldn't start on Safari 17","pubDate":"Fri, 02 Oct 2026 22:23:11 +0000","link":"https:\/\/dev.to\/adityareddy_dev\/why-the-opentelemetry-browser-sdk-wouldnt-start-on-safari-17-55j5","guid":"https:\/\/dev.to\/adityareddy_dev\/why-the-opentelemetry-browser-sdk-wouldnt-start-on-safari-17-55j5","description":"<p>On September 30 someone filed an issue on the OpenTelemetry browser SDK. <code>startBrowserSdk<\/code> was throwing <code>TypeError: URL.parse is not a function<\/code> on older browsers, so the SDK never started there at all.<\/p>\n\n<p>Nothing caught the error, so an app that started the SDK on load (the issue's example was while rendering a React provider) went down with it. Blank page, in production builds. The issue came with a clean reproduction too (Chromium 125 failed, Chromium 127 started fine), which made it easy to pick up.<\/p>\n\n<p>I went looking and it was one line. The SDK checks the export URL every time it starts, and it did that with <code>URL.parse<\/code>:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code><span class=\"kd\">const<\/span> <span class=\"n\">parsed<\/span> <span class=\"o\">=<\/span> <span class=\"no\">URL<\/span><span class=\"p\">.<\/span><span class=\"nf\">parse<\/span><span class=\"p\">(<\/span><span class=\"n\">url<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>Problem is, <code>URL.parse<\/code> is new. Safari only got it in version 18, Chrome and Firefox in 126, all in 2024. Anyone on Safari 17, which includes iPhones still on iOS 17, or on a Chrome or Firefox older than 126 doesn't have it. The older way, <code>new URL(url)<\/code>, has worked everywhere for years. It throws on a bad URL instead of returning <code>null<\/code> though, which is a big part of why <code>URL.parse<\/code> was added in the first place.<\/p>\n\n<p>So the fix goes back to the try\/catch:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code><span class=\"kd\">let<\/span> <span class=\"n\">parsed<\/span><span class=\"p\">:<\/span> <span class=\"no\">URL<\/span> <span class=\"o\">|<\/span> <span class=\"kc\">null<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">try<\/span> <span class=\"p\">{<\/span>\n  <span class=\"c1\">\/\/ Not `URL.parse`, which Safari &lt; 18 and Chrome\/Firefox &lt; 126 lack.<\/span>\n  <span class=\"n\">parsed<\/span> <span class=\"o\">=<\/span> <span class=\"k\">new<\/span> <span class=\"no\">URL<\/span><span class=\"p\">(<\/span><span class=\"n\">url<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span> <span class=\"k\">catch<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">parsed<\/span> <span class=\"o\">=<\/span> <span class=\"kc\">null<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>A URL that doesn't parse, or isn't http or https, still returns <code>null<\/code> and logs an error like before, and the SDK still refuses to start on it. Other parts of the repo already parsed URLs this way, so it wasn't a new pattern for anyone reviewing it.<\/p>\n\n<p>Testing was the annoying part, cause I didn't have an old Safari lying around. What I did instead was delete <code>URL.parse<\/code> in current Chrome and start the SDK:<br>\n<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight typescript\"><code><span class=\"kd\">const<\/span> <span class=\"n\">urlParse<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">Object<\/span><span class=\"p\">.<\/span><span class=\"nf\">getOwnPropertyDescriptor<\/span><span class=\"p\">(<\/span><span class=\"no\">URL<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'parse'<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n<span class=\"nc\">Reflect<\/span><span class=\"p\">.<\/span><span class=\"nf\">deleteProperty<\/span><span class=\"p\">(<\/span><span class=\"no\">URL<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'parse'<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n\n<span class=\"k\">try<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">browserSdk<\/span> <span class=\"o\">=<\/span> <span class=\"nf\">startBrowserSdk<\/span><span class=\"p\">(<\/span><span class=\"p\">{<\/span> <span class=\"cm\">\/* short batch delay for the test *\/<\/span> <span class=\"p\">}<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n  <span class=\"c1\">\/\/ emit a log and a span, then wait for the export<\/span>\n<span class=\"p\">}<\/span> <span class=\"k\">finally<\/span> <span class=\"p\">{<\/span>\n  <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">urlParse<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n    <span class=\"nb\">Object<\/span><span class=\"p\">.<\/span><span class=\"nf\">defineProperty<\/span><span class=\"p\">(<\/span><span class=\"no\">URL<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'parse'<\/span><span class=\"p\">,<\/span> <span class=\"n\">urlParse<\/span><span class=\"p\">)<\/span><span class=\"p\">;<\/span>\n  <span class=\"p\">}<\/span>\n<span class=\"p\">}<\/span>\n<\/code><\/pre>\n\n<\/div>\n\n\n\n<p>That test failed on main with the exact error from the issue and passed with the fix. I never ran it on a real Safari 17 or Chrome 125, and I said so in the PR.<\/p>\n\n<p>The bit I keep thinking about is why lint didn't catch it. The repo runs eslint-plugin-baseline-js set to <code>available: 'widely'<\/code>, which is there to stop exactly this kind of thing. It let <code>URL.parse<\/code> through cause its data counts <code>URL.parse<\/code> as part of the older <code>url<\/code> feature, and that one has been widely available for a long time. So a method Safari has had for about two years passed the check. I left the lint config alone, it felt like its own conversation.<\/p>\n\n<p>David Luna merged it on October 2.<\/p>\n\n<p>PR: <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-browser\/pull\/447\" rel=\"noopener noreferrer\">https:\/\/github.com\/open-telemetry\/opentelemetry-browser\/pull\/447<\/a><br>\nIssue: <a href=\"https:\/\/github.com\/open-telemetry\/opentelemetry-browser\/issues\/445\" rel=\"noopener noreferrer\">https:\/\/github.com\/open-telemetry\/opentelemetry-browser\/issues\/445<\/a><\/p>\n\n","category":["javascript","opentelemetry","webdev","opensource"]}]}}