Skip to content
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

a bunch more backports #1381

Merged
merged 7 commits into from
Apr 30, 2021
Merged

a bunch more backports #1381

merged 7 commits into from
Apr 30, 2021

Commits on Apr 30, 2021

  1. chore: fix cargo docs warnings (#1362)

    This PR simply fixes some cargo docs warnings.
    Folyd authored and hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    3c58127 View commit details
    Browse the repository at this point in the history
  2. subscriber: support special chars in span names (#1368)

    Filtering log events using the `target[span{field=value}]=level` syntax
    doesn't work when the span name contains a special char.
    
    This PR closes #1367 by adding support for span names with any
    characters other than `{` and `]` to `EnvFilter`.
    
    Co-authored-by: Eliza Weisman <eliza@buoyant.io>
    aym-v and hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    e2eb189 View commit details
    Browse the repository at this point in the history
  3. core: add Subscriber impl for Box<dyn Subscriber + ...> (#1358)

    In some cases, users may wish to erase the type of a `Subscriber`
    implementation, such as when it is dynamically constructed from a
    complex parameterized type. When doing so, it's important to ensure that
    all trait methods with default implementations are properly forwarded to
    the inner erased type. For example, if the type does not implement
    `try_close`, but the inner erased subscriber does, then the the
    subscriber will not be notified when spans close — which could result in
    a memory leak.
    
    To avoid potential footguns resulting from users implementing
    type-erased subscribers incorrectly, this branch adds a new `impl
    Subscriber for Box<dyn Subscriber + Send + Sync + 'static>` in
    `tracing-core`. This is also somewhat more ergonomic than any solution
    in another crate, since the implementation  is for `Box<dyn Subscriber +
    ...>` directly, rather than some `BoxedSubscriber` newtype.
    hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    1316eaf View commit details
    Browse the repository at this point in the history
  4. tracing: add an example of tracing in a panic hook (#1375)

    It turns out that when using the global dispatcher, emitting tracing
    events in a panic hook will capture the span in which the program
    panicked. This is very handy for debugging panics! Thanks a lot to
    @nate_mara for pointing this out to me on twitter --- I hadn't even
    thought of it!
    
    Since it isn't necessarily immediately obvious that this works, I
    thought it would be nice to add an example.
    hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    a94767a View commit details
    Browse the repository at this point in the history
  5. core: add support for Arc<dyn Subscriber + ...>

    ## Motivation (#1374)
    
    Users may wish to erase the type of a `Subscriber`
    implementation, such as when it is dynamically constructed from a
    complex parameterized type. PR #1358 added a `Subscriber` implementation
    for `Box<dyn Subscriber + Send + Sync + 'static>`, allowing the use of
    type-erased trait objects. In some cases, it may also be useful to share
    a type-erased subscriber, _without_ using `Dispatch` --- such as when
    different sets of `tracing-subscriber` subscribers are layered on one
    shared subscriber.
    
    ## Solution
    
    This branch builds on #1358 by adding an `impl Subscriber for Arc<dyn
    Subscriber + Send + Sync + 'static>`. I also added quick tests for both
    `Arc`ed and `Box`ed subscribers.
    
    Signed-off-by: Eliza Weisman <eliza@buoyant.io>
    hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    5f68c71 View commit details
    Browse the repository at this point in the history
  6. tracing: impl From<EnteredSpan> for Option<Id> (#1325)

    ## Motivation
    
    <!--
    Explain the context and why you're making that change. What is the problem
    you're trying to solve? If a new feature is being added, describe the intended
    use case that feature fulfills.
    -->
    
    The following code compiles failed:
    ```rust
    use tracing;
    
    fn main() {
    
        let span = tracing::info_span!("my_span").entered();
        tracing::info!(parent: &span, "test span");
    }
    ```
    
    ```log
       Compiling playground v0.0.1 (/playground)
    error[E0277]: the trait bound `Option<Id>: From<&EnteredSpan>` is not satisfied
      --> src/main.rs:6:5
       |
    6  |     tracing::info!(parent: &span, "test span");
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<&EnteredSpan>` is not implemented for `Option<Id>`
    ```
    
    ## Solution
    
    - `impl<'a> From<&'a EnteredSpan> for Option<&'a Id>`.
    - `impl<'a> From<&'a EnteredSpan> for Option<Id>`
    - Add `id()` method into `EnteredSpan`.
    
    Co-authored-by: Eliza Weisman <eliza@buoyant.io>
    Folyd and hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    4946123 View commit details
    Browse the repository at this point in the history
  7. docs: document span.in_scope() at top-level (#1344)

    ## Motivation
    
    `span.in_scope()` had a link def in the main tracing docs which was
    unused, this function is quite handy to know about and I almost
    re-implemented something similar to it.
    
    I almost reimplemented this as a macro.
    
    
    ## Solution
    
    Document it at top-level!
    
    Co-authored-by: Eliza Weisman <eliza@buoyant.io>
    Fishrock123 and hawkw committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    d4493a8 View commit details
    Browse the repository at this point in the history