Skip to content

Commit

Permalink
fix: Use correct Transaction props (#405)
Browse files Browse the repository at this point in the history
The transaction data is called `extra`, and its status is part of the trace context.
  • Loading branch information
Swatinem authored Jan 13, 2022
1 parent d35e0e1 commit b907d6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 3 additions & 5 deletions sentry-core/src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,20 @@ impl Transaction {
pub fn set_data(&self, key: &str, value: protocol::Value) {
let mut inner = self.inner.lock().unwrap();
if let Some(transaction) = inner.transaction.as_mut() {
transaction.data.insert(key.into(), value);
transaction.extra.insert(key.into(), value);
}
}

/// Get the status of the Transaction.
pub fn get_status(&self) -> Option<protocol::SpanStatus> {
let inner = self.inner.lock().unwrap();
inner.transaction.as_ref().and_then(|tx| tx.status)
inner.context.status
}

/// Set the status of the Transaction.
pub fn set_status(&self, status: protocol::SpanStatus) {
let mut inner = self.inner.lock().unwrap();
if let Some(transaction) = inner.transaction.as_mut() {
transaction.status = Some(status);
}
inner.context.status = Some(status);
}

/// Returns the headers needed for distributed tracing.
Expand Down
11 changes: 3 additions & 8 deletions sentry-types/src/protocol/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ pub struct Transaction<'a> {
pub tags: Map<String, String>,
/// Optional extra information to be sent with the event.
#[serde(default, skip_serializing_if = "Map::is_empty")]
pub data: Map<String, Value>,
pub extra: Map<String, Value>,
/// SDK metadata
#[serde(default, skip_serializing_if = "Option::is_none")]
pub sdk: Option<Cow<'a, ClientSdkInfo>>,
Expand All @@ -1848,9 +1848,6 @@ pub struct Transaction<'a> {
/// The start time of the transaction.
#[serde(default = "event::default_timestamp", with = "ts_seconds_float")]
pub start_timestamp: DateTime<Utc>,
/// Describes the status of the span (e.g. `ok`, `cancelled`, etc.)
#[serde(default, skip_serializing_if = "Option::is_none")]
pub status: Option<SpanStatus>,
/// The collection of finished spans part of this transaction.
pub spans: Vec<Span>,
/// Optional contexts.
Expand All @@ -1864,14 +1861,13 @@ impl<'a> Default for Transaction<'a> {
event_id: event::default_id(),
name: Default::default(),
tags: Default::default(),
data: Default::default(),
extra: Default::default(),
release: Default::default(),
environment: Default::default(),
sdk: Default::default(),
platform: event::default_platform(),
timestamp: Default::default(),
start_timestamp: event::default_timestamp(),
status: Default::default(),
spans: Default::default(),
contexts: Default::default(),
}
Expand All @@ -1890,14 +1886,13 @@ impl<'a> Transaction<'a> {
event_id: self.event_id,
name: self.name,
tags: self.tags,
data: self.data,
extra: self.extra,
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,
start_timestamp: self.start_timestamp,
status: self.status,
spans: self.spans,
contexts: self.contexts,
}
Expand Down

0 comments on commit b907d6f

Please sign in to comment.