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

SKUs: log the return value of top level functions called from C++ #21543

Merged
merged 6 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ where
}
}

#[instrument]
#[instrument(err(level = Level::WARN), ret)]
pub async fn fetch_order_credentials(&self, order_id: &str) -> Result<(), SkusError> {
let order = match self.client.get_order(order_id).await {
Ok(Some(order)) => order,
Expand Down
4 changes: 2 additions & 2 deletions components/skus/browser/rs/lib/src/sdk/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod fetch;
mod present;

use chrono::{NaiveDateTime, Utc};
use tracing::{debug, instrument};
use tracing::{debug, instrument, Level};

use crate::errors::{InternalError, SkusError};
use crate::models::*;
Expand Down Expand Up @@ -201,7 +201,7 @@ where
.and_then(|creds| creds.creds.into_iter().last()))
}

#[instrument]
#[instrument(err(level = Level::WARN), ret)]
pub async fn matching_credential_summary(
&self,
domain: &str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use http::uri;
use serde::{Deserialize, Serialize};
use serde_json::json;
use sha2::Sha512;
use tracing::instrument;
use tracing::{instrument, Level};

use crate::errors::{InternalError, SkusError};
use crate::models::*;
Expand Down Expand Up @@ -212,7 +212,7 @@ where
Ok(None)
}

#[instrument]
#[instrument(err(level = Level::WARN), ret)]
pub async fn prepare_credentials_presentation(
&self,
domain: &str,
Expand Down
4 changes: 2 additions & 2 deletions components/skus/browser/rs/lib/src/sdk/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ where
Ok(order)
}

#[instrument]
#[instrument(err(level = Level::WARN), ret)]
// submit_receipt allows for order proof of payment
pub async fn submit_receipt(&self, order_id: &str, receipt: &str) -> Result<(), InternalError> {
event!(Level::DEBUG, order_id = order_id, "submit_receipt called");
Expand Down Expand Up @@ -272,7 +272,7 @@ where
Ok(())
}

#[instrument]
#[instrument(err(level = Level::WARN), ret)]
pub async fn refresh_order(&self, order_id: &str) -> Result<Order, SkusError> {
event!(Level::DEBUG, order_id = order_id, "refresh_order called",);
let order = self.fetch_order(order_id).await?;
Expand Down
10 changes: 10 additions & 0 deletions patches/third_party-rust-syn-v2-BUILD.gn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/third_party/rust/syn/v2/BUILD.gn b/third_party/rust/syn/v2/BUILD.gn
index 366a62ad89662f02f700f30ffc73532daa0e5f91..76c62810a1a5e929203e1901ffecfb23dbf13c1d 100644
--- a/third_party/rust/syn/v2/BUILD.gn
+++ b/third_party/rust/syn/v2/BUILD.gn
@@ -132,4 +132,5 @@ cargo_crate("lib") {
"proc-macro",
"quote",
]
+ features += [ "extra-traits", "visit", "visit-mut" ]
}
9 changes: 4 additions & 5 deletions third_party/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions third_party/rust/tracing/v0_1/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ cargo_crate("lib") {
"//brave/third_party/rust/tracing/v0_1/crate/tests/filters_are_reevaluated_for_different_call_sites.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/filters_dont_leak.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/future_send.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/instrument.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/macro_imports.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/macros.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/macros_incompatible_concat.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/macros_redefined_core.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/max_level_hint.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/multiple_max_level_hints.rs",
"//brave/third_party/rust/tracing/v0_1/crate/tests/no_subscriber.rs",
Expand All @@ -56,7 +56,7 @@ cargo_crate("lib") {
# Unit tests skipped. Generate with --with-tests to include them.
build_native_rust_unit_tests = false
edition = "2018"
cargo_pkg_version = "0.1.37"
cargo_pkg_version = "0.1.40"
cargo_pkg_authors =
"Eliza Weisman <[email protected]>, Tokio Contributors <[email protected]>"
cargo_pkg_name = "tracing"
Expand All @@ -69,7 +69,6 @@ cargo_crate("lib") {
"//brave/third_party/rust/pin_project_lite/v0_2:lib",
"//brave/third_party/rust/tracing_attributes/v0_1:lib",
"//brave/third_party/rust/tracing_core/v0_1:lib",
"//third_party/rust/cfg_if/v1:lib",
]
features = [
"attributes",
Expand Down
8 changes: 5 additions & 3 deletions third_party/rust/tracing/v0_1/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Name: tracing
URL: https://crates.io/crates/tracing
Description: Application-level tracing for Rust.

Version: 0.1.37
Security Critical: yes
Version: 0.1.40
Security Critical: no
Shipped: yes
License: MIT
Revision: 8e35927d7ef5bad3b20fd53592ddb951ae7bec91
License File:
Revision: 15600a3a67c418f53cb80ff21da57d89a5de0486
2 changes: 1 addition & 1 deletion third_party/rust/tracing/v0_1/crate/.cargo_vcs_info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"git": {
"sha1": "8e35927d7ef5bad3b20fd53592ddb951ae7bec91"
"sha1": "15600a3a67c418f53cb80ff21da57d89a5de0486"
},
"path_in_vcs": "tracing"
}
135 changes: 135 additions & 0 deletions third_party/rust/tracing/v0_1/crate/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,138 @@
# 0.1.40

This release fixes a potential stack use-after-free in the
`Instrument::into_inner` method. Only uses of this method are affected by this
bug.

### Fixed

- Use `mem::ManuallyDrop` instead of `mem::forget` in `Instrument::into_inner`
([#2765])

[#2765]: https:/tokio-rs/tracing/pull/2765

Thanks to @cramertj and @manishearth for finding and fixing this issue!

# 0.1.39 (October 12, 2023)

This release adds several additional features to the `tracing` macros. In
addition, it updates the `tracing-core` dependency to [v0.1.32][core-0.1.32] and
the `tracing-attributes` dependency to [v0.1.27][attrs-0.1.27].

### Added

- Allow constant field names in macros ([#2617])
- Allow setting event names in macros ([#2699])
- **core**: Allow `ValueSet`s of any length ([#2508])

### Changed

- `tracing-attributes`: updated to [0.1.27][attrs-0.1.27]
- `tracing-core`: updated to [0.1.32][core-0.1.32]
- **attributes**: Bump minimum version of proc-macro2 to 1.0.60 ([#2732])
- **attributes**: Generate less dead code for async block return type hint ([#2709])

### Fixed

- Use fully qualified names in macros for items exported from std prelude
([#2621], [#2757])
- **attributes**: Allow [`clippy::let_with_type_underscore`] in macro-generated
code ([#2609])
- **attributes**: Allow `unknown_lints` in macro-generated code ([#2626])
- **attributes**: Fix a compilation error in `#[instrument]` when the `"log"`
feature is enabled ([#2599])

### Documented

- Add `axum-insights` to relevant crates. ([#2713])
- Fix link to RAI pattern crate documentation ([#2612])
- Fix docs typos and warnings ([#2581])
- Add `clippy-tracing` to related crates ([#2628])
- Add `tracing-cloudwatch` to related crates ([#2667])
- Fix deadlink to `tracing-etw` repo ([#2602])

[#2617]: https:/tokio-rs/tracing/pull/2617
[#2699]: https:/tokio-rs/tracing/pull/2699
[#2508]: https:/tokio-rs/tracing/pull/2508
[#2621]: https:/tokio-rs/tracing/pull/2621
[#2713]: https:/tokio-rs/tracing/pull/2713
[#2581]: https:/tokio-rs/tracing/pull/2581
[#2628]: https:/tokio-rs/tracing/pull/2628
[#2667]: https:/tokio-rs/tracing/pull/2667
[#2602]: https:/tokio-rs/tracing/pull/2602
[#2626]: https:/tokio-rs/tracing/pull/2626
[#2757]: https:/tokio-rs/tracing/pull/2757
[#2732]: https:/tokio-rs/tracing/pull/2732
[#2709]: https:/tokio-rs/tracing/pull/2709
[#2599]: https:/tokio-rs/tracing/pull/2599
[`let_with_type_underscore`]: http://rust-lang.github.io/rust-clippy/rust-1.70.0/index.html#let_with_type_underscore
[attrs-0.1.27]:
https:/tokio-rs/tracing/releases/tag/tracing-attributes-0.1.27
[core-0.1.32]:
https:/tokio-rs/tracing/releases/tag/tracing-core-0.1.32

# 0.1.38 (April 25th, 2023)

This `tracing` release changes the `Drop` implementation for `Instrumented`
`Future`s so that the attached `Span` is entered when dropping the `Future`. This
means that events emitted by the `Future`'s `Drop` implementation will now be
recorded within its `Span`. It also adds `#[inline]` hints to methods called in
the `event!` macro's expansion, for an improvement in both binary size and
performance.

Additionally, this release updates the `tracing-attributes` dependency to
[v0.1.24][attrs-0.1.24], which updates the [`syn`] dependency to v2.x.x.
`tracing-attributes` v0.1.24 also includes improvements to the `#[instrument]`
macro; see [the `tracing-attributes` 0.1.24 release notes][attrs-0.1.24] for
details.

### Added

- `Instrumented` futures will now enter the attached `Span` in their `Drop`
implementation, allowing events emitted when dropping the future to occur
within the span ([#2562])
- `#[inline]` attributes for methods called by the `event!` macros, making
generated code smaller ([#2555])
- **attributes**: `level` argument to `#[instrument(err)]` and
`#[instrument(ret)]` to override the level of
the generated return value event ([#2335])
- **attributes**: Improved compiler error message when `#[instrument]` is added to a `const fn`
([#2418])

### Changed

- `tracing-attributes`: updated to [0.1.24][attrs-0.1.24]
- Removed unneeded `cfg-if` dependency ([#2553])
- **attributes**: Updated [`syn`] dependency to 2.0 ([#2516])

### Fixed

- **attributes**: Fix `clippy::unreachable` warnings in `#[instrument]`-generated code ([#2356])
- **attributes**: Removed unused "visit" feature flag from `syn` dependency ([#2530])

### Documented

- **attributes**: Documented default level for `#[instrument(err)]` ([#2433])
- **attributes**: Improved documentation for levels in `#[instrument]` ([#2350])

Thanks to @nitnelave, @jsgf, @Abhicodes-crypto, @LukeMathWalker, @andrewpollack,
@quad, @klensy, @davidpdrsn, @dbidwell94, @ldm0, @NobodyXu, @ilsv, and @daxpedda
for contributing to this release!

[`syn`]: https://crates.io/crates/syn
[attrs-0.1.24]:
https:/tokio-rs/tracing/releases/tag/tracing-attributes-0.1.24
[#2565]: https:/tokio-rs/tracing/pull/2565
[#2555]: https:/tokio-rs/tracing/pull/2555
[#2553]: https:/tokio-rs/tracing/pull/2553
[#2335]: https:/tokio-rs/tracing/pull/2335
[#2418]: https:/tokio-rs/tracing/pull/2418
[#2516]: https:/tokio-rs/tracing/pull/2516
[#2356]: https:/tokio-rs/tracing/pull/2356
[#2530]: https:/tokio-rs/tracing/pull/2530
[#2433]: https:/tokio-rs/tracing/pull/2433
[#2350]: https:/tokio-rs/tracing/pull/2350

# 0.1.37 (October 6, 2022)

This release of `tracing` incorporates changes from `tracing-core`
Expand Down
25 changes: 13 additions & 12 deletions third_party/rust/tracing/v0_1/crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

[package]
edition = "2018"
rust-version = "1.49.0"
rust-version = "1.56.0"
name = "tracing"
version = "0.1.37"
version = "0.1.40"
authors = [
"Eliza Weisman <[email protected]>",
"Tokio Contributors <[email protected]>",
Expand All @@ -40,13 +40,13 @@ repository = "https:/tokio-rs/tracing"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs",
rustc-args = [
"--cfg",
"tracing_unstable",
]
rustc-args = [
rustdoc-args = [
"--cfg",
"docsrs",
"--cfg",
"tracing_unstable",
]
Expand Down Expand Up @@ -87,9 +87,6 @@ harness = false
name = "span_repeated"
harness = false

[dependencies.cfg-if]
version = "1.0.0"

[dependencies.log]
version = "0.4.17"
optional = true
Expand All @@ -98,16 +95,20 @@ optional = true
version = "0.2.9"

[dependencies.tracing-attributes]
version = "0.1.23"
version = "0.1.27"
rillian marked this conversation as resolved.
Show resolved Hide resolved
optional = true

[dependencies.tracing-core]
version = "0.1.30"
version = "0.1.32"
default-features = false

[dev-dependencies.criterion]
version = "0.3.6"
default-features = false
default_features = false

[dev-dependencies.futures]
version = "0.3.21"
default_features = false

[dev-dependencies.log]
version = "0.4.17"
Expand Down
12 changes: 6 additions & 6 deletions third_party/rust/tracing/v0_1/crate/Cargo.toml.orig

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading