Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tracing-appender: Introduce weekly rotation#3218

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

NickCaplinger
Copy link
Contributor

Motivation

While configuring tracing-appender, I wanted to specify a weekly log rotation interval. I was unable to do so, as the largest rotation interval was daily.

Solution

Before my introduction of weekly log rotation, rounding the currentOffsetDateTime was straightforward: we could simply keep the current date and truncate part or all of the time component. However, we cannot simply truncate the time with weekly rotation; the date must now be modified.

To round the date, I take its ordinal (how many days have passed since the start of the year) and round it backwards to the nearest 7 day period. This gives us consistent date-times that only change weekly.

dileping and toluRV reacted with thumbs up emoji
@NickCaplingerNickCaplinger requested a review froma team as acode ownerFebruary 17, 2025 19:34
Copy link
Contributor

@hdshds 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 PR!

In general this looks good. However, I think that we should reconsider the way we pick the beginning of the week (see comment).

@NickCaplingerNickCaplinger requested a review fromhdsMay 22, 2025 19:12
Copy link
Contributor

@hdshds left a comment

Choose a reason for hiding this comment

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

Looks good. I think this scheme makes more sense.

One last thing is that I think we should clarify whether it's the start of Sunday UTC or local time.

Thanks!

@NickCaplingerNickCaplinger requested a review fromhdsMay 23, 2025 16:53
Copy link
Contributor

@hdshds left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

CI is failing, but I think this branch just needsmaster merged in to fix that.

@NickCaplinger
Copy link
ContributorAuthor

I mergedmaster into this branch, but I'm still seeing CI failures:

8:40:06 AM: error: unexpected `cfg` condition name: `unsound_local_offset`8:40:06 AM:   --> tracing-subscriber/src/fmt/time/time_crate.rs:27:178:40:06 AM:    |8:40:06 AM: 27 |     doc(cfg(all(unsound_local_offset, feature = "time", feature = "local-time")))8:40:06 AM:    |                 ^^^^^^^^^^^^^^^^^^^^8:40:06 AM:    |8:40:06 AM:    = help: expected names are: `docsrs`, `feature`, `flaky_tests`, `test`, and `tracing_unstable` and 31 more8:40:06 AM:    = help: consider using a Cargo feature instead8:40:06 AM:    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:8:40:06 AM:             [lints.rust]8:40:06 AM:             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(unsound_local_offset)'] }8:40:06 AM:    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(unsound_local_offset)");` to the top of the `build.rs`8:40:06 AM:    = note: see <[https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html&gt;](https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html%3E) for more information about checking conditional configuration8:40:06 AM:    = note: `-D unexpected-cfgs` implied by `-D warnings`8:40:06 AM:    = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]`8:40:06 AM: error: unexpected `cfg` condition name: `unsound_local_offset`8:40:06 AM:   --> tracing-subscriber/src/fmt/time/mod.rs:16:328:40:06 AM:    |8:40:06 AM: 16 | #[cfg_attr(docsrs, doc(cfg(all(unsound_local_offset, feature = "local-time"))))]8:40:06 AM:    |                                ^^^^^^^^^^^^^^^^^^^^8:40:06 AM:    |8:40:06 AM:    = help: consider using a Cargo feature instead8:40:06 AM:    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:8:40:06 AM:             [lints.rust]8:40:06 AM:             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(unsound_local_offset)'] }8:40:06 AM:    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(unsound_local_offset)");` to the top of the `build.rs`8:40:06 AM:    = note: see <[https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html&gt;](https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html%3E) for more information about checking conditional configuration

This appears to be unrelated to my change. For what it's worth,#3237 is an open PR that mentions this problem. How should we proceed?

@hds
Copy link
Contributor

hds commentedMay 30, 2025

I've created a separate PR to fix these issues#3292, once that's merged you can pull in the latest changes and this PR should go green too.

NickCaplinger reacted with rocket emoji

@hdshds merged commitd81a69e intotokio-rs:masterMay 30, 2025
56 checks passed
@NickCaplinger
Copy link
ContributorAuthor

Thank you, Hayden! Have a great weekend

@hdshds mentioned this pull requestJun 2, 2025
25 tasks
hds pushed a commit that referenced this pull requestJun 2, 2025
## MotivationWhile configuring tracing-appender, I wanted to specify a weekly logrotation interval. I was unable to do so, as the largest rotationinterval was daily.## SolutionBefore my introduction of weekly log rotation, rounding the current`OffsetDateTime` was straightforward: we could simply keep the currentdate and truncate part or all of the time component. However, we cannotsimply truncate the time with weekly rotation; the date must now bemodified.To round the date, we roll logs at 00:00 UTC on Sunday. This gives usconsistent date-times that only change weekly.
hds pushed a commit that referenced this pull requestJun 2, 2025
## MotivationWhile configuring tracing-appender, I wanted to specify a weekly logrotation interval. I was unable to do so, as the largest rotationinterval was daily.## SolutionBefore my introduction of weekly log rotation, rounding the current`OffsetDateTime` was straightforward: we could simply keep the currentdate and truncate part or all of the time component. However, we cannotsimply truncate the time with weekly rotation; the date must now bemodified.To round the date, we roll logs at 00:00 UTC on Sunday. This gives usconsistent date-times that only change weekly.
hds pushed a commit that referenced this pull requestJun 3, 2025
## MotivationWhile configuring tracing-appender, I wanted to specify a weekly logrotation interval. I was unable to do so, as the largest rotationinterval was daily.## SolutionBefore my introduction of weekly log rotation, rounding the current`OffsetDateTime` was straightforward: we could simply keep the currentdate and truncate part or all of the time component. However, we cannotsimply truncate the time with weekly rotation; the date must now bemodified.To round the date, we roll logs at 00:00 UTC on Sunday. This gives usconsistent date-times that only change weekly.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@hdshdshds approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@NickCaplinger@hds

[8]ページ先頭

©2009-2025 Movatter.jp