-
Notifications
You must be signed in to change notification settings - Fork 12
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
Ship full log output to Cronitor #14
Conversation
cmd/exec.go
Outdated
outputForLogs := gatherOutput(tempFile, false) | ||
_, err = shipLogData(monitorCode, series, string(outputForLogs)) | ||
if err != nil { | ||
fmt.Printf("%v", err) |
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.
switch this to a log() function call and do the same on the other block.
Also since this inline goroutine is like 5+ LOC and used twice, i would probably just give it a name and call it
cmd/exec.go
Outdated
outputForPing := gatherOutput(tempFile) | ||
outputForPing := gatherOutput(tempFile, true) | ||
var metrics map[string]int = nil | ||
logLengthForPing, err := getFileSize(tempFile) |
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 like this err is overwriting the err on L180 that is used later on L203
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.
good catch
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 will rename the one on 180 -- not very defensive here. i'll do it in a branch i'm working on
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.
Honestly you shouldn't have to be, in my opinion this is a failure of go structurally
cmd/exec.go
Outdated
return &b | ||
} | ||
|
||
func getPresignedUrl(postBody []byte) ([]byte, error) { |
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.
would be nice to move this into lib/cronitor to keep this exec command focused on its main job. That module currently uses our v3 api end points but I will eventually update them to be consistent with this.
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.
A few thoughts on this:
- As you said, currently
lib/cronitor
is built very differently than that bit is, including API versions (presign doesn't even have a version), etc. - Personally I think the presign API call actually acts quite a bit differently than
lib/cronitor
and the rest of the API. It is technically an API call, but only because we need to keep the AWS keys secret in order to presign. I think there's another valid argument that it actually belongs insideexec
, because its sole purpose is to presign URLs for log uploading, which is very much anexec
-related task.
Given the urgency I understand around shipping this, I suggest we leave this as is for now, and then if you disagree with what I wrote above and really want me to move it to lib/cronitor
, I can refactor after.
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.
Ok I just pushed this, i was hung up at the end with a problem but the I realize it failed still when I stashed my changes.
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.
Not a time thing--philosophically I genuinely think it should sit in exec
. But I'm happy to move it.
Regarding shipping now vs later, I misunderstood what you were saying--I thought you were suggesting refactoring the methods to fit as methods of the CronitorApi
struct that appears in lib/cronitor
, which from looking through it seemed like it would take longer given the assumptions about the API it currently makes--which actually if we did it would be clean. cronitor-kubernetes has a very similar structure and it looks nice. And actually looking at what I did there, I actually did attach shipLogData
to the main struct, so I'm probably disproving my own earlier point given how clean that looks, and maybe it should be refactored.
That said if you literally just meant copy/pasting it to lib/cronitor
, obviously that will take like 5 seconds. I can do that 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.
Here's the error currently:
mac: ~/0x0/cli $ ./cronitor-cli -v exec shane-testy2 'true && echo "test"'
Reading config from /etc/cronitor/cronitor.json
Running subcommand: true && echo "test"
Sending ping https://cronitor.link/ping/xxx/shane-testy2?state=run&try=1&stamp=1651207111.322&msg=true+%26%26+echo+%22test%22&host=Shanes-MacBook-Pro.local&series=1651207111.322
test
Sending ping https://cronitor.link/ping/xxx/shane-testy2?state=complete&try=1&stamp=1651207111.351&msg=test%0A&host=Shanes-MacBook-Pro.local&duration=0.029&series=1651207111.322&status_code=0&metric=length%3A5
error generating presign url for log uploading: error response code 400 returned
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 pings are correct, has the correct length, etc, but the log upload is not happy
https://cronitor.io/app/monitors/shane-testy2?env=production&time=7d
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'm pretty sure I figured out what's going on here and fixed in the latest commit. Your sample command works for me locally now, pull latest and try again
Some failing tests here I will dig in and see what's up
|
Let me know what you find and I can look into it / fix. |
Yes we have the beginnings of a docker-based test rig so it can be tested on different platforms that should be easy to adapt to Actions. But valuable right now is depending on how long it takes. |
This might be a test update that didn't get committed when I migrated to the new ping URL format, verifying |
Let me know! We could work on it and decide on a timebox for it. Usually setting up CI isn't too bad |
This PR adds full log-shipping capabilities without truncation, like are available in https://github.com/cronitorio/cronitor-kubernetes, to Cronitor-CLI.
Still remaining: