Skip to content

Commit

Permalink
docs: delete ref of router and indent correctly examples in readme
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Coenen <[email protected]>
  • Loading branch information
bnjjj committed Jan 10, 2022
1 parent b07bec1 commit edfce85
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://raw.githubusercontent.com/apollographql/space-kit/main/src/illustrations/svgs/astronaut1.svg" width="100%" height="144">

# Contributing to Apollo Router
# Contributing to test-span

## Before you contribute!

Expand All @@ -13,7 +13,7 @@ That will allow us to figure out a way to solve the issue together, and possibly
Test-span is written in [Rust]. In order to contribute, you'll need to have Rust installed. To install Rust,
visit [https://www.rust-lang.org/tools/install].

Rust has a build tool and package manager called [`cargo`] that you'll use to interact with the Apollo Router's code.
Rust has a build tool and package manager called [`cargo`] that you'll use to interact with test-span's code.

To build:

Expand Down
80 changes: 40 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A macro and utilities to do snapshot tests on tracing spans.

<p>
<p>
<a href="https://docs.rs/test-span">
<img src="https://docs.rs/test-span/badge.svg" alt="docs">
</a>
Expand All @@ -24,34 +24,34 @@ A macro and utilities to do snapshot tests on tracing spans.
Refer to the [tests](test-span/tests/tests.rs) for a more exhaustive list of features and behaviors:

```rust
use test_span::prelude::*;

#[test_span]
fn a_test() {
do_something();

// test_span provides your with three functions:
let spans = get_spans();
let logs = get_logs();
// you can get both in one call
let (spans, logs) = get_telemetry();

// This plays well with insta snapshots:
insta::assert_json_snapshot!(logs);
insta::assert_json_snapshot!(spans);
}

// Test span plays well with async
#[test_span(tokio::test)]
// you can specify the span / log level you would like to track like this:
#[level(tracing::Level::INFO)]
async fn an_sync_test() {
do_something_async().await;
// You still get access to each function
let spans = get_spans();
let logs = get_logs();
let (spans, logs) = get_telemetry();
}
use test_span::prelude::*;

#[test_span]
fn a_test() {
do_something();

// test_span provides your with three functions:
let spans = get_spans();
let logs = get_logs();
// you can get both in one call
let (spans, logs) = get_telemetry();

// This plays well with insta snapshots:
insta::assert_json_snapshot!(logs);
insta::assert_json_snapshot!(spans);
}

// Test span plays well with async
#[test_span(tokio::test)]
// you can specify the span / log level you would like to track like this:
#[level(tracing::Level::INFO)]
async fn an_sync_test() {
do_something_async().await;
// You still get access to each function
let spans = get_spans();
let logs = get_logs();
let (spans, logs) = get_telemetry();
}
```

## Limitations
Expand All @@ -60,17 +60,17 @@ Spans and logs are hard to track across thread spawns. However we're providing y

```rust
#[test_span]
fn track_across_threads() {
std::thread::spawn(|| {
tracing::info!("will only show up in get_all_logs!");
})
.join()
.unwrap();

// get_all_logs takes a filter Level
let all_logs = test_span::get_all_logs(&tracing::Level::INFO);
assert!(all_logs.contains_message("will only show up in get_all_logs!"));
}
fn track_across_threads() {
std::thread::spawn(|| {
tracing::info!("will only show up in get_all_logs!");
})
.join()
.unwrap();

// get_all_logs takes a filter Level
let all_logs = test_span::get_all_logs(&tracing::Level::INFO);
assert!(all_logs.contains_message("will only show up in get_all_logs!"));
}
```

## Contributing
Expand Down

0 comments on commit edfce85

Please sign in to comment.