|
39 | 39 |
|
40 | 40 | # pragma mark - Private |
41 | 41 |
|
42 | | -namespace { |
43 | | - |
44 | 42 | /** |
45 | 43 | * Given an array of samples with absolute timestamps, return the serialized JSON mapping with |
46 | 44 | * their data, with timestamps normalized relative to the provided transaction's start time. |
|
49 | 47 | _sentry_serializedTraceProfileSamplesWithRelativeTimestamps( |
50 | 48 | NSArray<SentrySample *> *samples, uint64_t startSystemTime) |
51 | 49 | { |
52 | | - const auto result = [NSMutableArray<NSDictionary *> array]; |
| 50 | + NSMutableArray<NSDictionary *> *result = [NSMutableArray<NSDictionary *> array]; |
53 | 51 | [samples enumerateObjectsUsingBlock:^( |
54 | 52 | SentrySample *_Nonnull sample, NSUInteger idx, BOOL *_Nonnull stop) { |
55 | 53 | // This shouldn't happen as we would've filtered out any such samples, but we should still |
|
58 | 56 | SENTRY_LOG_WARN(@"Filtering sample as it came before start time to begin slicing."); |
59 | 57 | return; |
60 | 58 | } |
61 | | - const auto dict = [NSMutableDictionary dictionary]; |
62 | | - const auto durationNs = getDurationNs(startSystemTime, sample.absoluteTimestamp); |
| 59 | + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; |
| 60 | + uint64_t durationNs = getDurationNs(startSystemTime, sample.absoluteTimestamp); |
63 | 61 | dict[@"elapsed_since_start_ns"] = sentry_stringForUInt64(durationNs); |
64 | 62 |
|
65 | 63 | dict[@"thread_id"] = sentry_stringForUInt64(sample.threadID); |
|
81 | 79 | NSArray<NSDictionary *> * |
82 | 80 | _sentry_serializedContinuousProfileSamples(NSArray<SentrySample *> *samples) |
83 | 81 | { |
84 | | - const auto result = [NSMutableArray<NSDictionary *> array]; |
| 82 | + NSMutableArray<NSDictionary *> *result = [NSMutableArray<NSDictionary *> array]; |
85 | 83 | [samples enumerateObjectsUsingBlock:^( |
86 | 84 | SentrySample *_Nonnull sample, NSUInteger idx, BOOL *_Nonnull stop) { |
87 | | - const auto dict = [NSMutableDictionary dictionary]; |
| 85 | + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; |
88 | 86 | dict[@"timestamp"] = @(sample.absoluteNSDateInterval); |
89 | 87 | dict[@"thread_id"] = sentry_stringForUInt64(sample.threadID); |
90 | 88 | dict[@"stack_id"] = sample.stackIndex; |
|
96 | 94 | return result; |
97 | 95 | } |
98 | 96 |
|
99 | | -} // namespace |
100 | | - |
101 | 97 | # pragma mark - Exported for tests |
102 | 98 |
|
103 | 99 | NSString * |
|
136 | 132 | } |
137 | 133 |
|
138 | 134 | // slice the profile data to only include the samples/metrics within the transaction |
139 | | - const auto slicedSamples = sentry_slicedProfileSamples(samples, startSystemTime, endSystemTime); |
| 135 | + NSArray<SentrySample *> *slicedSamples |
| 136 | + = sentry_slicedProfileSamples(samples, startSystemTime, endSystemTime); |
140 | 137 | if (slicedSamples.count < 2) { |
141 | 138 | SENTRY_LOG_DEBUG(@"Not enough samples in profile during the transaction"); |
142 | 139 | [hub.getClient recordLostEvent:kSentryDataCategoryProfile |
143 | 140 | reason:kSentryDiscardReasonEventProcessor]; |
144 | 141 | return nil; |
145 | 142 | } |
146 | | - const auto payload = [NSMutableDictionary<NSString *, id> dictionary]; |
| 143 | + NSMutableDictionary<NSString *, id> *payload = [NSMutableDictionary<NSString *, id> dictionary]; |
147 | 144 | NSMutableDictionary<NSString *, id> *const profile = [profileData[@"profile"] mutableCopy]; |
148 | 145 | profile[@"samples"] = _sentry_serializedTraceProfileSamplesWithRelativeTimestamps( |
149 | 146 | slicedSamples, startSystemTime); |
150 | 147 | payload[@"profile"] = profile; |
151 | 148 |
|
152 | 149 | payload[@"version"] = @"1"; |
153 | | - const auto debugImages = [NSMutableArray<NSDictionary<NSString *, id> *> new]; |
| 150 | + NSMutableArray<NSDictionary<NSString *, id> *> *debugImages = |
| 151 | + [NSMutableArray<NSDictionary<NSString *, id> *> new]; |
154 | 152 | for (SentryDebugMeta *debugImage in debugMeta) { |
155 | 153 | [debugImages addObject:[debugImage serialize]]; |
156 | 154 | } |
|
164 | 162 | @"build_number" : sentry_getOSBuildNumber() |
165 | 163 | }; |
166 | 164 |
|
167 | | - const auto isEmulated = sentry_isSimulatorBuild(); |
| 165 | + bool isEmulated = sentry_isSimulatorBuild(); |
168 | 166 | payload[@"device"] = @{ |
169 | 167 | @"architecture" : sentry_getCPUArchitecture(), |
170 | 168 | @"is_emulator" : @(isEmulated), |
|
179 | 177 | payload[@"release"] = hub.getClient.options.releaseName; |
180 | 178 |
|
181 | 179 | // add the gathered metrics |
182 | | - auto metrics = serializedMetrics; |
| 180 | + NSDictionary<NSString *, id> *metrics = serializedMetrics; |
183 | 181 |
|
184 | 182 | # if SENTRY_HAS_UIKIT |
185 | | - const auto mutableMetrics = |
| 183 | + NSMutableDictionary<NSString *, id> *mutableMetrics = |
186 | 184 | [NSMutableDictionary<NSString *, id> dictionaryWithDictionary:metrics]; |
187 | | - const auto slowFrames = sentry_sliceTraceProfileGPUData(gpuData.slowFrameTimestamps, |
188 | | - startSystemTime, endSystemTime, /*useMostRecentFrameRate */ NO); |
| 185 | + NSArray<SentrySerializedMetricEntry *> *slowFrames |
| 186 | + = sentry_sliceTraceProfileGPUData(gpuData.slowFrameTimestamps, startSystemTime, |
| 187 | + endSystemTime, /*useMostRecentFrameRate */ NO); |
189 | 188 | if (slowFrames.count > 0) { |
190 | 189 | mutableMetrics[kSentryProfilerSerializationKeySlowFrameRenders] = |
191 | 190 | @ { @"unit" : @"nanosecond", @"values" : slowFrames }; |
192 | 191 | } |
193 | 192 |
|
194 | | - const auto frozenFrames = sentry_sliceTraceProfileGPUData(gpuData.frozenFrameTimestamps, |
195 | | - startSystemTime, endSystemTime, |
| 193 | + NSArray<SentrySerializedMetricEntry *> *frozenFrames = sentry_sliceTraceProfileGPUData( |
| 194 | + gpuData.frozenFrameTimestamps, startSystemTime, endSystemTime, |
196 | 195 | /*useMostRecentFrameRate */ NO); |
197 | 196 | if (frozenFrames.count > 0) { |
198 | 197 | mutableMetrics[kSentryProfilerSerializationKeyFrozenFrameRenders] = |
199 | 198 | @ { @"unit" : @"nanosecond", @"values" : frozenFrames }; |
200 | 199 | } |
201 | 200 |
|
202 | 201 | if (slowFrames.count > 0 || frozenFrames.count > 0) { |
203 | | - const auto frameRates = sentry_sliceTraceProfileGPUData(gpuData.frameRateTimestamps, |
204 | | - startSystemTime, endSystemTime, |
| 202 | + NSArray<SentrySerializedMetricEntry *> *frameRates = sentry_sliceTraceProfileGPUData( |
| 203 | + gpuData.frameRateTimestamps, startSystemTime, endSystemTime, |
205 | 204 | /*useMostRecentFrameRate */ YES); |
206 | 205 | if (frameRates.count > 0) { |
207 | 206 | mutableMetrics[kSentryProfilerSerializationKeyFrameRates] = |
|
236 | 235 | // profiling session, to count the number of total samples sent so far, to decide whether or not |
237 | 236 | // a 1-sample chunk is acceptable. |
238 | 237 |
|
239 | | - const auto payload = [NSMutableDictionary<NSString *, id> dictionary]; |
| 238 | + NSMutableDictionary<NSString *, id> *payload = [NSMutableDictionary<NSString *, id> dictionary]; |
240 | 239 | NSMutableDictionary<NSString *, id> *const profile = [profileData[@"profile"] mutableCopy]; |
241 | 240 | profile[@"samples"] = _sentry_serializedContinuousProfileSamples(samples); |
242 | 241 |
|
243 | 242 | payload[@"profile"] = profile; |
244 | 243 |
|
245 | 244 | payload[@"version"] = @"2"; |
246 | | - const auto debugImages = [NSMutableArray<NSDictionary<NSString *, id> *> new]; |
| 245 | + NSMutableArray<NSDictionary<NSString *, id> *> *debugImages = |
| 246 | + [NSMutableArray<NSDictionary<NSString *, id> *> new]; |
247 | 247 | for (SentryDebugMeta *debugImage in debugMeta) { |
248 | 248 | [debugImages addObject:[debugImage serialize]]; |
249 | 249 | } |
|
257 | 257 | payload[@"release"] = hub.getClient.options.releaseName; |
258 | 258 | payload[@"platform"] = SentryPlatformName; |
259 | 259 |
|
260 | | - const auto clientInfo = [NSMutableDictionary dictionary]; |
| 260 | + NSMutableDictionary *clientInfo = [NSMutableDictionary dictionary]; |
261 | 261 | clientInfo[@"name"] = SentryMeta.sdkName; |
262 | 262 | clientInfo[@"version"] = SentryMeta.versionString; |
263 | 263 | payload[@"client_sdk"] = clientInfo; |
264 | 264 |
|
265 | 265 | // add the gathered metrics |
266 | | - auto metrics = serializedMetrics; |
| 266 | + NSDictionary<NSString *, id> *metrics = serializedMetrics; |
267 | 267 |
|
268 | 268 | # if SENTRY_HAS_UIKIT |
269 | | - const auto mutableMetrics = |
| 269 | + NSMutableDictionary<NSString *, id> *mutableMetrics = |
270 | 270 | [NSMutableDictionary<NSString *, id> dictionaryWithDictionary:metrics]; |
271 | 271 | if (gpuData.slowFrameTimestamps.count > 0) { |
272 | | - const auto values = [NSMutableDictionary dictionary]; |
| 272 | + NSMutableDictionary *values = [NSMutableDictionary dictionary]; |
273 | 273 | values[@"unit"] = @"nanosecond"; |
274 | 274 | values[@"values"] = gpuData.slowFrameTimestamps; |
275 | 275 | mutableMetrics[kSentryProfilerSerializationKeySlowFrameRenders] = values; |
276 | 276 | } |
277 | 277 |
|
278 | 278 | if (gpuData.frozenFrameTimestamps.count > 0) { |
279 | | - const auto values = [NSMutableDictionary dictionary]; |
| 279 | + NSMutableDictionary *values = [NSMutableDictionary dictionary]; |
280 | 280 | values[@"unit"] = @"nanosecond"; |
281 | 281 | values[@"values"] = gpuData.frozenFrameTimestamps; |
282 | 282 | mutableMetrics[kSentryProfilerSerializationKeyFrozenFrameRenders] = values; |
283 | 283 | } |
284 | 284 |
|
285 | 285 | if (gpuData.slowFrameTimestamps.count > 0 || gpuData.frozenFrameTimestamps.count > 0) { |
286 | 286 | if (gpuData.frameRateTimestamps.count > 0) { |
287 | | - const auto values = [NSMutableDictionary dictionary]; |
| 287 | + NSMutableDictionary *values = [NSMutableDictionary dictionary]; |
288 | 288 | values[@"unit"] = @"hz"; |
289 | 289 | values[@"values"] = gpuData.frameRateTimestamps; |
290 | 290 | mutableMetrics[kSentryProfilerSerializationKeyFrameRates] = values; |
|
310 | 310 | # endif // SENTRY_HAS_UIKIT |
311 | 311 | ) |
312 | 312 | { |
313 | | - const auto chunkID = [[SentryId alloc] init]; |
314 | | - const auto payload = sentry_serializedContinuousProfileChunk( |
| 313 | + SentryId *chunkID = [[SentryId alloc] init]; |
| 314 | + NSMutableDictionary<NSString *, id> *payload = sentry_serializedContinuousProfileChunk( |
315 | 315 | profileID, chunkID, profileState, metricProfilerState, |
316 | 316 | [SentryDependencyContainer.sharedInstance.debugImageProvider getDebugImagesFromCache], |
317 | 317 | SentrySDK.currentHub |
|
326 | 326 | return nil; |
327 | 327 | } |
328 | 328 |
|
329 | | - const auto JSONData = [SentrySerialization dataWithJSONObject:payload]; |
| 329 | + NSData *JSONData = [SentrySerialization dataWithJSONObject:payload]; |
330 | 330 | if (JSONData == nil) { |
331 | 331 | SENTRY_LOG_DEBUG(@"Failed to encode profile to JSON."); |
332 | 332 | return nil; |
|
343 | 343 | } |
344 | 344 | # endif // defined(SENTRY_TEST) || defined(SENTRY_TEST_CI) |
345 | 345 |
|
346 | | - const auto header = |
| 346 | + SentryEnvelopeItemHeader *header = |
347 | 347 | [[SentryEnvelopeItemHeader alloc] initWithType:SentryEnvelopeItemTypeProfileChunk |
348 | 348 | length:JSONData.length]; |
349 | 349 | header.platform = @"cocoa"; |
350 | | - const auto envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:header data:JSONData]; |
| 350 | + SentryEnvelopeItem *envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:header |
| 351 | + data:JSONData]; |
351 | 352 |
|
352 | 353 | return [[SentryEnvelope alloc] initWithId:chunkID singleItem:envelopeItem]; |
353 | 354 | } |
|
356 | 357 | SentryProfiler *profiler, NSDictionary<NSString *, id> *profilingData, |
357 | 358 | SentryTransaction *transaction, NSDate *startTimestamp) |
358 | 359 | { |
359 | | - const auto images = |
| 360 | + NSArray<SentryDebugMeta *> *images = |
360 | 361 | [SentryDependencyContainer.sharedInstance.debugImageProvider getDebugImagesFromCache]; |
361 | | - const auto payload = sentry_serializedTraceProfileData( |
| 362 | + NSMutableDictionary<NSString *, id> *payload = sentry_serializedTraceProfileData( |
362 | 363 | profilingData, transaction.startSystemTime, transaction.endSystemTime, |
363 | 364 | sentry_profilerTruncationReasonName(profiler.truncationReason), |
364 | 365 | [profiler.metricProfiler serializeTraceProfileMetricsBetween:transaction.startSystemTime |
|
384 | 385 | }; |
385 | 386 | payload[@"timestamp"] = sentry_toIso8601String(startTimestamp); |
386 | 387 |
|
387 | | - const auto JSONData = [SentrySerialization dataWithJSONObject:payload]; |
| 388 | + NSData *JSONData = [SentrySerialization dataWithJSONObject:payload]; |
388 | 389 | if (JSONData == nil) { |
389 | 390 | SENTRY_LOG_DEBUG(@"Failed to encode profile to JSON."); |
390 | 391 | return nil; |
|
394 | 395 | sentry_writeProfileFile(JSONData, false /*continuous*/); |
395 | 396 | # endif // defined(SENTRY_TEST) || defined(SENTRY_TEST_CI) |
396 | 397 |
|
397 | | - const auto header = [[SentryEnvelopeItemHeader alloc] initWithType:SentryEnvelopeItemTypeProfile |
398 | | - length:JSONData.length]; |
| 398 | + SentryEnvelopeItemHeader *header = |
| 399 | + [[SentryEnvelopeItemHeader alloc] initWithType:SentryEnvelopeItemTypeProfile |
| 400 | + length:JSONData.length]; |
399 | 401 | return [[SentryEnvelopeItem alloc] initWithHeader:header data:JSONData]; |
400 | 402 | } |
401 | 403 |
|
402 | 404 | NSMutableDictionary<NSString *, id> *_Nullable sentry_collectProfileDataHybridSDK( |
403 | 405 | uint64_t startSystemTime, uint64_t endSystemTime, SentryId *traceId, SentryHub *hub) |
404 | 406 | { |
405 | | - const auto profiler = sentry_profilerForFinishedTracer(traceId); |
| 407 | + SentryProfiler *profiler = sentry_profilerForFinishedTracer(traceId); |
406 | 408 | if (!profiler) { |
407 | 409 | return nil; |
408 | 410 | } |
|
0 commit comments