clockworklabs / clockworklabs/SpacetimeDB
Bindings `Timestamp::elapsed`: point to `Span` interface in panic message
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
An appealing misuse of the module Timestamp interface is to use it to time reducer execution. It will not work for this; within a reducer invocation, Timestamp::now returns a constant value, the start of the transaction. This is intended behavior and should not change.
Timestamp::elapsed panics when attempting to mis-use that interface in this way. We should expand the panic message to encourage users to use time_span::Span instead.
E.g. we should tell users to rewrite this:
let now = Timestamp::now();
workload();
let elapsed = now.elapsed().as_secs();
into:
use spacetimedb::time_span::Span;
let span = Span::start("My workload");
workload();
span.end();
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the implementation of Timestamp::elapsed and its panic path, then read any surrounding tests or diagnostics. Update the user-facing panic guidance to recommend time_span::Span, and verify that the message clearly points users toward the intended replacement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100