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

Add console_without_tokio_unstable to make tokio_unstable assertion optional #446

Merged
merged 2 commits into from Aug 24, 2023

Conversation

ldm0
Copy link
Contributor

@ldm0 ldm0 commented Jul 5, 2023

We add the same trace span in the runtime of our company project as tokio to support tokio-console, but we don't enable the tokio_unstable cfg. Removing this assertion allows us to stop using a forked console-subscriber.

@ldm0 ldm0 requested a review from a team as a code owner July 5, 2023 12:36
@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch from 89d3358 to 3ba6d9e Compare July 6, 2023 04:07
@hds
Copy link
Collaborator

hds commented Jul 7, 2023

@ldm0 I'm concerned that removing this assertion would make the first user experience of using tokio-console and console-subscriber potentially worse (and by a lot). If a new user forgets to enable tokio_unstable or doesn't add it in the right place, then console-subscriber will "fail silently".

Is the reason that you don't wish to build with tokio_unstable that you don't want to enable other unstable APIs in tokio?

Would adding another cfg flag which you could use instead (and that would do nothing else) also solve your issue?

For example, we could add a cfg flag like console_without_tokio_unstable, which would avoid this assertion, but otherwise do nothing - the expectation being that anyone using this flag really know what they're doing.

@ldm0
Copy link
Contributor Author

ldm0 commented Jul 7, 2023

@hds

Is the reason that you don't wish to build with tokio_unstable that you don't want to enable other unstable APIs in tokio?

Exactly, that's one of the reasons. We use a cargo-feature to gate the instrumentations in our runtime, thus enabling tokio_unstable cfg is not necessary.

Introducing less cfg is also important to maintain compilation speed, since adding or removing cfg invalidates all compilation cache.

I'm concerned that removing this assertion would make the first user experience of using tokio-console and console-subscriber potentially worse (and by a lot). If a new user forgets to enable tokio_unstable or doesn't add it in the right place, then console-subscriber will "fail silently".

And yes, first user experience is important.
Would you mind my adding a default cargo-feature like tokio_unstable_assertion: When it's disabled, the assertion check is turned off.
In this way, the tokio_unstable cfg check is on by default, and developers can turn off the assertion manually by turning off the feature.

@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch from 3ba6d9e to 0e6d4cf Compare July 7, 2023 16:48
@ldm0 ldm0 changed the title Remove assertion on cfg tokio_unstable in console-subscriber Add tokio_unstable_assertion to make cfg assertion optional Jul 7, 2023
@hds
Copy link
Collaborator

hds commented Jul 7, 2023

@ldm0 There are additional downsides to using a feature for this instead of a cfg flag.

Some other crate in your dependency graph could enable the feature and you'd miss the warning. Also, once we add a feature, it can't be removed, even if it effectively does nothing in the future, without being a breaking change.

Whereas even if we remove this assertion from the code in the future, it's not a breaking change if the code still compiles and runs as before.

I'm not sure I understand your concern with the cfg flag. Changing a flag does force a recompile, that's true, but it is a one time operation (I don't see a use case where someone would need to regularly turn this flag on and off). From my point of view, that outweighs the negatives of introducing a feature flag for this case.

@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch from 0e6d4cf to 65564d1 Compare July 7, 2023 17:50
@ldm0 ldm0 changed the title Add tokio_unstable_assertion to make cfg assertion optional Add console_without_tokio_unstable to make tokio_unstable assertion optional Jul 7, 2023
@ldm0
Copy link
Contributor Author

ldm0 commented Jul 7, 2023

@hds Okay, cfg is also appropriate though. At least now there is a way to turn off the assertion. :D

@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch 4 times, most recently from e9fbd47 to 531f2ea Compare July 7, 2023 18:15
Copy link
Collaborator

@hds hds left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, I hadn't seen that you pushed changes already. Let's combine the 2 cfg checks.

console-subscriber/src/lib.rs Outdated Show resolved Hide resolved
@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch from 531f2ea to bc754ef Compare July 11, 2023 12:37
@hds
Copy link
Collaborator

hds commented Jul 11, 2023

@hawkw What do you think about this approach to allow people to use console-subscriber without the tokio_unstable cfg flag (because their instrumentation is coming from elsewhere)?

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.

I'm fine with this approach. However, I think that if we're adding this flag, we should also make sure to add it to the documentation as well.

We discuss enabling Tokio's instrumentation in the docs here: https://github.com/tokio-rs/console/blob/main/console-subscriber/README.md#enabling-tokio-instrumentation. We should probably add a new section on using other runtimes that mentions the new cfg option.

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.

let's make sure to add this to the docs, and then i'll be happy to approve it!

@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch from bc754ef to 4c28842 Compare July 13, 2023 21:24
@ldm0
Copy link
Contributor Author

ldm0 commented Jul 13, 2023

Documentation is updated.

console-subscriber/README.md Outdated Show resolved Hide resolved
@ldm0 ldm0 force-pushed the ldm_remove_cfg_assertion branch from 4c28842 to 130d4af Compare July 14, 2023 03:59
@ldm0 ldm0 requested a review from hawkw July 18, 2023 17:52
Copy link
Collaborator

@hds hds left a comment

Choose a reason for hiding this comment

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

Thank you for your change! This looks good to me.

Add cfg `console_without_tokio_unstable` for developers to turn off the
assertion on `tokio_unstable`. This is useful for non-tokio runtimes
which has `tokio-console` support.
@hawkw hawkw merged commit 9c18c4f into tokio-rs:main Aug 24, 2023
12 checks passed
@ldm0 ldm0 deleted the ldm_remove_cfg_assertion branch August 25, 2023 04:03
hawkw pushed a commit that referenced this pull request Sep 29, 2023
Add cfg `console_without_tokio_unstable` for developers to turn off the
assertion on `tokio_unstable`. This is useful for non-tokio runtimes
which has `tokio-console` support.
hawkw added a commit that referenced this pull request Sep 29, 2023
# Changelog

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## console-subscriber-v0.2.0 - (2023-09-29)

[0b0c1af](https://github.com/tokio-rs/console/commit/0b0c1aff18c3260d3a45a78f6c0d6f4206af1cbb)...[0b0c1af](https://github.com/tokio-rs/console/commit/0b0c1aff18c3260d3a45a78f6c0d6f4206af1cbb)

### <a id = "console-subscriber-v0.2.0-breaking"></a>Breaking Changes
- **Update Tonic and Prost dependencies ([#364](#364 ([f9b8e03](https://github.com/tokio-rs/console/commit/f9b8e03bd7ee1d0edb441c94a93a350d5b06ed3b))<br />This commit updates the public dependencies `prost` and `tonic` to
semver-incompatible versions (v0.11.0 and v0.8.0, respectively). This is
a breaking change for users who are integrating the `console-api` protos
with their own `tonic` servers or clients.
- **Update `tonic` to v0.10 and increase MSRV to 1.64 ([#464](#464 ([96e62c8](https://github.com/tokio-rs/console/commit/96e62c83ef959569bb062dc8fee98fa2b2461e8d))<br />This is a breaking change for users of `console-api` and
`console-subscriber`, as it changes the public `tonic` dependency to a
semver-incompatible version. This breaks compatibility with `tonic`
0.9.x and `prost` 0.11.x.

### Added

- [**breaking**](#console-subscriber-v0.2.0-breaking) Update Tonic and Prost dependencies ([#364](#364)) ([f9b8e03](f9b8e03))
- Add support for Unix domain sockets ([#388](#388)) ([a944dbc](a944dbc), closes [#296](#296))
- Add scheduled time per task ([#406](#406)) ([f280df9](f280df9))
- Add task scheduled times histogram ([#409](#409)) ([d92a399](d92a399))
- Update `tonic` to 0.9 ([#420](#420)) ([48af1ee](48af1ee))
- Update MSRV to Rust 1.60.0 ([b18ee47](b18ee47))
- Expose server parts ([#451](#451)) ([e51ac5a](e51ac5a))
- Add cfg `console_without_tokio_unstable` ([#446](#446)) ([7ed6673](7ed6673))
- Add warning for tasks that never yield ([#439](#439)) ([d05fa9e](d05fa9e))
- [**breaking**](#console-subscriber-v0.2.0-breaking) Update `tonic` to v0.10 and increase MSRV to 1.64 ([#464](#464)) ([96e62c8](96e62c8))

### Documented

- Fix unclosed code block ([#463](#463)) ([362bdbe](362bdbe))
- Update MSRV version docs to 1.64 ([#467](#467)) ([94a5a51](94a5a51))

### Fixed

- Fix build on tokio 1.21.0 ([#374](#374)) ([c34ac2d](c34ac2d))
- Fix off-by-one indexing for `callsites` ([#391](#391)) ([43891ab](43891ab))
- Bump minimum Tokio version ([#397](#397)) ([bbb8f25](bbb8f25), fixes [#386](#386))
- Fix self wakes count ([#430](#430)) ([d308935](d308935))
- Remove clock skew warning in `start_poll` ([#434](#434)) ([4a88b28](4a88b28))
- Do not report excessive polling ([#378](#378)) ([#440](#440)) ([8b483bf](8b483bf), closes [#378](#378))
- Correct retain logic ([#447](#447)) ([36ffc51](36ffc51))

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants