SShortSingh.
Back to feed

Holding span.enter() across an await in async Rust mixed up trace IDs between requests

0
·7 views

An engineer investigating logs found that entries from one request sometimes carried another request's trace ID in an async Rust service. The root cause was an axum middleware that held a span.enter() guard across an .await, which keeps the span active while other tasks run on the same thread. The recommended fix is to attach the span to the future with .instrument(span), which enters the span on each poll and exits it on each yield. A test with two interleaved requests on one thread should confirm each log line sits in exactly one correct span, and it should fail when the buggy pattern is reintroduced. The same approach was applied to queue-processing loops, where each message runs in its own span with a late-filled message_id field and early exits converted from continue to return.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingHacker News ·

Pwn.watch Launches Site Tracking Recent Security Breaches

A new website called pwn.watch has been shared on Hacker News, where it is listed as a resource for following security compromises. The submission linked to the site and received five points and one comment from readers. The available source material provides no details about which breaches the site covers or how it collects its information. Further specifics about the platform's scope and methodology are not included in the original post.

0
ProgrammingDEV Community ·

The Lazy Python Tutor: A Chatbot That Answers Coding Questions in Plain Language

A developer has built a Streamlit-based app called The Lazy Python Tutor, aimed at people who want quick answers instead of a full course. Users ask a single question and receive a plain-language explanation along with one small example. The project was submitted to the Hacktoberfest 2026 DEV Challenge and is available as both a live app and open-source code on GitHub. Planned future features include an error-explanation tool for absolute beginners, voice input, and a feature that turns chat history into short recap cards. The creator describes the core goal as complete, with the focus now on possible extensions.

0
ProgrammingDEV Community ·

MagicRemover Explains Why Its AI Eraser Re-renders Entire Photos

A developer of the browser-based AI eraser MagicRemover found that two of its help pages gave conflicting accounts of how edits affect a photo. Tracing the pipeline showed that instruction-based editing regenerates the whole image from a text prompt, so the brushed area is not the only part that changes. The company switched from mask inpainting, which leaves untouched pixels identical to the original, to an instruction-following editor in June, improving shadow handling. Before any upload is sent, images are downscaled to about one megapixel, and a vision-language model labels the marked subjects from a red-filled copy. The post notes that some site copy still described the older behaviour.

0
ProgrammingDEV Community ·

Context-shrinking tool cut AI agent token use 78% but lost two answers

A developer tested Hexum, a hosted MCP server that trims code before sending it to an AI model, against sending full files and against no files. Across 10 questions about open-source Python and TypeScript libraries, the trimmed approach cut tokens sent to the model by a median of 77.7%. Accuracy fell from 9 of 10 with full files to 7 of 10 with Hexum. Analysis of the misses showed the answer files were shown only by bare filename without their folder path, causing the agent to search wrong locations. The author also reported a bug in which repeated requests returned empty views, which the founder fixed within two days.