Skip to content

feat: Associate request ids with log lines by using json logs and contextvars#185

Merged
hanchchch merged 9 commits intomainfrom
sanjay/json_logs
Feb 5, 2026
Merged

feat: Associate request ids with log lines by using json logs and contextvars#185
hanchchch merged 9 commits intomainfrom
sanjay/json_logs

Conversation

@sanjayprabhu
Copy link
Contributor

@sanjayprabhu sanjayprabhu commented Dec 13, 2025

For multiplexed apps, we can't associate raw logs/stdout lines with request ids. So, wrap stdout/stderr/log fd with a Json wrapper that writes the line as well as request specific context from contextvars at the agent level. The server then converts it back from json and merges the log level metadata into other metadata before writing it's own json log line.

Fal app PR here fal-ai/fal#740

"message": message,
**self.log_labels,
**self.extra_labels,
**line_labels,
Copy link
Member

Choose a reason for hiding this comment

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

cool

@sanjayprabhu sanjayprabhu marked this pull request as ready for review December 24, 2025 21:07
@efiop
Copy link
Contributor

efiop commented Dec 27, 2025

pls rebase, i've fixed the macos tests.

Copy link
Member

@chamini2 chamini2 left a comment

Choose a reason for hiding this comment

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

thanks!

@linear
Copy link

linear bot commented Feb 3, 2026

Copy link
Contributor Author

@sanjayprabhu sanjayprabhu left a comment

Choose a reason for hiding this comment

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

Nice, good idea. We don't need the ellipsis anymore with this.

@hanchchch hanchchch merged commit 14cadf6 into main Feb 5, 2026
10 checks passed
@hanchchch hanchchch deleted the sanjay/json_logs branch February 5, 2026 03:34
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.

4 participants