-
Notifications
You must be signed in to change notification settings - Fork 18
Native crumbs #111
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
Native crumbs #111
Conversation
Remove Cassette related Tests
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
KrzaQ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much to say, it looks ok to me.
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
| self.queue = try CASQueueFile.init(path: breadcrumbSettings.getBreadcrumbLogPath().path) | ||
|
|
||
|
|
||
| self.breadcrumbLogURL = try breadcrumbSettings.getBreadcrumbLogPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it can throw? Maybe it would be better to throw an error faster and here pass only data needed by BacktraceBreadcrumbFileHelper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
| self.queue = try CASQueueFile.init(path: breadcrumbSettings.getBreadcrumbLogPath().path) | ||
|
|
||
|
|
||
| self.breadcrumbLogURL = try breadcrumbSettings.getBreadcrumbLogPath() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the file doesn't exist? we don't create it anywhere. We always write to a file. How about creating a start method that will do startup logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file will always exist;
getBreadcrumbLogPath() method will create a file if doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no good way to do this since BacktraceBreadcrumbSettings forces us to (try/unwrap), if for any reason the file is nil the files operations methods will catch the error and warn BacktraceLogger.
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Sources/Features/Breadcrumb/BacktraceBreadcrumbFileHelper.swift
Outdated
Show resolved
Hide resolved
Rename BacktraceBreadcrumbFileHelper to BacktraceBreadcrumbFile Code improvements
Add BacktraceBreadcrumbFile extension to host file operations Add remove(at index: Int) to Queue class Update BacktraceLogger error messages
|
|
||
| func clearBreadcrumbLogFile(at breadcrumbLogURL: URL) { | ||
| do { | ||
| try "".write(to: breadcrumbLogURL, atomically: false, encoding: .utf8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if someone deletes a file when you're generating breadcrumbs?
| BacktraceLogger.warning("Error when adding breadcrumbSize to array") | ||
| return false | ||
| } | ||
| let queueBreadcrumb = queuedBreadcrumbs[index] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We receive index out of bounds when we access breadcrumbs with an invalid index, right? or will it return null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it shouldn't but I'll guard it
| @@ -1,5 +1,15 @@ | |||
| import Foundation | |||
|
|
|||
| struct BreadcrumbRecord { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be moved to a separated file.
You implemented queue to be generic. However, putting BreadcrumbRecord definition in the Queue implementation sounds weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving it
| @@ -1,5 +1,15 @@ | |||
| import Foundation | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it QueueFile? I believe its a generic queue instead. Can we rename the file to Queue or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Queue it is!
Add BreadcrumbRecord class definition Rename QueueFile to Queue Guard queue index when iterating
| let text = "this is Breadcrumb number \(writeIndex)" | ||
| // submit a task to the queue for background execution | ||
| DispatchQueue.global().async(group: group, execute: { | ||
| expect { breadcrumbs.addBreadcrumb(text) }.to(beTrue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this background task, this test doesn't do what is intended to do (in fact, the entire loop is useless).
We had lots of problems with multithreaded behavior corrupting the file, so beware!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll seep a close eye on multithreaded behaviour, thank you!
| let fileSize = attr[FileAttributeKey.size] as? Int | ||
| let requestedSize = settings.maxQueueFileSizeBytes | ||
| expect { fileSize }.to(beLessThanOrEqualTo(requestedSize)) | ||
| expect { fileSize }.to(beGreaterThanOrEqualTo(requestedSize - 1000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is important. I would consider adjusting it, not deleting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
| // Currently, we accept we lose this Breadcrumb in the UI - it will still be in the file | ||
| // for manual inspection. | ||
| let expectedNumberOfMatches = writeIndex - wrapIndex - 1 | ||
| expect(matches).to(beGreaterThanOrEqualTo(expectedNumberOfMatches), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is important. I would consider adjusting it, not deleting it. The -1 may no longer be necessary due to the Cassette dependency being removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is specifically there to make sure the file rolls over, so the number of expected matches are really important. Otherwise the entire test doesn't do anything the other (smaller) tests already do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this one for the same reason, I'll adjust it.
Thank you :)
| s.osx.public_header_files = ["Backtrace-macOS/**/*.h*"] | ||
| s.tvos.public_header_files = ["Backtrace-tvOS/**/*.h*"] | ||
|
|
||
| s.ios.dependency "Cassette", '1.0.0-beta5' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if there's any superfluous #if os(iOS) || os(OSX) left in prod/test code. I know there were a bunch of 'm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look :)
|
Hey hey! Cool that that pesky Cassette is finally being removed :). I forgot where, but there's performance test results stored in Github or Hack somewhere that document for which file sizes the performance is what. This PR seems to be doing somewhat similar to what #95 was meant to do (but is outdated now). You may want to compare and then close it. Thanks :) |
Uh oh!
There was an error while loading. Please reload this page.