Skip to content
Closed
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
12 changes: 12 additions & 0 deletions Cargo.lock

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

133 changes: 95 additions & 38 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
[workspace]
resolver = "2"
members = [
"sentry",
"sentry-actix",
"sentry-anyhow",
"sentry-backtrace",
"sentry-contexts",
"sentry-core",
"sentry-debug-images",
"sentry-log",
"sentry-opentelemetry",
"sentry-panic",
"sentry-slog",
"sentry-tower",
"sentry-tracing",
"sentry-types",
"sentry",
"sentry-actix",
"sentry-anyhow",
"sentry-backtrace",
"sentry-contexts",
"sentry-core",
"sentry-debug-images",
"sentry-log",
"sentry-opentelemetry",
"sentry-panic",
"sentry-slog",
"sentry-time",
"sentry-tower",
"sentry-tracing",
"sentry-types",
]

[workspace.package]
authors = ["Sentry <hello@sentry.io>"]
repository = "https://github.com/getsentry/sentry-rust"
homepage = "https://sentry.io/welcome/"
edition = "2021"
rust-version = "1.88"

[workspace.lints.clippy]
arithmetic-side-effects.level = "warn"
allow-attributes.level = "warn"

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] }
homepage = "https://sentry.io/welcome/"
repository = "https://github.com/getsentry/sentry-rust"

[workspace.dependencies]
actix-http = "3.12"
Expand All @@ -40,6 +34,7 @@ backtrace = "0.3.44"
bitflags = "2.9.4"
bytes = "1.11.1"
cfg_aliases = "0.2.1"
# chrono = "0.4"
criterion = "0.5"
curl = "0.4.25"
debugid = "0.8.0"
Expand All @@ -62,27 +57,82 @@ os_info = "3.5.0"
pin-project = "1.0.10"
pretty_env_logger = "0.5.0"
prost = "0.13.3"
rand = "0.9.3"
rand = "0.9"
rayon = "1.5.3"
regex = { version = "1.5.5", default-features = false }
reqwest = { version = "0.13.2", default-features = false }
rstest = "0.25.0"
rustc_version = "0.4.0"
rustls = { version = "0.23.18", default-features = false }
sentry = { version = "0.49.1", path = "sentry", default-features = false }
sentry-actix = { version = "0.49.1", path = "sentry-actix", default-features = false }
sentry-anyhow = { version = "0.49.1", path = "sentry-anyhow", default-features = false, features = ["backtrace"] }
sentry-backtrace = { version = "0.49.1", path = "sentry-backtrace", default-features = false }
sentry-contexts = { version = "0.49.1", path = "sentry-contexts", default-features = false }
sentry-core = { version = "0.49.1", path = "sentry-core", default-features = false }
sentry-debug-images = { version = "0.49.1", path = "sentry-debug-images", default-features = false }
sentry-log = { version = "0.49.1", path = "sentry-log", default-features = false }
sentry-opentelemetry = { version = "0.49.1", path = "sentry-opentelemetry", default-features = false }
sentry-panic = { version = "0.49.1", path = "sentry-panic", default-features = false }
sentry-slog = { version = "0.49.1", path = "sentry-slog", default-features = false }
sentry-tower = { version = "0.49.1", path = "sentry-tower", default-features = false }
sentry-tracing = { version = "0.49.1", path = "sentry-tracing", default-features = false }
sentry-types = { version = "0.49.1", path = "sentry-types", default-features = false, features = ["protocol"] }
sentry = { path = "sentry", version = "0.49.1", default-features = false }
sentry-actix = {
path = "sentry-actix",
version = "0.49.1",
default-features = false
}
sentry-anyhow = {
path = "sentry-anyhow",
version = "0.49.1",
default-features = false,
features = ["backtrace"]
}
sentry-backtrace = {
path = "sentry-backtrace",
version = "0.49.1",
default-features = false
}
sentry-contexts = {
path = "sentry-contexts",
version = "0.49.1",
default-features = false
}
sentry-core = {
path = "sentry-core",
version = "0.49.1",
default-features = false
}
sentry-debug-images = {
path = "sentry-debug-images",
version = "0.49.1",
default-features = false
}
sentry-log = {
path = "sentry-log",
version = "0.49.1",
default-features = false
}
sentry-opentelemetry = {
path = "sentry-opentelemetry",
version = "0.49.1",
default-features = false
}
sentry-panic = {
path = "sentry-panic",
version = "0.49.1",
default-features = false
}
sentry-slog = {
path = "sentry-slog",
version = "0.49.1",
default-features = false
}
sentry-time = { path = "sentry-time", version = "0.49.1" }
sentry-tower = {
path = "sentry-tower",
version = "0.49.1",
default-features = false
}
sentry-tracing = {
path = "sentry-tracing",
version = "0.49.1",
default-features = false
}
sentry-types = {
path = "sentry-types",
version = "0.49.1",
default-features = false,
features = ["protocol"]
}
serde = "1.0.117"
serde_json = "1.0.48"
slog = "2.5.2"
Expand All @@ -100,3 +150,10 @@ uname = "0.1.1"
ureq = { version = "3.0.11", default-features = false }
url = "2.2.2"
uuid = "1.0.0"

[workspace.lints.clippy]
allow-attributes.level = "warn"
arithmetic-side-effects.level = "warn"

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(doc_cfg)"] }
4 changes: 3 additions & 1 deletion sentry-contexts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ workspace = true
[dependencies]
sentry-core = { workspace = true }
libc = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
hostname = { workspace = true }

[target."cfg(not(windows))".dependencies]
[target.'cfg(all(not(windows), not(target_arch = "wasm32")))'.dependencies]
uname = { workspace = true }

[target."cfg(windows)".dependencies]
Expand Down
20 changes: 19 additions & 1 deletion sentry-contexts/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,19 @@ mod model_support {
}

/// Returns the server name (hostname) if available.
#[cfg(not(target_arch = "wasm32"))]
pub fn server_name() -> Option<String> {
hostname::get().ok().and_then(|s| s.into_string().ok())
}

#[cfg(target_arch = "wasm32")]
pub fn server_name() -> Option<String> {
// TODO: What other options are available?
None
}

/// Returns the OS context
#[cfg(not(windows))]
#[cfg(all(not(windows), not(target_arch = "wasm32")))]
pub fn os_context() -> Option<Context> {
use uname::uname;
if let Ok(info) = uname() {
Expand Down Expand Up @@ -168,6 +175,17 @@ pub fn os_context() -> Option<Context> {
)
}

#[cfg(target_arch = "wasm32")]
pub fn os_context() -> Option<Context> {
Some(
OsContext {
name: Some("WASM".into()),
..Default::default()
}
.into(),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WASM cfg overly broad

Medium Severity

server_name and os_context gate on target_arch = "wasm32", which also matches targets like Emscripten where uname/hostname and real OS info previously worked. That regresses those targets to a hardcoded "WASM" OS and no server name. sentry-time already uses the narrower wasm + unknown cfg for browser-only limitations.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit df5a05f. Configure here.

}

/// Returns the rust info.
pub fn rust_context() -> Context {
RuntimeContext {
Expand Down
50 changes: 26 additions & 24 deletions sentry-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,53 @@
name = "sentry-core"
version = "0.49.1"
authors = { workspace = true }
license = "MIT"
readme = "README.md"
repository = { workspace = true }
homepage = { workspace = true }
edition = { workspace = true }
rust-version = { workspace = true }
description = """
Core Sentry library used for instrumentation and integration development.
"""
edition = { workspace = true }
rust-version = { workspace = true }

[lints]
workspace = true
readme = "README.md"
homepage = { workspace = true }
repository = { workspace = true }
license = "MIT"

[package.metadata.docs.rs]
all-features = true

[[bench]]
name = "scope_benchmark"
harness = false

[features]
default = []
client = ["rand"]
test = ["client", "release-health"]
release-health = []
logs = []
metrics = []
name = "scope_benchmark"

[dependencies]
# chrono.workspace = true
log = { workspace = true, features = ["std"], optional = true }
rand = { workspace = true, optional = true }
sentry-time = { workspace = true }
sentry-types = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
url = { workspace = true }
uuid = { workspace = true, features = ["v4", "serde"], optional = true }
uuid = { workspace = true, features = ["serde", "v4"], optional = true }

[dev-dependencies]
# 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 = { workspace = true, features = ["test", "transport", "metrics"] }
anyhow = { workspace = true }
criterion = { workspace = true }
futures = { workspace = true }
rayon = { workspace = 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 = { workspace = true, features = ["metrics", "test", "transport"] }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] }
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread"] }

[features]
default = []
client = ["rand"]
logs = []
metrics = []
release-health = []
test = ["client", "release-health"]

[lints]
workspace = true
6 changes: 3 additions & 3 deletions sentry-core/src/client/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use std::sync::{Arc, Condvar, Mutex, MutexGuard};
use std::thread::JoinHandle;
use std::time::{Duration, Instant};
use std::time::Duration;

use super::EnvelopeSender;
use crate::protocol::EnvelopeItem;
Expand Down Expand Up @@ -79,7 +79,7 @@ where
if *shutdown {
return;
}
let mut last_flush = Instant::now();
let mut last_flush = sentry_time::Instant::now();
loop {
let timeout = FLUSH_INTERVAL
.checked_sub(last_flush.elapsed())
Expand All @@ -93,7 +93,7 @@ where
worker_queue.lock().unwrap(),
&worker_envelope_sender,
);
last_flush = Instant::now();
last_flush = sentry_time::Instant::now();
}
}
})
Expand Down
3 changes: 3 additions & 0 deletions sentry-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ pub mod test;
// public api from other crates
#[doc(inline)]
pub use sentry_types as types;

#[doc(hidden)]
pub use sentry_time;
pub use sentry_types::protocol::v7 as protocol;
pub use sentry_types::protocol::v7::{Breadcrumb, Envelope, Level, User};

Expand Down
Loading