Skip to content

Commit a9db3b4

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/transaction-source
2 parents 627a60b + ed3a521 commit a9db3b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+133
-15
lines changed

relay-common/src/constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ use std::str::FromStr;
88
use schemars::JsonSchema;
99
use serde::{Deserialize, Serialize};
1010

11+
use crate::macros::impl_str_serde;
12+
1113
/// The type of an event.
1214
///
1315
/// The event type determines how Sentry handles the event and has an impact on processing, rate

relay-common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
html_favicon_url = "https://raw.githubusercontent.com/getsentry/relay/master/artwork/relay-icon.png"
66
)]
77

8-
#[macro_use]
98
mod macros;
109

1110
mod cell;
@@ -19,6 +18,7 @@ mod utils;
1918
pub use crate::cell::*;
2019
pub use crate::constants::*;
2120
pub use crate::glob::*;
21+
pub use crate::macros::*;
2222
pub use crate::project::*;
2323
pub use crate::retry::*;
2424
pub use crate::time::*;

relay-common/src/macros.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ macro_rules! impl_str_ser {
1717
};
1818
}
1919

20+
pub use impl_str_ser;
21+
2022
/// Helper macro to implement string based deserialization.
2123
///
2224
/// If a type implements `FromStr` then this automatically
@@ -58,6 +60,8 @@ macro_rules! impl_str_de {
5860
};
5961
}
6062

63+
pub use impl_str_de;
64+
6165
/// Helper macro to implement string based serialization and deserialization.
6266
///
6367
/// If a type implements `FromStr` and `Display` then this automatically
@@ -71,6 +75,8 @@ macro_rules! impl_str_serde {
7175
};
7276
}
7377

78+
pub use impl_str_serde;
79+
7480
/// Same as `try` but to be used in functions that return `Box<Future>` instead of `Result`.
7581
///
7682
/// Useful when calling synchronous (but cheap enough) functions in async code.
@@ -84,6 +90,8 @@ macro_rules! tryf {
8490
};
8591
}
8692

93+
pub use tryf;
94+
8795
/// A cloning alternative to a `move` closure.
8896
///
8997
/// When one needs to use a closure with move semantics one often needs to clone and move some of
@@ -127,3 +135,5 @@ macro_rules! clone {
127135
move |$($p),+| $body
128136
}};
129137
}
138+
139+
pub use clone;

relay-common/src/project.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::fmt;
22
use std::str::FromStr;
33

4+
use crate::macros::impl_str_serde;
5+
46
#[doc(inline)]
57
pub use sentry_types::{ParseProjectIdError, ProjectId};
68

relay-common/src/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::str;
44
use lazy_static::lazy_static;
55
use regex::Regex;
66

7+
use crate::macros::impl_str_serde;
8+
79
lazy_static! {
810
static ref GLOB_RE: Regex = Regex::new(r#"\?|\*\*|\*"#).unwrap();
911
}

relay-general/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
#[macro_use]
1313
extern crate relay_general_derive;
1414

15-
#[macro_use]
1615
mod macros;
1716

1817
#[cfg(test)]
19-
#[macro_use]
2018
mod testutils;
2119

2220
pub mod pii;

relay-general/src/macros.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ macro_rules! derive_string_meta_structure {
4747
};
4848
}
4949

50+
pub(crate) use derive_string_meta_structure;
51+
5052
/// Implements FromStr and Display on a flat/C-like enum such that strings roundtrip correctly and
5153
/// all variants can be FromStr'd.
5254
///
5355
///
5456
/// Usage:
5557
///
56-
/// ```rust
58+
/// ```ignore
5759
/// // derive fail for this or whatever you need. The type must be ZST though.
5860
/// struct ValueTypeError;
5961
///
@@ -99,3 +101,5 @@ macro_rules! derive_fromstr_and_display {
99101
}
100102
}
101103
}
104+
105+
pub(crate) use derive_fromstr_and_display;

relay-general/src/pii/attachments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ mod tests {
507507
use itertools::Itertools;
508508

509509
use crate::pii::PiiConfig;
510+
use crate::testutils::assert_eq_bytes_str;
510511

511512
use super::*;
512513

relay-general/src/pii/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ mod tests {
366366
use crate::pii::processor::PiiProcessor;
367367
use crate::pii::{Redaction, ReplaceRedaction};
368368
use crate::processor::{process_value, ProcessingState, ValueType};
369+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
369370
use crate::types::{Annotated, Remark, RemarkType};
370371

371372
use super::{BUILTIN_RULES, BUILTIN_RULES_MAP};

relay-general/src/pii/convert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ mod tests {
128128
use crate::pii::{DataScrubbingConfig, PiiConfig, PiiProcessor};
129129
use crate::processor::{process_value, ProcessingState};
130130
use crate::protocol::Event;
131+
use crate::testutils::{assert_annotated_snapshot, assert_eq_dbg};
131132
use crate::types::FromValue;
132133

133134
use super::to_pii_config as to_pii_config_impl;

relay-general/src/pii/processor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ use {
361361
Addr, DebugImage, DebugMeta, Event, ExtraValue, Headers, LogEntry, NativeDebugImage,
362362
Request,
363363
},
364+
crate::testutils::assert_annotated_snapshot,
364365
crate::types::{Annotated, Object, Value},
365366
};
366367

relay-general/src/processor/attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use enumset::{EnumSet, EnumSetType};
66
use failure::Fail;
77
use smallvec::SmallVec;
88

9+
use crate::macros::derive_fromstr_and_display;
910
use crate::processor::{ProcessValue, SelectorPathItem, SelectorSpec};
1011
use crate::types::Annotated;
1112

relay-general/src/processor/chunks.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ where
174174
}
175175
}
176176

