Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Features:
- [Docs]
- [Examples]
- [FAQ](#faq)
- [Migrating from tracing](#migrating-from-tokio-tracing)

## Getting Started

Expand Down Expand Up @@ -159,17 +160,18 @@ The concept of 'level' may not be an optimal feature for tracing systems. While

In this context, fastrace offers a more efficient solution by filtering out entire traces that are not of interest through its unique [tail-sampling](https://opentelemetry.io/blog/2022/tail-sampling/) design. Therefore, the concept of 'level', borrowed directly from logging systems, may not be suitable for fastrace.

### Will fastrace support OpenTelemetry feature 'X'?
## Migrating from tokio-tracing

fastrace is focused on high performance tracing only. You can open an issue for the missing tracing features you want to have.
If you're using the [tokio-tracing](https://github.com/tokio-rs/tracing) ecosystem and want to switch to fastrace for better performance, you can use [fastrace-tracing](https://github.com/fast/fastrace-tracing) to make the transition easier.

Note that we always prioritize performance over features, so that not all tracing feature requests may be accepted.
The `fastrace-tracing` crate provides a compatibility layer that lets you capture spans from libraries instrumented with `tokio-tracing` in two lines of code:

### What's the status of this library?

**API Unstable**: The API is not stabilized yet, may be changed in the future.
```rust
let subscriber = tracing_subscriber::Registry::default().with(fastrace_tracing::FastraceCompatLayer::new());
tracing::subscriber::set_global_default(subscriber).unwrap();
```

**Code base Tested**: fastrace has been tested with high coverage. However, applications utilizing fastrace have not been widely deployed, so that fastrace is currently **NOT** regarded as battle-tested.
For more details, refer to the [fastrace-tracing documentation](https://docs.rs/fastrace-tracing).

[Docs]: https://docs.rs/fastrace/
[Examples]: https://github.com/fast/fastrace/tree/main/fastrace/examples
Expand Down
9 changes: 8 additions & 1 deletion fastrace/src/collector/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl SpanId {
SpanId(rand::random())
}

// TODO: consider using `random()`.
#[inline]
/// Create a non-zero `SpanId`
pub(crate) fn next_id() -> SpanId {
Expand Down Expand Up @@ -128,7 +129,7 @@ impl<'de> serde::Deserialize<'de> for SpanId {
///
/// [`TraceId`]: crate::collector::TraceId
/// [`SpanId`]: crate::collector::SpanId
#[derive(Clone, Copy, Debug, Default)]
#[derive(Clone, Copy, Debug)]
pub struct SpanContext {
pub trace_id: TraceId,
pub span_id: SpanId,
Expand Down Expand Up @@ -328,6 +329,12 @@ impl SpanContext {
}
}

impl Default for SpanContext {
fn default() -> Self {
Self::random()
}
}

#[cfg(test)]
mod tests {
use std::collections::HashSet;
Expand Down
Loading