Skip to content

Commit afcac66

Browse files
authored
feat: Add release/env/sdk to Transactions (#402)
1 parent 281f3ff commit afcac66

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

sentry-core/src/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub struct Client {
4545
transport: TransportArc,
4646
session_flusher: RwLock<Option<SessionFlusher>>,
4747
integrations: Vec<(TypeId, Arc<dyn Integration>)>,
48-
sdk_info: ClientSdkInfo,
48+
pub(crate) sdk_info: ClientSdkInfo,
4949
}
5050

5151
impl fmt::Debug for Client {

sentry-core/src/performance.rs

+4
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ impl Transaction {
293293
.insert("trace".into(), inner.context.clone().into());
294294

295295
// TODO: apply the scope to the transaction, whatever that means
296+
let opts = client.options();
297+
transaction.release = opts.release.clone();
298+
transaction.environment = opts.environment.clone();
299+
transaction.sdk = Some(std::borrow::Cow::Owned(client.sdk_info.clone()));
296300

297301
let mut envelope = protocol::Envelope::new();
298302
envelope.add_item(transaction);

sentry-types/src/protocol/v7.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,12 @@ pub struct Transaction<'a> {
18211821
skip_serializing_if = "Option::is_none"
18221822
)]
18231823
pub name: Option<String>,
1824+
/// A release identifier.
1825+
#[serde(default, skip_serializing_if = "Option::is_none")]
1826+
pub release: Option<Cow<'a, str>>,
1827+
/// An optional environment identifier.
1828+
#[serde(default, skip_serializing_if = "Option::is_none")]
1829+
pub environment: Option<Cow<'a, str>>,
18241830
/// Optional tags to be attached to the event.
18251831
#[serde(default, skip_serializing_if = "Map::is_empty")]
18261832
pub tags: Map<String, String>,
@@ -1852,6 +1858,8 @@ impl<'a> Default for Transaction<'a> {
18521858
event_id: event::default_id(),
18531859
name: Default::default(),
18541860
tags: Default::default(),
1861+
release: Default::default(),
1862+
environment: Default::default(),
18551863
sdk: Default::default(),
18561864
platform: event::default_platform(),
18571865
timestamp: Default::default(),
@@ -1874,6 +1882,8 @@ impl<'a> Transaction<'a> {
18741882
event_id: self.event_id,
18751883
name: self.name,
18761884
tags: self.tags,
1885+
release: self.release.map(|x| Cow::Owned(x.into_owned())),
1886+
environment: self.environment.map(|x| Cow::Owned(x.into_owned())),
18771887
sdk: self.sdk.map(|x| Cow::Owned(x.into_owned())),
18781888
platform: Cow::Owned(self.platform.into_owned()),
18791889
timestamp: self.timestamp,

0 commit comments

Comments
 (0)