177+
#[cfg(test)]
178+
use crate::testutils::assert_eq_dbg;
179+
177180
#[test]
178181
fn test_chunk_split() {
179182
let remarks = vec![Remark::with_range(

relay-general/src/protocol/breadcrumb.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ pub struct Breadcrumb {
121121
pub other: Object<Value>,
122122
}
123123

124+
#[cfg(test)]
125+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
126+
124127
#[test]
125128
fn test_breadcrumb_roundtrip() {
126129
use crate::types::Map;

relay-general/src/protocol/client_report.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ impl ClientReport {
4242
mod tests {
4343
use super::*;
4444

45+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
46+
4547
#[test]
4648
fn test_client_report_roundtrip() {
4749
let json = r#"{

relay-general/src/protocol/clientsdk.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ pub struct ClientSdkInfo {
6464
pub other: Object<Value>,
6565
}
6666

67+
#[cfg(test)]
68+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
69+
6770
#[test]
6871
fn test_client_sdk_roundtrip() {
6972
use crate::types::Map;

relay-general/src/protocol/contexts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ impl FromValue for Contexts {
731731
}
732732
}
733733

734+
#[cfg(test)]
735+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
736+
734737
#[test]
735738
fn test_device_context_roundtrip() {
736739
let json = r#"{

relay-general/src/protocol/debugmeta.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,10 @@ pub struct DebugMeta {
481481
}
482482

483483
#[cfg(test)]
484-
use crate::types::Map;
484+
use {
485+
crate::testutils::{assert_eq_dbg, assert_eq_str},
486+
crate::types::Map,
487+
};
485488

486489
#[test]
487490
fn test_debug_image_proguard_roundtrip() {

relay-general/src/protocol/event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use schemars::schema::Schema;
88

99
use serde::{Serialize, Serializer};
1010

11+
use crate::macros::derive_string_meta_structure;
1112
use crate::processor::ProcessValue;
1213
use crate::protocol::{
1314
Breadcrumb, Breakdowns, ClientSdkInfo, Contexts, Csp, DebugMeta, Exception, ExpectCt,
@@ -537,6 +538,9 @@ pub struct Event {
537538
pub other: Object<Value>,
538539
}
539540

541+
#[cfg(test)]
542+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
543+
540544
#[test]
541545
fn test_event_roundtrip() {
542546
use chrono::{TimeZone, Utc};

relay-general/src/protocol/exception.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ pub struct Exception {
6868
pub other: Object<Value>,
6969
}
7070

71+
#[cfg(test)]
72+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
73+
7174
#[test]
7275
fn test_exception_roundtrip() {
7376
use crate::types::Map;

relay-general/src/protocol/fingerprint.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ impl IntoValue for Fingerprint {
114114
// Fingerprints must not be trimmed.
115115
impl ProcessValue for Fingerprint {}
116116

117+
#[cfg(test)]
118+
use crate::testutils::assert_eq_dbg;
119+
117120
#[test]
118121
fn test_fingerprint_string() {
119122
assert_eq_dbg!(

relay-general/src/protocol/logentry.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ impl FromValue for LogEntry {
131131
}
132132
}
133133

134+
#[cfg(test)]
135+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
136+
134137
#[test]
135138
fn test_logentry_roundtrip() {
136139
let json = r#"{

relay-general/src/protocol/measurements.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ fn is_valid_measurement_name(name: &str) -> bool {
134134
.all(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' | '.'))
135135
}
136136

137+
#[cfg(test)]
138+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
139+
137140
#[test]
138141
fn test_measurements_serialization() {
139142
use crate::protocol::Event;

relay-general/src/protocol/mechanism.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ impl FromValue for Mechanism {
256256
}
257257
}
258258

259+
#[cfg(test)]
260+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
261+
259262
#[test]
260263
fn test_mechanism_roundtrip() {
261264
use crate::types::Map;

relay-general/src/protocol/request.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ pub struct Request {
500500
pub other: Object<Value>,
501501
}
502502

503+
#[cfg(test)]
504+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
505+
503506
#[test]
504507
fn test_header_normalization() {
505508
let json = r#"{

relay-general/src/protocol/security_report.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use serde::de::{Error, IgnoredAny};
1111
use serde::{Deserialize, Serialize};
1212
use url::Url;
1313

14+
use crate::macros::derive_fromstr_and_display;
1415
use crate::protocol::{
1516
Event, HeaderName, HeaderValue, Headers, LogEntry, PairList, Request, TagEntry, Tags,
1617
};
@@ -1083,6 +1084,8 @@ impl SecurityReportType {
10831084
mod tests {
10841085
use super::*;
10851086

1087+
use crate::testutils::assert_annotated_snapshot;
1088+
10861089
#[test]
10871090
fn test_unsplit_uri() {
10881091
assert_eq!(unsplit_uri("", ""), "");

relay-general/src/protocol/session.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use failure::Fail;
55
use serde::{Deserialize, Serialize};
66
use uuid::Uuid;
77

8+
use crate::macros::derive_fromstr_and_display;
89
use crate::protocol::IpAddr;
910

1011
/// The type of session event we're dealing with.
@@ -295,6 +296,8 @@ impl SessionAggregates {
295296
mod tests {
296297
use super::*;
297298

299+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
300+
298301
#[test]
299302
fn test_session_default_values() {
300303
let json = r#"{

relay-general/src/protocol/span.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub struct Span {
5656
#[cfg(test)]
5757
mod tests {
5858
use super::*;
59+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
5960
use chrono::{TimeZone, Utc};
6061

6162
#[test]

relay-general/src/protocol/stacktrace.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ impl From<Stacktrace> for RawStacktrace {
366366
}
367367
}
368368

369+
#[cfg(test)]
370+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
371+
369372
#[test]
370373
fn test_frame_roundtrip() {
371374
let json = r#"{

relay-general/src/protocol/tags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ impl std::ops::DerefMut for Tags {
7272
}
7373
}
7474

75+
#[cfg(test)]
76+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
77+
7578
#[test]
7679
fn test_tags_from_object() {
7780
let json = r#"{

relay-general/src/protocol/templateinfo.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ pub struct TemplateInfo {
3232
pub other: Object<Value>,
3333
}
3434

35+
#[cfg(test)]
36+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
37+
3538
#[test]
3639
fn test_template_roundtrip() {
3740
use crate::types::Map;

relay-general/src/protocol/thread.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ pub struct Thread {
127127
pub other: Object<Value>,
128128
}
129129

130+
#[cfg(test)]
131+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
132+
130133
#[test]
131134
fn test_thread_id() {
132135
assert_eq_dbg!(

relay-general/src/protocol/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,9 @@ impl schemars::JsonSchema for Timestamp {
11011101
}
11021102
}
11031103

1104+
#[cfg(test)]
1105+
use crate::testutils::{assert_eq_dbg, assert_eq_str};
1106+
11041107
#[test]
11051108
fn test_values_serialization() {
11061109
let value = Annotated::new(Values {

0 commit comments

Comments
 (0)