Skip to content

Commit ca0d36b

Browse files
committed
Merge branch 'master' into feat/upstream-pending
* master: feat(sampling): Support custom tags and more contexts (#1268) deps: Update symbolic to pull in Unreal parser fixes (#1266) Bring in CLA Lite (#1257) release: 0.8.11 ref(profiling): Normalize all profiles (#1250) feat(profiling): Add a profile data category and count profiles in an envelope to apply rate limits (#1259) fix: Raise a new InvalidCompression Outcome for invalid Unreal compression (#1237) chore: Update logo for dark or light theme (#1262) ref: Use Duration to compute breakdowns and span durations (#1260)
2 parents 4c05f99 + b23b8d3 commit ca0d36b

File tree

29 files changed

+10067
-389
lines changed

29 files changed

+10067
-389
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
3+
4+
<!-- Describe your PR here. -->
5+
6+
7+
8+
<!--
9+
10+
Sentry employees and contractors can delete or ignore the following.
11+
12+
-->
13+
14+
### Legal Boilerplate
15+
16+
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- fix(metrics): Enforce metric name length limit. ([#1238](https://github.com/getsentry/relay/pull/1238))
1414
- Accept and forward unknown Envelope items. In processing mode, drop items individually rather than rejecting the entire request. This allows SDKs to send new data in combined Envelopes in the future. ([#1246](https://github.com/getsentry/relay/pull/1246))
1515
- Stop extracting metrics with outdated names from sessions. ([#1251](https://github.com/getsentry/relay/pull/1251), [#1252](https://github.com/getsentry/relay/pull/1252))
16+
- Update symbolic to pull in fixed Unreal parser that now correctly handles zero-length files. ([#1266](https://github.com/getsentry/relay/pull/1266))
1617

1718
**Internal**:
1819

@@ -22,6 +23,10 @@
2223
- Remove the unused "internal" data category. ([#1245](https://github.com/getsentry/relay/pull/1245))
2324
- Add the client and version as `sdk` tag to extracted session metrics in the format `name/version`. ([#1248](https://github.com/getsentry/relay/pull/1248))
2425
- Expose `shutdown_timeout` in `OverridableConfig` ([#1247](https://github.com/getsentry/relay/pull/1247))
26+
- Normalize all profiles and reject invalid ones. ([#1250](https://github.com/getsentry/relay/pull/1250))
27+
- Raise a new InvalidCompression Outcome for invalid Unreal compression. ([#1237](https://github.com/getsentry/relay/pull/1237))
28+
- Add a profile data category and count profiles in an envelope to apply rate limits. ([#1259](https://github.com/getsentry/relay/pull/1259))
29+
- Support dynamic sampling by custom tags, operating system name and version, as well as device name and family. ([#1268](https://github.com/getsentry/relay/pull/1268))
2530

2631
## 22.4.0
2732

Cargo.lock

+7-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<p align="center">
2-
<a href="https://sentry.io" target="_blank" align="center">
3-
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<picture>
4+
<source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-white.png" media="(prefers-color-scheme: dark)" />
5+
<source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" />
6+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" alt="Sentry" width="280">
7+
</picture>
48
</a>
5-
<br />
69
</p>
710

811
# Official Sentry Relay

py/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## Unreleased
3+
## 0.8.11
44

55
- Add protocol support for custom units on transaction measurements. ([#1256](https://github.com/getsentry/relay/pull/1256))
6+
- Add a profile data category and count profiles in an envelope to apply rate limits. ([#1259](https://github.com/getsentry/relay/pull/1259))
67

78
## 0.8.10
89

relay-cabi/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "relay-cabi"
3-
version = "0.8.10"
3+
version = "0.8.11"
44
authors = ["Sentry <[email protected]>"]
55
homepage = "https://getsentry.github.io/relay/"
66
repository = "https://github.com/getsentry/relay"

relay-common/src/constants.rs

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ pub enum DataCategory {
107107
Attachment = 4,
108108
/// Session updates. Quantity is the number of updates in the batch.
109109
Session = 5,
110+
/// A profile
111+
Profile = 6,
110112
/// Any other data category not known by this Relay.
111113
#[serde(other)]
112114
Unknown = -1,
@@ -122,6 +124,7 @@ impl DataCategory {
122124
"security" => Self::Security,
123125
"attachment" => Self::Attachment,
124126
"session" => Self::Session,
127+
"profile" => Self::Profile,
125128
_ => Self::Unknown,
126129
}
127130
}
@@ -135,6 +138,7 @@ impl DataCategory {
135138
Self::Security => "security",
136139
Self::Attachment => "attachment",
137140
Self::Session => "session",
141+
Self::Profile => "profile",
138142
Self::Unknown => "unknown",
139143
}
140144
}

relay-common/src/time.rs

+45
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,51 @@ pub fn instant_to_date_time(instant: Instant) -> chrono::DateTime<chrono::Utc> {
1616
instant_to_system_time(instant).into()
1717
}
1818

19+
/// Returns the number of milliseconds contained by this `Duration` as `f64`.
20+
///
21+
/// The returned value does include the fractional (nanosecond) part of the duration.
22+
///
23+
/// # Example
24+
///
25+
/// ```
26+
/// use std::time::Duration;
27+
///
28+
/// let duration = Duration::from_nanos(2_125_000);
29+
/// let millis = relay_common::duration_to_millis(duration);
30+
/// assert_eq!(millis, 2.125);
31+
/// ```
32+
pub fn duration_to_millis(duration: Duration) -> f64 {
33+
(duration.as_secs_f64() * 1_000_000_000f64).round() / 1_000_000f64
34+
}
35+
36+
/// Returns the positive number of milliseconds contained by this `Duration` as `f64`.
37+
///
38+
/// The returned value does include the fractional (nanosecond) part of the duration. If the
39+
/// duration is negative, this returns `0.0`;
40+
///
41+
/// # Example
42+
///
43+
/// ```
44+
/// use chrono::Duration;
45+
///
46+
/// let duration = Duration::nanoseconds(2_125_000);
47+
/// let millis = relay_common::chrono_to_positive_millis(duration);
48+
/// assert_eq!(millis, 2.125);
49+
/// ```
50+
///
51+
/// Negative durations are clamped to `0.0`:
52+
///
53+
/// ```
54+
/// use chrono::Duration;
55+
///
56+
/// let duration = Duration::nanoseconds(-2_125_000);
57+
/// let millis = relay_common::chrono_to_positive_millis(duration);
58+
/// assert_eq!(millis, 0.0);
59+
/// ```
60+
pub fn chrono_to_positive_millis(duration: chrono::Duration) -> f64 {
61+
duration_to_millis(duration.to_std().unwrap_or_default())
62+
}
63+
1964
/// The conversion result of [`UnixTimestamp::to_instant`].
2065
///
2166
/// If the time is outside of what can be represented in an [`Instant`], this is `Past` or

relay-general/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<p align="center">
2-
<a href="https://sentry.io" target="_blank" align="center">
3-
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<picture>
4+
<source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-white.png" media="(prefers-color-scheme: dark)" />
5+
<source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" />
6+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" alt="Sentry" width="280">
7+
</picture>
48
</a>
5-
<br />
69
</p>
710

811
# General - Sentry Annotated Protocol

relay-general/src/protocol/debugmeta.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::types::{
2222
/// be stripped liberally because it would break processing for certain platforms.
2323
///
2424
/// Those strings get special treatment in our PII processor to avoid stripping the basename.
25-
#[derive(Debug, FromValue, IntoValue, Empty, Clone, PartialEq)]
25+
#[derive(Debug, FromValue, IntoValue, Empty, Clone, PartialEq, Deserialize, Serialize)]
2626
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
2727
pub struct NativeImagePath(pub String);
2828

relay-general/src/protocol/tags.rs

+12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ impl FromValue for TagEntry {
4646
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
4747
pub struct Tags(pub PairList<TagEntry>);
4848

49+
impl Tags {
50+
/// Returns a reference to the value of the tag, if it exists.
51+
///
52+
/// If the tag with the specified key exists multiple times, the first instance is returned. If
53+
/// no tag with the given key exists or the tag entry is erroneous, `None` is returned`.
54+
///
55+
/// To retrieve the [`Annotated`] wrapper of the tag value, use [`PairList::get`] instead.
56+
pub fn get(&self, key: &str) -> Option<&str> {
57+
self.0.get_value(key).map(String::as_str)
58+
}
59+
}
60+
4961
impl std::ops::Deref for Tags {
5062
type Target = Array<TagEntry>;
5163

relay-general/src/protocol/types.rs

+37-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::cmp::Ordering;
44
use std::fmt;
55
use std::iter::{FromIterator, IntoIterator};
66
use std::net;
7-
use std::ops::{Add, Deref, DerefMut};
7+
use std::ops::{Add, Sub};
88
use std::str::FromStr;
99

1010
use chrono::{DateTime, Datelike, Duration, LocalResult, NaiveDateTime, TimeZone, Utc};
@@ -211,6 +211,33 @@ where
211211
.position(|entry| entry.as_pair().0.as_str() == Some(key))
212212
}
213213

214+
/// Returns a reference to the annotated value corresponding to the key.
215+
///
216+
/// The key may be any borrowed form of the pairlist's key type. If there are multiple entries
217+
/// with the same key, the first is returned.
218+
pub fn get<'a, Q>(&'a self, key: Q) -> Option<&Annotated<V>>
219+
where
220+
Q: AsRef<str>,
221+
K: 'a,
222+
{
223+
self.position(key)
224+
.and_then(|pos| self.0.get(pos))
225+
.and_then(Annotated::value)
226+
.map(|pair| pair.as_pair().1)
227+
}
228+
229+
/// Returns a reference to the value corresponding to the key.
230+
///
231+
/// The key may be any borrowed form of the pairlist's key type. If there are multiple entries
232+
/// with the same key, the first is returned.
233+
pub fn get_value<'a, Q>(&'a self, key: Q) -> Option<&V>
234+
where
235+
Q: AsRef<str>,
236+
K: 'a,
237+
{
238+
self.get(key).and_then(Annotated::value)
239+
}
240+
214241
/// Returns `true` if the pair list contains a value for the specified key.
215242
pub fn contains<Q>(&self, key: Q) -> bool
216243
where
@@ -467,6 +494,7 @@ hex_metrastructure!(RegVal, "register value");
467494
pub struct Addr(pub u64);
468495

469496
hex_metrastructure!(Addr, "address");
497+
relay_common::impl_str_serde!(Addr, "an address");
470498

471499
/// An ip address.
472500
#[derive(
@@ -892,20 +920,6 @@ impl From<DateTime<Utc>> for Timestamp {
892920
}
893921
}
894922

895-
impl Deref for Timestamp {
896-
type Target = DateTime<Utc>;
897-
898-
fn deref(&self) -> &Self::Target {
899-
&self.0
900-
}
901-
}
902-
903-
impl DerefMut for Timestamp {
904-
fn deref_mut(&mut self) -> &mut <Self as Deref>::Target {
905-
&mut self.0
906-
}
907-
}
908-
909923
impl Add<Duration> for Timestamp {
910924
type Output = Self;
911925

@@ -914,6 +928,14 @@ impl Add<Duration> for Timestamp {
914928
}
915929
}
916930

931+
impl Sub<Timestamp> for Timestamp {
932+
type Output = chrono::Duration;
933+
934+
fn sub(self, rhs: Timestamp) -> Self::Output {
935+
self.into_inner() - rhs.into_inner()
936+
}
937+
}
938+
917939
impl PartialEq<DateTime<Utc>> for Timestamp {
918940
fn eq(&self, other: &DateTime<Utc>) -> bool {
919941
&self.0 == other

relay-general/src/store/normalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'a> NormalizeProcessor<'a> {
171171
Ok(())
172172
})?;
173173

174-
ClockDriftProcessor::new(sent_at.map(|x| *x), received_at)
174+
ClockDriftProcessor::new(sent_at.map(|ts| ts.into_inner()), received_at)
175175
.error_kind(error_kind)
176176
.process_event(event, meta, state)?;
177177

0 commit comments

Comments
 (0)