Skip to content

Commit

Permalink
Upgrade to Sentry 0.24 and use public SystemTime (#10)
Browse files Browse the repository at this point in the history
* Upgrade to Sentry 0.24 and use public `SystemTime`

Sentry just released 0.24.1, and switched away from `chrono` in [409] to
address `RUSTSEC-2020-0159` and now only uses `std::time::SystemTime` in
its public API.

[409]: getsentry/sentry-rust#409

* Fix clippy lints

Co-authored-by: Jake Shadle <[email protected]>
  • Loading branch information
MarijnS95 and Jake-Shadle authored Jan 21, 2022
1 parent a274288 commit 1dc6f19
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ debug-logs = []
breakpad-handler = { version = "0.1.0", path = "./breakpad-handler" }
crossbeam = "0.8.0"
parking_lot = "0.11"
sentry-core = { version = "0.23", features = ["client"] }
sentry-core = { version = "0.24", features = ["client"] }
serde_json = "1.0"

[workspace]
Expand Down
6 changes: 3 additions & 3 deletions src/breakpad_integration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sentry_core::{protocol as proto, types};
use std::path::Path;
use sentry_core::protocol as proto;
use std::{path::Path, time::SystemTime};

pub use breakpad_handler::InstallOptions;

Expand Down Expand Up @@ -59,7 +59,7 @@ impl BreakpadIntegration {
// We want to set the timestamp here since we aren't actually
// going to send the crash directly, but rather the next time
// this integration is initialized
timestamp: types::Utc::now(),
timestamp: SystemTime::now(),
// This is the easiest way to indicate a session crash update
// in the same envelope with the crash itself. :p
exception: vec![proto::Exception {
Expand Down
81 changes: 81 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,84 @@
// BEGIN - Embark standard lints v5 for Rust 1.55+
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)]
#![warn(
clippy::all,
clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro,
clippy::debug_assert_with_mut_call,
clippy::disallowed_method,
clippy::disallowed_type,
clippy::doc_markdown,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next,
clippy::flat_map_option,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools,
clippy::from_iter_instead_of_collect,
clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops,
clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_digit_groups,
clippy::large_stack_arrays,
clippy::large_types_passed_by_value,
clippy::let_unit_value,
clippy::linkedlist,
clippy::lossy_float_literal,
clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore,
clippy::map_flatten,
clippy::map_unwrap_or,
clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wild_err_arm,
clippy::match_wildcard_for_single_variants,
clippy::mem_forget,
clippy::mismatched_target_os,
clippy::missing_enforced_import_renames,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow,
clippy::needless_continue,
clippy::needless_for_each,
clippy::option_option,
clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::rc_mutex,
clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::single_match_else,
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string,
clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
clippy::unnested_or_patterns,
clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible,
nonstandard_style,
rust_2018_idioms
)]
// END - Embark standard lints v0.5 for Rust 1.55+

//! Capture and report minidumps to [Sentry](https://sentry.io/about/)
//!
//! 1. Create a [`BreakpadTransportFactory`] for [`ClientOptions::transport`](https://docs.rs/sentry-core/0.23.0/sentry_core/struct.ClientOptions.html#structfield.transport)
Expand Down
10 changes: 5 additions & 5 deletions src/shared.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sentry_core::{protocol as proto, types};
use std::path::Path;
use std::{path::Path, time::SystemTime};

pub(crate) fn assemble_envelope(md: CrashMetadata, minidump_path: &Path) -> proto::Envelope {
let mut envelope = proto::Envelope::new();
Expand All @@ -12,9 +12,9 @@ pub(crate) fn assemble_envelope(md: CrashMetadata, minidump_path: &Path) -> prot
minidump_path
.metadata()
.ok()
.and_then(|md| md.created().ok().map(|st| st.into()))
.and_then(|md| md.created().ok())
})
.unwrap_or_else(types::Utc::now);
.unwrap_or_else(SystemTime::now);

// An event_id is required, so if we were unable to get one from the .metadata
// we just use the guid in the filename of the minidump
Expand Down Expand Up @@ -93,7 +93,7 @@ impl CrashMetadata {

let event = lines.next().and_then(|eve| {
if !eve.is_empty() {
match serde_json::from_str::<proto::Event>(eve) {
match serde_json::from_str::<proto::Event<'_>>(eve) {
Ok(event) => Some(event),
Err(e) => {
debug_print!("unable to deserialize Event: {}", e);
Expand All @@ -107,7 +107,7 @@ impl CrashMetadata {

let session_update = lines.next().and_then(|su| {
if !su.is_empty() {
match serde_json::from_str::<proto::SessionUpdate>(su) {
match serde_json::from_str::<proto::SessionUpdate<'_>>(su) {
Ok(sess) => Some(sess),
Err(e) => {
debug_print!("unable to deserialize SessionUpdate: {}", e);
Expand Down
2 changes: 1 addition & 1 deletion src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum CrashSendStyle {
}

/// The [`TransportFactory`](https://docs.rs/sentry-core/0.23.0/sentry_core/trait.TransportFactory.html) implementation that must be used in concert with
/// [BreakpadIntegration](crate::BreakpadIntegration) to report crash events to
/// [`BreakpadIntegration`](crate::BreakpadIntegration) to report crash events to
/// Sentry
pub struct BreakpadTransportFactory {
inner: Arc<dyn TransportFactory>,
Expand Down

0 comments on commit 1dc6f19

Please sign in to comment.