Skip to content

Commit

Permalink
feat(spans): Extract release tag from the transaction to the span (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
iker-barriocanal authored Jun 9, 2023
1 parent a013cca commit dca9fb7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
21 changes: 17 additions & 4 deletions relay-server/src/metrics_extraction/spans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ pub(crate) fn extract_span_metrics(
return Err(ExtractMetricsError::InvalidTimestamp);
}

// Collect data for the databag that isn't metrics
let mut databag = BTreeMap::new();

if let Some(release) = event.release.as_str() {
databag.insert("release".to_owned(), release.to_owned());
}

// Collect the shared tags for all the metrics and spans on this transaction.
let mut shared_tags = BTreeMap::new();

Expand Down Expand Up @@ -180,12 +187,18 @@ pub(crate) fn extract_span_metrics(
// represent a risk for the indexers.

// Even if we emit metrics, we want this info to be duplicated in every span.
span.data.get_or_insert_with(BTreeMap::new).extend(
span_tags
span.data.get_or_insert_with(BTreeMap::new).extend({
let it = span_tags
.clone()
.into_iter()
.map(|(k, v)| (k, Annotated::new(Value::String(v)))),
);
.map(|(k, v)| (k, Annotated::new(Value::String(v))));
it.chain(
databag
.clone()
.into_iter()
.map(|(k, v)| (k, Annotated::new(Value::String(v)))),
)
});

if let Some(user) = event.user.value() {
if let Some(value) = get_eventuser_tag(user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.op": String(
"react.mount",
),
Expand Down Expand Up @@ -70,6 +73,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.category": String(
"ui.react",
),
Expand Down Expand Up @@ -117,6 +123,9 @@ expression: event.value().unwrap().spans
"http.method": String(
"PoSt",
),
"release": String(
"1.2.3",
),
"span.action": String(
"POST",
),
Expand Down Expand Up @@ -179,6 +188,9 @@ expression: event.value().unwrap().spans
"http.method": String(
"POST",
),
"release": String(
"1.2.3",
),
"span.action": String(
"POST",
),
Expand Down Expand Up @@ -244,6 +256,9 @@ expression: event.value().unwrap().spans
"http.method": String(
"POST",
),
"release": String(
"1.2.3",
),
"span.action": String(
"POST",
),
Expand Down Expand Up @@ -318,6 +333,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"SELECT",
),
Expand Down Expand Up @@ -386,6 +404,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"SELECT",
),
Expand Down Expand Up @@ -454,6 +475,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"INSERT",
),
Expand Down Expand Up @@ -519,6 +543,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"INSERT",
),
Expand Down Expand Up @@ -578,6 +605,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"INSERT",
),
Expand Down Expand Up @@ -640,6 +670,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"SELECT",
),
Expand Down Expand Up @@ -705,6 +738,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"SELECT",
),
Expand Down Expand Up @@ -773,6 +809,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.action": String(
"SELECT",
),
Expand Down Expand Up @@ -844,6 +883,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.category": String(
"db",
),
Expand Down Expand Up @@ -909,6 +951,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.category": String(
"cache",
),
Expand Down Expand Up @@ -968,6 +1013,9 @@ expression: event.value().unwrap().spans
"environment": String(
"fake_environment",
),
"release": String(
"1.2.3",
),
"span.category": String(
"resource",
),
Expand Down

0 comments on commit dca9fb7

Please sign in to comment.