-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Motivation I was attempting to use this library with a wasm target in a browser. If you call `std::time::{Instant, SystemTime}::now` in a wasm target, it will panic at runtime. This library makes use of both `::now()` calls, which will result in a panic when attempting to record a trace. ## Solution In the library that this library calls (`opentelemetry-api`), this is resolved by replacing calls to `SystemTime::now()` with an implementation that returns a `SystemTime` constructed from `js_sys::Date`. To preserve the ability to pass `SystemTime`-typed args to `opentelemetry_api` methods, I just added the same mechanism to this library. Because `Instant` is never used in `opentelemetry_api`, we can instead replace the implementation entirely with the api-compatible "polyfill" from `web_time`. All of these changes are behind `cfg` and automatically enabled when building for `wasm32` targets, so this will not change any behavior/performance when built for other targets.
- Loading branch information
1 parent
6149863
commit 80ae321
Showing
3 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters