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

Follow logs using overlap #89

Merged

Conversation

nocturnalastro
Copy link
Collaborator

No description provided.

@nocturnalastro nocturnalastro force-pushed the followLogsOverlap branch 2 times, most recently from 54e4b29 to 47b5813 Compare September 20, 2023 10:23
@nocturnalastro nocturnalastro marked this pull request as ready for review September 20, 2023 11:35
Comment on lines 66 to 68
usr, err := user.Current()
if err != nil {
log.Fatal("Failed to result homedir for current user in --tempdir")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the error is for user.Current() maybe we should rephrase the error message? something like

Suggested change
usr, err := user.Current()
if err != nil {
log.Fatal("Failed to result homedir for current user in --tempdir")
usr, err := user.Current()
if err != nil {
log.Fatal("Failed to get current user")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to "Failed to fetch current user so could not resolve tempdir"

@@ -13,13 +13,16 @@ import (
var (
OptionalCollectorNames []string
RequiredCollectorNames []string
OptInCollectorNames []string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand from the name what it is. Sounds very similar to OptionalCollectorNames

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OptIn is off by default, Optional is on by default but can be turned off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can probably take this out as we moved the log collector to on by default

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed :)

Copy link
Contributor

@crwr45 crwr45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a pass to rewrite the test descriptions and some comments for clarity, but looks promising.

collectCmd.Flags().StringVarP(
&logsOutputFile,
"logs-output", "l", "",
"Path to the logs output file. This is required when using the opt in logs collector",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Path to the logs output file. This is required when using the opt in logs collector",
"Path to the logs output file. This is required when using the logs collector",

)

// LogsCollector collects logs from repeated calls to the kubeapi with overlapping query times,
// the lines are then fed into a channel, in another gorotine they are de-duplicated and written to an output file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the lines are then fed into a channel, in another gorotine they are de-duplicated and written to an output file.
// the lines are then fed into a channel, in another goroutine they are de-duplicated and written to an output file.

}

//nolint:varnamelen // x and y are just two sets of lines
func findIncompatableLines(x, y []*ProcessedLine) int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo in name and add a definition of what an incompatible line is as it's extensively used:

Suggested change
func findIncompatableLines(x, y []*ProcessedLine) int {
// an incompatible line is a line that exists in x without being present at the same index in y.
func findIncompatibleLines(x, y []*ProcessedLine) int {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also consider renaming to something like findFirstIssueIndex

}

//nolint:gocritic,varnamelen // don't want to name the return values as they should be built later, I think x, y are expressive enough names
func fixLines(x, y []*ProcessedLine, issueIndex int) ([]*ProcessedLine, []*ProcessedLine, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixLines needs a sentence or two docstring explaining what the two output line slices are and what guarantees are made about them

return loglines.MakeSliceFromLines(lines, generation), nil
}

var _ = Describe("Dedup AB tests", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the text in each of the When and It calls needs to be rewritten for clarity

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone through them if you think there needs extra let me know.

Copy link
Contributor

@crwr45 crwr45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, happy to merge once we have a long run that matches the more crude method.

@nocturnalastro nocturnalastro merged commit d7ab104 into redhat-partner-solutions:main Oct 17, 2023
5 checks passed
@nocturnalastro
Copy link
Collaborator Author

Did 3000m and completely matched the crude method :)

@nocturnalastro nocturnalastro deleted the followLogsOverlap branch October 17, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants