-
Notifications
You must be signed in to change notification settings - Fork 434
Add tracing support #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mihai-dinculescu
wants to merge
56
commits into
graphql-rust:master
Choose a base branch
from
mihai-dinculescu:add_tracing_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add tracing support #720
Changes from 2 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
e0f7eb5
Add tracing support
mihai-dinculescu 419520d
Merge branch 'master' into add_tracing_support
LegNeato c1f9e5f
Merge branch 'master' into add_tracing_support
LegNeato 753c80f
Rocket can now compile on stable
LegNeato c599bae
Remove `boxed` in favor of `pin`.
LegNeato b556934
Add tracing support example
LegNeato 0134da3
Add some coarse execution tracing
LegNeato 5c888a8
Remove old comment / docs
LegNeato ef2da9b
Merge branch 'master' into add_tracing_support
LegNeato 01b3453
Fix book tests
LegNeato 7ac7304
fix up some imports
LegNeato 06687dd
Add back subscriber Cargo.toml instructions
LegNeato 697a743
Change trace errors to trace
mihai-dinculescu f2977d5
Tracing unit tests
mihai-dinculescu 6c3654c
Tracing unit tests names
mihai-dinculescu 7f746de
Revert "Rocket can now compile on stable"
LegNeato 64cad08
Merge branch 'master' into add_tracing_support
LegNeato d7acba9
Merge branch 'master' into add_tracing_support
LegNeato 88dc9c4
Fix tracing spans
LegNeato 8a2f6ec
Do not include trailing newline on the last error
LegNeato 83fd44d
Standard tracing labels on snake_case
LegNeato c92dd87
Add a validation error case to the tracing example
LegNeato 64d8e11
Use $crate everywhere
LegNeato cdbc0ce
Add other levels to span macros
LegNeato 65ab688
Merge branch 'master' into add_tracing_support
LegNeato 6cf48d9
Merge branch 'master' into add_tracing_support
LegNeato 5f8a4ca
Merge branch 'master' into add_tracing_support
LegNeato ae1054e
Merge branch 'master' into add_tracing_support
LegNeato 5938345
Use the released tracing crate
mihai-dinculescu 8bc07f6
Fix email address
LegNeato 82497d3
Standardize on snake case for tracing
LegNeato 79102a3
Add tracing support
mihai-dinculescu 6a16cf8
Rocket can now compile on stable
LegNeato 11bb5e2
Add tracing support example
LegNeato 57ecb56
Add some coarse execution tracing
LegNeato cff6678
Remove old comment / docs
LegNeato cb3ee27
Fix book tests
LegNeato 0d52c50
fix up some imports
LegNeato 7f24509
Add back subscriber Cargo.toml instructions
LegNeato cb7ab0c
Change trace errors to trace
mihai-dinculescu 7b02ccc
Tracing unit tests
mihai-dinculescu 4000f1e
Tracing unit tests names
mihai-dinculescu e968c4b
Revert "Rocket can now compile on stable"
LegNeato 58fed76
Fix tracing spans
LegNeato 7b5ad7e
Do not include trailing newline on the last error
LegNeato c34a1c2
Standard tracing labels on snake_case
LegNeato 26407e2
Add a validation error case to the tracing example
LegNeato 94279d1
Use $crate everywhere
LegNeato bf35077
Add other levels to span macros
LegNeato 2365016
Use the released tracing crate
mihai-dinculescu ca744b5
Fix email address
LegNeato 62acd3f
Standardize on snake case for tracing
LegNeato 4d7797a
Merge master
LegNeato 72a28d4
Remove rustfmt option causing breakage
LegNeato 2977b1f
Remove subscription helper mod
LegNeato 264030f
Merge branch 'master' into add_tracing_support
LegNeato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Tracing | ||
|
||
Juniper relies on the [tracing](https://crates.io/crates/tracing) crate for instrumentation. | ||
|
||
!FILENAME Cargo.toml | ||
|
||
```toml | ||
[dependencies] | ||
tracing = "0.1.17" | ||
tracing-subscriber = "0.2.9" | ||
tracing-log = "0.1.1" | ||
``` | ||
|
||
## Usage | ||
|
||
```rust | ||
# extern crate tracing; | ||
# extern crate tracing_subscriber; | ||
# extern crate tracing_log; | ||
fn main() { | ||
// compatibility with the log crate (unstable) | ||
// converts all log records into tracing events | ||
tracing_log::LogTracer::init().expect("LogTracer init failed"); | ||
|
||
// a builder for `FmtSubscriber`. | ||
let subscriber = tracing_subscriber::FmtSubscriber::builder() | ||
// all spans/events with a level higher than TRACE | ||
// (e.g, debug, info, warn, etc.) will be written to stdout. | ||
.with_max_level(tracing::Level::TRACE) | ||
// completes the builder. | ||
.finish(); | ||
|
||
tracing::subscriber::set_global_default(subscriber) | ||
.expect("Setting default tracing subscriber failed"); | ||
|
||
// ... | ||
} | ||
``` |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ mod interface; | |
mod tests; | ||
|
||
pub mod subscription_helpers; | ||
|
||
mod tracing; |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __juniper_trace_internal { | ||
($trace_type:ident; $($element:expr),*) => {{ | ||
#[cfg(feature = "tracing")] | ||
tracing::$trace_type!($($element),*); | ||
}}; | ||
} | ||
|
||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __juniper_trace { | ||
($($element:expr),*) => {{ | ||
$crate::__juniper_trace_internal!(trace; $($element),*) | ||
}}; | ||
} | ||
|
||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __juniper_trace_debug { | ||
($($element:expr),*) => {{ | ||
$crate::__juniper_trace_internal!(debug; $($element),*) | ||
}}; | ||
} | ||
|
||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __juniper_trace_info { | ||
($($element:expr),*) => {{ | ||
$crate::__juniper_trace_internal!(info; $($element),*) | ||
}}; | ||
} | ||
|
||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __juniper_trace_warn { | ||
($($element:expr),*) => {{ | ||
$crate::__juniper_trace_internal!(warn; $($element),*) | ||
}}; | ||
} | ||
|
||
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! __juniper_trace_error { | ||
($($element:expr),*) => {{ | ||
$crate::__juniper_trace_internal!(error; $($element),*) | ||
}}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.