Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD] Add more debug/trace logging #273

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,21 @@ - (void)URLSession:(__unused NSURLSession *)session task:(NSURLSessionTask *)tas
NSError *errorFromGetRequest = nil;
auto request = getTaskRequest(task, &errorFromGetRequest);
auto httpResponse = BSGDynamicCast<NSHTTPURLResponse>(task.response);
BSGLogDebug(@"BSGURLSessionPerformanceDelegate.URLSession:didFinishCollectingMetrics for URL %@", request.URL);

if (task.error != nil || task.response == nil || httpResponse.statusCode == 0) {
BSGLogDebug(@"BSGURLSessionPerformanceDelegate.URLSession:didFinishCollectingMetrics: error %@, response %@, statusCode %ld", task.error, task.response, (long)httpResponse.statusCode);
return;
}

if (self.baseEndpointStr.length > 0 && [request.URL.absoluteString hasPrefix:self.baseEndpointStr]) {
BSGLogDebug(@"BSGURLSessionPerformanceDelegate.URLSession:didFinishCollectingMetrics: endpoint %@ has base %@", request.URL.absoluteString, self.baseEndpointStr);
return;
}

auto span = (BugsnagPerformanceSpan *)objc_getAssociatedObject(task, associatedNetworkSpanKey);
if (!span) {
BSGLogDebug(@"BSGURLSessionPerformanceDelegate.URLSession:didFinishCollectingMetrics: Failed to create span");
return;
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/BugsnagPerformance/Private/Span.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class Span {
~Span() {
switch(spanDestroyAction) {
case AbortOnSpanDestroy:
BSGLogDebug(@"Span::~Span(): for span %@. Action = Abort", data_->name);
BSGLogDebug(@"Span::~Span(): for span %@. Action = Abort (span is currently %@)", data_->name, isEnded_ ? @"ended" : @"open");
abortIfOpen();
break;
case EndOnSpanDestroy:
BSGLogDebug(@"Span::~Span(): for span %@. Action = End", data_->name);
BSGLogDebug(@"Span::~Span(): for span %@. Action = End (span is currently %@)", data_->name, isEnded_ ? @"ended" : @"open");
end(CFAbsoluteTimeGetCurrent());
break;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ class Span {
}

void end(CFAbsoluteTime time) noexcept {
BSGLogDebug(@"Span::end(%f)", time);
BSGLogDebug(@"Span::end(%f): %@", time, data_->name);
bool expected = false;
if (!isEnded_.compare_exchange_strong(expected, true)) {
// compare_exchange_strong() returns true only if isEnded_ was exchanged (from false to true).
Expand Down
Loading