Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
# if SENTRY_HAS_UIKIT
profiler.screenFrameData =
[SentryDependencyContainer.sharedInstance.framesTracker.currentFrames copy];
SENTRY_LOG_DEBUG(
@"Grabbing copy of frames tracker screen frames data to attach to profiler: %@.",
profiler.screenFrameData);
if (_gProfilersToTracers.count == 0) {
[SentryDependencyContainer.sharedInstance.framesTracker resetProfilingTimestamps];
}
Expand Down
18 changes: 15 additions & 3 deletions Sources/Sentry/Profiling/SentryProfilerState.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "SentryProfilerState.h"
#if SENTRY_TARGET_PROFILING_SUPPORTED
# import "SentryAsyncSafeLog.h"
# import "SentryBacktrace.hpp"
# import "SentryDependencyContainer.h"
# import "SentryDispatchQueueWrapper.h"
Expand Down Expand Up @@ -121,7 +122,8 @@ - (void)appendBacktrace:(const Backtrace &)backtrace
const auto symbols
= backtrace_symbols(reinterpret_cast<void *const *>(backtrace.addresses.data()),
static_cast<int>(backtrace.addresses.size()));
# endif
const auto *backtraceFunctionNames = [NSMutableArray<NSString *> array];
# endif // defined(DEBUG)

const auto stack = [NSMutableArray<NSNumber *> array];
for (std::vector<uintptr_t>::size_type backtraceAddressIdx = 0;
Expand All @@ -133,8 +135,10 @@ - (void)appendBacktrace:(const Backtrace &)backtrace
const auto frame = [NSMutableDictionary<NSString *, id> dictionary];
frame[@"instruction_addr"] = instructionAddress;
# if defined(DEBUG)
frame[@"function"]
const auto functionName
= parseBacktraceSymbolsFunctionName(symbols[backtraceAddressIdx]);
frame[@"function"] = functionName;
[backtraceFunctionNames addObject:functionName];
# endif
const auto newFrameIndex = @(state.frames.count);
[stack addObject:newFrameIndex];
Expand All @@ -146,7 +150,7 @@ - (void)appendBacktrace:(const Backtrace &)backtrace
}
# if defined(DEBUG)
free(symbols);
# endif
# endif // defined(DEBUG)

const auto sample = [[SentrySample alloc] init];
sample.absoluteTimestamp = backtrace.absoluteTimestamp;
Expand All @@ -165,6 +169,14 @@ - (void)appendBacktrace:(const Backtrace &)backtrace
[state.stacks addObject:stack];
}

# if defined(DEBUG)
if (backtraceFunctionNames.count > 0) {
SENTRY_ASYNC_SAFE_LOG_DEBUG("Recorded backtrace for thread %s at %llu: %s",
threadID.UTF8String, sample.absoluteTimestamp,
backtraceFunctionNames.description.UTF8String);
}
# endif // defined(DEBUG)

[state.samples addObject:sample];
}];
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryFramesTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ - (void)resetProfilingTimestamps

- (void)resetProfilingTimestampsInternal
{
SENTRY_LOG_DEBUG(@"Resetting profiling GPU timeseries data.");
self.frozenFrameTimestamps = [SentryMutableFrameInfoTimeSeries array];
self.slowFrameTimestamps = [SentryMutableFrameInfoTimeSeries array];
self.frameRateTimestamps = [SentryMutableFrameInfoTimeSeries array];
Expand Down
7 changes: 5 additions & 2 deletions Sources/Sentry/SentryHttpTransport.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,14 @@ - (void)sendAllCachedEnvelopes

SentryEnvelope *envelope = [SentrySerialization envelopeWithData:envelopeFileContents.contents];
if (nil == envelope) {
SENTRY_LOG_DEBUG(@"Envelope contained no deserializable data.");
[self deleteEnvelopeAndSendNext:envelopeFileContents.path];
return;
}

SentryEnvelope *rateLimitedEnvelope = [self.envelopeRateLimit removeRateLimitedItems:envelope];
if (rateLimitedEnvelope.items.count == 0) {
SENTRY_LOG_DEBUG(@"Envelope had no rate-limited items, nothing to send.");
[self deleteEnvelopeAndSendNext:envelopeFileContents.path];
return;
}
Expand All @@ -313,6 +315,7 @@ - (void)sendAllCachedEnvelopes
didFailWithError:&requestError];

if (nil != requestError) {
SENTRY_LOG_DEBUG(@"Failed to build request: %@.", requestError);
[self recordLostEventFor:rateLimitedEnvelope.items];
[self deleteEnvelopeAndSendNext:envelopeFileContents.path];
return;
Expand Down Expand Up @@ -354,12 +357,13 @@ - (void)sendEnvelope:(SentryEnvelope *)envelope
return;
}

// If the response is not nil we had an internet connection.
if (error && response.statusCode != 429) {
SENTRY_LOG_DEBUG(@"Request error other than rate limit: %@", error);
[weakSelf recordLostEventFor:envelope.items];
}

if (nil != response) {
SENTRY_LOG_DEBUG(@"Envelope sent successfully!");
[weakSelf.rateLimits update:response];
[weakSelf deleteEnvelopeAndSendNext:envelopePath];
} else {
Expand All @@ -371,7 +375,6 @@ - (void)sendEnvelope:(SentryEnvelope *)envelope

- (void)finishedSending
{
SENTRY_LOG_DEBUG(@"Finished sending.");
@synchronized(self) {
self.isSending = NO;
if (self.isFlushing) {
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/SentryNSURLRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ - (instancetype)initEnvelopeRequestWithURL:(NSURL *)url
forHTTPHeaderField:@"User-Agent"];
[self setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
self.HTTPBody = sentry_gzippedWithCompressionLevel(data, -1, error);

SENTRY_LOG_DEBUG(@"Constructed request: %@", self);
}

return self;
Expand Down
13 changes: 13 additions & 0 deletions Sources/Sentry/SentryScreenFrames.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ - (nonnull id)copyWithZone:(nullable NSZone *)zone

# endif // SENTRY_TARGET_PROFILING_SUPPORTED

- (NSString *)description
{
NSMutableString *result = [NSMutableString
stringWithFormat:@"Total frames: %lu; slow frames: %lu; frozen frames: %lu",
(unsigned long)_total, (unsigned long)_slow, (unsigned long)_frozen];
# if SENTRY_TARGET_PROFILING_SUPPORTED
[result appendFormat:
@"\nslowFrameTimestamps: %@\nfrozenFrameTimestamps: %@\nframeRateTimestamps: %@",
_slowFrameTimestamps, _frozenFrameTimestamps, _frameRateTimestamps];
# endif // SENTRY_TARGET_PROFILING_SUPPORTED
return result;
}

@end

#endif // SENTRY_UIKIT_AVAILABLE