-
Notifications
You must be signed in to change notification settings - Fork 680
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
Use log timestamps from docker logs. #401
base: master
Are you sure you want to change the base?
Conversation
Hi @localghost |
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.
Please re-work this PR. Also add any new feature descriptions to README.md
. Also add your change to CHANGELOG.md
.
Thanks for your contribution!
router/pump.go
Outdated
@@ -235,6 +235,7 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool, inactivityTim | |||
Since: sinceTime.Unix(), | |||
InactivityTimeout: inactivityTimeout, | |||
RawTerminal: rawTerminal, | |||
Timestamps: true, |
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.
set this to true only if this feature is enabled
router/pump.go
Outdated
@@ -361,10 +362,15 @@ func newContainerPump(container *docker.Container, stdout, stderr io.Reader) *co | |||
} | |||
return | |||
} | |||
logMessage, logTime, err := parseLogLine(line) |
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.
parseLogLine
should only be called if this feature is enabled. Also, if we get an error, perhaps we should fall back to default behaviour of using Time.Now()
router/pump.go
Outdated
if err != nil { | ||
return "", time.Time{}, err | ||
} | ||
return logEntry[1], logTime, nil |
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 guarantee that logEntry[1]
exists. You should rework this function to check the length of logEntry
@gbolo |
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.
almost good for for merge. I like that the default behaviour remains during errors. Just review my comment.
@michaelshobbs how does the PR look to you?
if len(logEntry) == 2 { | ||
return logEntry[1], logTime | ||
} | ||
return "", logTime |
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 do we want to return an empty log line? Shouldn't this also be: return line, time.Now()
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.
if line
has no white spaces - if it had the function would finish at len(logEntry) == 2
- and logEntry[0]
is a valid time string - otherwise the function would finish at err != nil
then it means that an empty message was logged
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.
looks reasonable. needs tests, however
Hi @localghost I agree with @michaelshobbs. This shouldn't be too hard. Just make a test case that focuses on testing the function |
@gbolo, I know, I just don't have time currently. I will update this pr in a few days. Thanks. |
@gbolo @michaelshobbs |
something changed with the upstream golint repo. i've had to modify other projects to get around this. please fix this in logspout by changing this line: Line 41 in 89c2a08
to
|
@gbolo @michaelshobbs |
I have the same problem as @yunusemrecatalcam. What is the workaround for seeing real timestamps with at least millisecond resolution? |
The rationale for this PR is that not preserving original timestamps by logspout makes investigation of issues across multiple services hard.