From 26003e67900f5da520eb34ee23c56bc3d1641a2e Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Sat, 26 Aug 2023 14:05:13 +0200 Subject: [PATCH] add thread ID to hybrid SDK profile payload --- Sentry.xcodeproj/project.pbxproj | 8 ++++---- .../{PrivateSentrySDKOnly.m => PrivateSentrySDKOnly.mm} | 5 +++++ Tests/SentryTests/PrivateSentrySDKOnlyTests.swift | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) rename Sources/Sentry/{PrivateSentrySDKOnly.m => PrivateSentrySDKOnly.mm} (96%) diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 7a820c7fef0..2686da382d0 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -377,7 +377,7 @@ 7B6C5F8126034354007F7DFF /* SentryWatchdogTerminationLogic.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6C5F8026034354007F7DFF /* SentryWatchdogTerminationLogic.h */; }; 7B6C5F8726034395007F7DFF /* SentryWatchdogTerminationLogic.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5F8626034395007F7DFF /* SentryWatchdogTerminationLogic.m */; }; 7B6CC50224EE5A42001816D7 /* SentryHubTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6CC50124EE5A42001816D7 /* SentryHubTests.swift */; }; - 7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.m */; }; + 7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.mm */; }; 7B6D1263265F7CC600C9BE4B /* PrivateSentrySDKOnlyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D1262265F7CC600C9BE4B /* PrivateSentrySDKOnlyTests.swift */; }; 7B6D135C27F4605D00331ED2 /* TestEnvelopeRateLimitDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D135B27F4605D00331ED2 /* TestEnvelopeRateLimitDelegate.swift */; }; 7B6D98E924C6D336005502FA /* SentrySdkInfo+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6D98E824C6D336005502FA /* SentrySdkInfo+Equality.m */; }; @@ -1277,7 +1277,7 @@ 7B6C5F8026034354007F7DFF /* SentryWatchdogTerminationLogic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryWatchdogTerminationLogic.h; path = include/SentryWatchdogTerminationLogic.h; sourceTree = ""; }; 7B6C5F8626034395007F7DFF /* SentryWatchdogTerminationLogic.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryWatchdogTerminationLogic.m; sourceTree = ""; }; 7B6CC50124EE5A42001816D7 /* SentryHubTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryHubTests.swift; sourceTree = ""; }; - 7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrivateSentrySDKOnly.m; sourceTree = ""; }; + 7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateSentrySDKOnly.mm; sourceTree = ""; }; 7B6D1262265F7CC600C9BE4B /* PrivateSentrySDKOnlyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateSentrySDKOnlyTests.swift; sourceTree = ""; }; 7B6D135B27F4605D00331ED2 /* TestEnvelopeRateLimitDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestEnvelopeRateLimitDelegate.swift; sourceTree = ""; }; 7B6D98E724C6D336005502FA /* SentrySdkInfo+Equality.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentrySdkInfo+Equality.h"; sourceTree = ""; }; @@ -2286,7 +2286,7 @@ 63AA76931EB9C1C200D153DE /* Sentry.h */, D8BBD32628FD9FBF0011F850 /* SentrySwift.h */, D81A346B291AECC7005A27A9 /* PrivateSentrySDKOnly.h */, - 7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.m */, + 7B6D1260265F784000C9BE4B /* PrivateSentrySDKOnly.mm */, 63AA76941EB9C1C200D153DE /* SentryClient.h */, 63AA75ED1EB8B3C400D153DE /* SentryClient.m */, 7B85DC1C24EFAFCD007D01D2 /* SentryClient+Private.h */, @@ -4092,7 +4092,7 @@ 7BE1E33424F7E3CB009D3AD0 /* SentryMigrateSessionInit.m in Sources */, 15E0A8F22411A45A00F044E3 /* SentrySession.m in Sources */, 844EDCE62947DC3100C86F34 /* SentryNSTimerFactory.m in Sources */, - 7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.m in Sources */, + 7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.mm in Sources */, 63BE85711ECEC6DE00DC44F5 /* NSDate+SentryExtras.m in Sources */, 7BD4BD4927EB2A5D0071F4FF /* SentryDiscardedEvent.m in Sources */, 03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */, diff --git a/Sources/Sentry/PrivateSentrySDKOnly.m b/Sources/Sentry/PrivateSentrySDKOnly.mm similarity index 96% rename from Sources/Sentry/PrivateSentrySDKOnly.m rename to Sources/Sentry/PrivateSentrySDKOnly.mm index f65a42aef68..befce66fe20 100644 --- a/Sources/Sentry/PrivateSentrySDKOnly.m +++ b/Sources/Sentry/PrivateSentrySDKOnly.mm @@ -12,6 +12,7 @@ #import "SentryProfiler.h" #import "SentrySDK+Private.h" #import "SentrySerialization.h" +#import "SentryThreadHandle.hpp" #import "SentryUser+Private.h" #import "SentryViewHierarchy.h" #import @@ -140,6 +141,10 @@ + (uint64_t)startProfilerForTrace:(SentryId *)traceId; if (payload != nil) { payload[@"platform"] = SentryPlatformName; + payload[@"transaction"] = @{ + @"active_thread_id" : + [NSNumber numberWithLongLong:sentry::profiling::ThreadHandle::current()->tid()] + }; } return payload; diff --git a/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift b/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift index 679dc45599a..908cfc3d4e3 100644 --- a/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift +++ b/Tests/SentryTests/PrivateSentrySDKOnlyTests.swift @@ -146,6 +146,9 @@ class PrivateSentrySDKOnlyTests: XCTestCase { XCTAssertNotNil(profile?["samples"]) XCTAssertNotNil(profile?["stacks"]) XCTAssertNotNil(profile?["frames"]) + let transactionInfo = payload?["transaction"] as? NSDictionary + XCTAssertNotNil(transactionInfo) + XCTAssertGreaterThan(transactionInfo?["active_thread_id"] as! Int64, 0) } func testProfilingDiscard() {