From 97c78367a2950b91c30ce3bd86243b95cbceac23 Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Fri, 29 Nov 2024 11:36:44 +0100 Subject: [PATCH 1/3] Add sdk.name to events created --- relay-server/src/utils/native.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/relay-server/src/utils/native.rs b/relay-server/src/utils/native.rs index 23d641b94f..44f52b0a4c 100644 --- a/relay-server/src/utils/native.rs +++ b/relay-server/src/utils/native.rs @@ -9,12 +9,15 @@ use std::error::Error; use chrono::{TimeZone, Utc}; use minidump::{MinidumpAnnotation, MinidumpCrashpadInfo, MinidumpModuleList, Module}; use relay_event_schema::protocol::{ - Context, Contexts, Event, Exception, JsonLenientString, Level, Mechanism, Values, + ClientSdkInfo, Context, Contexts, Event, Exception, JsonLenientString, Level, Mechanism, Values, }; use relay_protocol::{Annotated, Value}; type Minidump<'a> = minidump::Minidump<'a, &'a [u8]>; +/// Client SDK name used for the event payload to identify events created out of minidumps. +const CLIENT_SDK_NAME: &str = "minidump"; + /// Placeholder payload fragments indicating a native event. /// /// These payload attributes tell the processing pipeline that the event requires attachment @@ -192,6 +195,12 @@ pub fn process_minidump(event: &mut Event, data: &[u8]) { } }; + // Add sdk information for analytics. + event.client_sdk.get_or_insert_with(|| ClientSdkInfo { + name: Annotated::new(CLIENT_SDK_NAME.to_owned()), + ..Default::default() + }); + // Use the minidump's timestamp as the event's primary time. This timestamp can lie multiple // days in the past, in which case the event may be rejected in store normalization. let timestamp = Utc From 0dbccd214497f3735e3ae55675e8503d98f07ccc Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Fri, 29 Nov 2024 11:47:28 +0100 Subject: [PATCH 2/3] small fix --- relay-server/src/utils/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-server/src/utils/native.rs b/relay-server/src/utils/native.rs index 44f52b0a4c..45d22ea275 100644 --- a/relay-server/src/utils/native.rs +++ b/relay-server/src/utils/native.rs @@ -198,7 +198,7 @@ pub fn process_minidump(event: &mut Event, data: &[u8]) { // Add sdk information for analytics. event.client_sdk.get_or_insert_with(|| ClientSdkInfo { name: Annotated::new(CLIENT_SDK_NAME.to_owned()), - ..Default::default() + ..ClientSdkInfo::default() }); // Use the minidump's timestamp as the event's primary time. This timestamp can lie multiple From 5391fb49c5a6806ad13cf4921187646f796b99ff Mon Sep 17 00:00:00 2001 From: tobias-wilfert Date: Fri, 29 Nov 2024 13:51:06 +0100 Subject: [PATCH 3/3] Made sdk name more specific, added changelog and attempted to find test that can be expanded --- CHANGELOG.md | 1 + relay-server/src/utils/native.rs | 16 ++++++++++++---- tests/integration/test_minidump.py | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ad8385cf5..fd9c3d8528 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ **Features:** +- Set `sdk.name` for events created from minidumps. ([#4313](https://github.com/getsentry/relay/pull/4313)) - Retain empty string values in `span.data` and `event.contexts.trace.data`. ([#4174](https://github.com/getsentry/relay/pull/4174)) - Allow `sample_rate` to be float type when deserializing `DynamicSamplingContext`. ([#4181](https://github.com/getsentry/relay/pull/4181)) - Support inbound filters for profiles. ([#4176](https://github.com/getsentry/relay/pull/4176)) diff --git a/relay-server/src/utils/native.rs b/relay-server/src/utils/native.rs index 45d22ea275..bc9c32a169 100644 --- a/relay-server/src/utils/native.rs +++ b/relay-server/src/utils/native.rs @@ -15,9 +15,6 @@ use relay_protocol::{Annotated, Value}; type Minidump<'a> = minidump::Minidump<'a, &'a [u8]>; -/// Client SDK name used for the event payload to identify events created out of minidumps. -const CLIENT_SDK_NAME: &str = "minidump"; - /// Placeholder payload fragments indicating a native event. /// /// These payload attributes tell the processing pipeline that the event requires attachment @@ -195,9 +192,20 @@ pub fn process_minidump(event: &mut Event, data: &[u8]) { } }; + let client_sdk_name = if minidump.get_stream::().is_ok() { + "minidump.crashpad" + } else if minidump + .get_stream::() + .is_ok() + { + "minidump.breakpad" + } else { + "minidump.unknown" + }; + // Add sdk information for analytics. event.client_sdk.get_or_insert_with(|| ClientSdkInfo { - name: Annotated::new(CLIENT_SDK_NAME.to_owned()), + name: Annotated::new(client_sdk_name.to_owned()), ..ClientSdkInfo::default() }); diff --git a/tests/integration/test_minidump.py b/tests/integration/test_minidump.py index b4c4bba378..1d12c136bb 100644 --- a/tests/integration/test_minidump.py +++ b/tests/integration/test_minidump.py @@ -448,6 +448,9 @@ def test_minidump_with_processing( # Check information extracted from the minidump assert event["timestamp"] == 1574692481.0 # 11/25/2019 @ 2:34pm (UTC) + # Check that the SDK name is correctly detected + assert event["sdk"]["name"] == "minidump.unknown" + assert list(message["attachments"]) == [ { "id": attachment_id,