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

Micro-optimize Span Field recording #642

Merged
merged 2 commits into from
Feb 26, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [1.68.0]
rust: [1.73.0]

name: Check / Test MSRV on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

**Compatiblity**:

- Raised the MSRV to **1.73**.

**Improvements**:

- Slightly improved overhead of the `tracing` layer. ([#642](https://github.com/getsentry/sentry-rust/pull/642))

## 0.32.2

### Various fixes & improvements
Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

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

8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ best API and adding new features.
We currently only verify this crate against a recent version of Sentry hosted on [sentry.io](https://sentry.io/) but it
should work with on-prem Sentry versions 20.6 and later.

The **Minimum Supported Rust Version** is currently at _1.68.0_.
The Sentry crates will support a _6 months_ old Rust version at time of release,
The **Minimum Supported Rust Version** is currently at _1.73.0_.
The Sentry crates tries to support a _6 months_ old Rust version at time of release,
and the MSRV will be increased in accordance with its dependencies.

**Note**: Due to the misconfiguration in our workflow that verified the MSRV builds,
we had to bump it all the way to _1.67.0_, breaking our own _6 months_ old rule.
As of version _0.30.0_, the workflow has been fixed, and the MSRV will be enforced correctly.

## Resources

- [Discord](https://discord.gg/ez5KZN7) server for project discussions.
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.68.0"
msrv = "1.73.0"
6 changes: 4 additions & 2 deletions sentry-actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ description = """
Sentry client extension for actix-web 3.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
actix-web = { version = "4", default-features = false }
futures-util = { version = "0.3.5", default-features = false }
sentry-core = { version = "0.32.2", path = "../sentry-core", default-features = false, features = ["client"] }
sentry-core = { version = "0.32.2", path = "../sentry-core", default-features = false, features = [
"client",
] }

[dev-dependencies]
actix-web = { version = "4" }
Expand Down
2 changes: 1 addition & 1 deletion sentry-anyhow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration for anyhow.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[features]
default = ["backtrace"]
Expand Down
7 changes: 5 additions & 2 deletions sentry-backtrace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ description = """
Sentry integration and utilities for dealing with stacktraces.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
backtrace = "0.3.44"
once_cell = "1"
regex = { version = "1.5.5", default-features = false, features = ["std", "unicode-perl"] }
regex = { version = "1.5.5", default-features = false, features = [
"std",
"unicode-perl",
] }
sentry-core = { version = "0.32.2", path = "../sentry-core" }
2 changes: 1 addition & 1 deletion sentry-contexts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Sentry integration for os, device, and rust contexts.
"""
build = "build.rs"
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
sentry-core = { version = "0.32.2", path = "../sentry-core" }
Expand Down
7 changes: 5 additions & 2 deletions sentry-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Core sentry library used for instrumentation and integration development.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[package.metadata.docs.rs]
all-features = true
Expand Down Expand Up @@ -43,7 +43,10 @@ uuid = { version = "1.0.0", features = ["v4", "serde"], optional = true }
# Because we re-export all the public API in `sentry`, we actually run all the
# doctests using the `sentry` crate. This also takes care of the doctest
# limitation documented in https://github.com/rust-lang/rust/issues/45599.
sentry = { path = "../sentry", default-features = false, features = ["test", "transport"] }
sentry = { path = "../sentry", default-features = false, features = [
"test",
"transport",
] }
anyhow = "1.0.30"
criterion = "0.5"
futures = "0.3.24"
Expand Down
2 changes: 1 addition & 1 deletion sentry-debug-images/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration that adds the list of loaded libraries to events.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
findshlibs = "=0.10.2"
Expand Down
2 changes: 1 addition & 1 deletion sentry-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration for log and env_logger crates.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
sentry-core = { version = "0.32.2", path = "../sentry-core" }
Expand Down
2 changes: 1 addition & 1 deletion sentry-panic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration for capturing panics.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
sentry-core = { version = "0.32.2", path = "../sentry-core" }
Expand Down
2 changes: 1 addition & 1 deletion sentry-slog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration for the slog crate.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[dependencies]
sentry-core = { version = "0.32.2", path = "../sentry-core" }
Expand Down
6 changes: 4 additions & 2 deletions sentry-tower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration for tower-based crates.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -25,7 +25,9 @@ tower-layer = "0.3"
tower-service = "0.3"
http = { version = "1.0.0", optional = true }
pin-project = { version = "1.0.10", optional = true }
sentry-core = { version = "0.32.2", path = "../sentry-core", default-features = false, features = ["client"] }
sentry-core = { version = "0.32.2", path = "../sentry-core", default-features = false, features = [
"client",
] }
url = { version = "2.2.2", optional = true }

[dev-dependencies]
Expand Down
10 changes: 7 additions & 3 deletions sentry-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = """
Sentry integration for tracing and tracing-subscriber crates.
"""
edition = "2021"
rust-version = "1.68"
rust-version = "1.73"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -20,9 +20,13 @@ default = []
backtrace = ["dep:sentry-backtrace"]

[dependencies]
sentry-core = { version = "0.32.2", path = "../sentry-core", features = ["client"] }
sentry-core = { version = "0.32.2", path = "../sentry-core", features = [
"client",
] }
tracing-core = "0.1"
tracing-subscriber = { version = "0.3.1", default-features = false, features = ["std"] }
tracing-subscriber = { version = "0.3.1", default-features = false, features = [
"std",
] }
sentry-backtrace = { version = "0.32.2", path = "../sentry-backtrace", optional = true }

[dev-dependencies]
Expand Down
23 changes: 5 additions & 18 deletions sentry-tracing/src/converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::error::Error;
use sentry_core::protocol::{Event, Exception, Mechanism, Thread, Value};
use sentry_core::{event_from_error, Breadcrumb, Level, TransactionOrSpan};
use tracing_core::field::{Field, Visit};
use tracing_core::{span, Subscriber};
use tracing_core::Subscriber;
use tracing_subscriber::layer::Context;
use tracing_subscriber::registry::LookupSpan;

Expand Down Expand Up @@ -42,7 +42,10 @@ fn extract_event_data(event: &tracing_core::Event) -> (Option<String>, FieldVisi
// When #[instrument(err)] is used the event does not have a message attached to it.
// the error message is attached to the field "error".
.or_else(|| visitor.json_values.remove("error"))
.and_then(|v| v.as_str().map(|s| s.to_owned()));
.and_then(|v| match v {
Value::String(s) => Some(s),
_ => None,
});

(message, visitor)
}
Expand Down Expand Up @@ -93,22 +96,6 @@ where
(message, visitor)
}

/// Extracts the message and metadata from a span
pub(crate) fn extract_span_data(
attrs: &span::Attributes,
) -> (Option<String>, BTreeMap<String, Value>) {
let mut data = FieldVisitor::default();
attrs.record(&mut data);

// Find message of the span, if any
let message = data
.json_values
.remove("message")
.and_then(|v| v.as_str().map(|s| s.to_owned()));

(message, data.json_values)
}

/// Records all fields of [`tracing_core::Event`] for easy access
#[derive(Default)]
pub(crate) struct FieldVisitor {
Expand Down
Loading
Loading