Feature Request
Motivation
I'm developing a qqbot webhook callback handler targeting WASM (to be ran on Supabase Edge Functions' Runtime), and would like to use tower_http::trace::TraceLayer to enable tracing for my application. However, as some time related APIs from standard library (like std::time::Instant::now()) panics on wasm-unkown-unkown, TraceLayer and some other service couldn't be used in WASM context.
By replacing those time related API calls with WASM compatible ones, we can make this crate more accessible to those who wish to use them in WASM context (for example, worker with axum for Cloudflare Workers and edge computing).
Proposal
We could replace std::time with web-time, and gate this behind a cargo feature (for compatibility and those who don't want wasm stuff). I've tried vibe coding with Copilot and it seems to be working, so this should be a viable solution.
Possible drawback is the user will have to download an extra dependency if they enable full.
If possible, I'm willing to do the implementation myself (I would do it by hand and won't vibe code for the PR of course).
Alternatives
An alternative would be not use tower_http::trace::TraceLayer and instead manually implement the tracing stuff. The drawback is the user would have to write a lot more code to get it working.
I chose the proposed solution because it's relatively simple to implement (web-time should be a drop-in replacement for those APIs) and could make more tower-http services available for WASM (edge computing scenario).
Feature Request
Motivation
I'm developing a qqbot webhook callback handler targeting WASM (to be ran on Supabase Edge Functions' Runtime), and would like to use
tower_http::trace::TraceLayerto enable tracing for my application. However, as some time related APIs from standard library (likestd::time::Instant::now()) panics onwasm-unkown-unkown,TraceLayerand some other service couldn't be used in WASM context.By replacing those time related API calls with WASM compatible ones, we can make this crate more accessible to those who wish to use them in WASM context (for example,
workerwithaxumfor Cloudflare Workers and edge computing).Proposal
We could replace
std::timewithweb-time, and gate this behind a cargo feature (for compatibility and those who don't want wasm stuff). I've tried vibe coding with Copilot and it seems to be working, so this should be a viable solution.Possible drawback is the user will have to download an extra dependency if they enable
full.If possible, I'm willing to do the implementation myself (I would do it by hand and won't vibe code for the PR of course).
Alternatives
An alternative would be not use
tower_http::trace::TraceLayerand instead manually implement the tracing stuff. The drawback is the user would have to write a lot more code to get it working.I chose the proposed solution because it's relatively simple to implement (
web-timeshould be a drop-in replacement for those APIs) and could make moretower-httpservices available for WASM (edge computing scenario).