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

attributes: permit setting parent span via #[instrument(parent = …)] #2091

Merged
merged 5 commits into from
Apr 25, 2022

Conversation

jswrenn
Copy link
Contributor

@jswrenn jswrenn commented Apr 25, 2022

This PR extends the #[instrument] attribute to accept an optionally parent = … argument that provides an explicit parent to the generated Span.

Motivation

This PR resolves #2021 and partially resolves #879. (It only partly resolves #879 in that it only provides a mechanism for specifying an explicit parent, but not for invoking follows_from.)

Solution

This PR follows the implementation strategy articulated by @hawkw: #879 (comment). The user-provided value to the parent argument may be any expression, and this expression is provided directly to the invocation of span!.

@jswrenn jswrenn requested review from hawkw, davidbarsky and a team as code owners April 25, 2022 17:21
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this looks great to me! i had one minor documentation suggestion, but besides that, this looks ready to merge!

tracing-attributes/src/lib.rs Show resolved Hide resolved
Adds an example where the `parent` comes from a struct's field.
Modifies the integration tests of `#[instrument(parent = …)]` to ensure
that type of `parent` is at least as restrictive as that of the `parent`
argument of `Span::child_of`.
@hawkw hawkw enabled auto-merge (squash) April 25, 2022 21:36
@hawkw hawkw merged commit 92ec839 into tokio-rs:master Apr 25, 2022
hawkw pushed a commit that referenced this pull request Apr 26, 2022
#2091)

This PR extends the `#[instrument]` attribute to accept an optionally
`parent = …` argument that provides an explicit parent to the generated
`Span`.

## Motivation

This PR resolves #2021 and partially resolves #879. (It only partly
resolves #879 in that it only provides a mechanism for specifying an
explicit parent, but *not* for invoking `follows_from`.)

## Solution

This PR follows the implementation strategy articulated by @hawkw:
#879 (comment).
The user-provided value to the `parent` argument may be any expression,
and this expression is provided directly to the invocation of
[`span!`](https://tracing.rs/tracing/macro.span.html).
hawkw pushed a commit that referenced this pull request Apr 26, 2022
#2091)

This PR extends the `#[instrument]` attribute to accept an optionally
`parent = …` argument that provides an explicit parent to the generated
`Span`.

## Motivation

This PR resolves #2021 and partially resolves #879. (It only partly
resolves #879 in that it only provides a mechanism for specifying an
explicit parent, but *not* for invoking `follows_from`.)

## Solution

This PR follows the implementation strategy articulated by @hawkw:
#879 (comment).
The user-provided value to the `parent` argument may be any expression,
and this expression is provided directly to the invocation of
[`span!`](https://tracing.rs/tracing/macro.span.html).
hawkw pushed a commit that referenced this pull request Apr 26, 2022
#2091)

This PR extends the `#[instrument]` attribute to accept an optionally
`parent = …` argument that provides an explicit parent to the generated
`Span`.

## Motivation

This PR resolves #2021 and partially resolves #879. (It only partly
resolves #879 in that it only provides a mechanism for specifying an
explicit parent, but *not* for invoking `follows_from`.)

## Solution

This PR follows the implementation strategy articulated by @hawkw:
#879 (comment).
The user-provided value to the `parent` argument may be any expression,
and this expression is provided directly to the invocation of
[`span!`](https://tracing.rs/tracing/macro.span.html).
hawkw pushed a commit that referenced this pull request Apr 26, 2022
#2091)

This PR extends the `#[instrument]` attribute to accept an optionally
`parent = …` argument that provides an explicit parent to the generated
`Span`.

## Motivation

This PR resolves #2021 and partially resolves #879. (It only partly
resolves #879 in that it only provides a mechanism for specifying an
explicit parent, but *not* for invoking `follows_from`.)

## Solution

This PR follows the implementation strategy articulated by @hawkw:
#879 (comment).
The user-provided value to the `parent` argument may be any expression,
and this expression is provided directly to the invocation of
[`span!`](https://tracing.rs/tracing/macro.span.html).
hawkw added a commit that referenced this pull request Apr 26, 2022
# 0.1.21 (April 26, 2022)

This release adds support for setting explicit parent and follows-from
spans in the `#[instrument]` attribute.

### Added

- `#[instrument(follows_from = ...)]` argument for setting one or more
  follows-from span ([#2093])
- `#[instrument(parent = ...)]` argument for overriding the generated
  span's parent ([#2091])

### Fixed

- Extra braces around `async` blocks in expanded code (causes a Clippy
  warning) ([#2090])
- Broken documentation links ([#2068], [#2077])

Thanks to @jarrodldavis, @ben0x539, and new contributor @jswrenn for
contributing to this release!

[#2093]: #2093
[#2091]: #2091
[#2090]: #2090
[#2077]: #2077
[#2068]: #2068
hawkw added a commit that referenced this pull request Apr 27, 2022
# 0.1.21 (April 26, 2022)

This release adds support for setting explicit parent and follows-from
spans in the `#[instrument]` attribute.

### Added

- `#[instrument(follows_from = ...)]` argument for setting one or more
  follows-from span ([#2093])
- `#[instrument(parent = ...)]` argument for overriding the generated
  span's parent ([#2091])

### Fixed

- Extra braces around `async` blocks in expanded code (causes a Clippy
  warning) ([#2090])
- Broken documentation links ([#2068], [#2077])

Thanks to @jarrodldavis, @ben0x539, and new contributor @jswrenn for
contributing to this release!

[#2093]: #2093
[#2091]: #2091
[#2090]: #2090
[#2077]: #2077
[#2068]: #2068
kaffarell pushed a commit to kaffarell/tracing that referenced this pull request May 22, 2024
# 0.1.21 (April 26, 2022)

This release adds support for setting explicit parent and follows-from
spans in the `#[instrument]` attribute.

### Added

- `#[instrument(follows_from = ...)]` argument for setting one or more
  follows-from span ([tokio-rs#2093])
- `#[instrument(parent = ...)]` argument for overriding the generated
  span's parent ([tokio-rs#2091])

### Fixed

- Extra braces around `async` blocks in expanded code (causes a Clippy
  warning) ([tokio-rs#2090])
- Broken documentation links ([tokio-rs#2068], [tokio-rs#2077])

Thanks to @jarrodldavis, @ben0x539, and new contributor @jswrenn for
contributing to this release!

[tokio-rs#2093]: tokio-rs#2093
[tokio-rs#2091]: tokio-rs#2091
[tokio-rs#2090]: tokio-rs#2090
[tokio-rs#2077]: tokio-rs#2077
[tokio-rs#2068]: tokio-rs#2068
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants