Skip to content

Commit

Permalink
feat: Add release/env/sdk to Transactions (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem authored Jan 11, 2022
1 parent 281f3ff commit afcac66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry-core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct Client {
transport: TransportArc,
session_flusher: RwLock<Option<SessionFlusher>>,
integrations: Vec<(TypeId, Arc<dyn Integration>)>,
sdk_info: ClientSdkInfo,
pub(crate) sdk_info: ClientSdkInfo,
}

impl fmt::Debug for Client {
Expand Down
4 changes: 4 additions & 0 deletions sentry-core/src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ impl Transaction {
.insert("trace".into(), inner.context.clone().into());

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

let mut envelope = protocol::Envelope::new();
envelope.add_item(transaction);
Expand Down
10 changes: 10 additions & 0 deletions sentry-types/src/protocol/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,12 @@ pub struct Transaction<'a> {
skip_serializing_if = "Option::is_none"
)]
pub name: Option<String>,
/// A release identifier.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub release: Option<Cow<'a, str>>,
/// An optional environment identifier.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub environment: Option<Cow<'a, str>>,
/// Optional tags to be attached to the event.
#[serde(default, skip_serializing_if = "Map::is_empty")]
pub tags: Map<String, String>,
Expand Down Expand Up @@ -1852,6 +1858,8 @@ impl<'a> Default for Transaction<'a> {
event_id: event::default_id(),
name: Default::default(),
tags: Default::default(),
release: Default::default(),
environment: Default::default(),
sdk: Default::default(),
platform: event::default_platform(),
timestamp: Default::default(),
Expand All @@ -1874,6 +1882,8 @@ impl<'a> Transaction<'a> {
event_id: self.event_id,
name: self.name,
tags: self.tags,
release: self.release.map(|x| Cow::Owned(x.into_owned())),
environment: self.environment.map(|x| Cow::Owned(x.into_owned())),
sdk: self.sdk.map(|x| Cow::Owned(x.into_owned())),
platform: Cow::Owned(self.platform.into_owned()),
timestamp: self.timestamp,
Expand Down

0 comments on commit afcac66

Please sign in to comment.