-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Change log format to JSON and log destination to stdout #48
Conversation
change the log format in Go written service from text payload to JSON payload using 3rd party logging library (logrus). https://cloud.google.com/logging/docs/structured-logging https://github.com/sirupsen/logrus/blob/33a1e118e113c7d1dd24a80f80670864cd598519/json_formatter.go#L40-L49 Effected services are frontend, productcatalogservice, checkoutservice, and shippinservice. Also change target container registry and locust scenario for testing.
I'm not sure if stderr tells anything about the log to Stackdriver. In my https://github.com/ahmetb/coffeelog project I've seen that output stream doesn't matter as long as you get the Stackdriver json fields right. As for (3) and (4), not sure why you felt like you did "git add" these files. 😄 You can test those without adding them to your commit. |
@@ -50,6 +50,6 @@ func quoteByCountFloat(count int) float64 { | |||
return 0 | |||
} | |||
count64 := float64(count) | |||
var p float64 = 1 + (count64 * 0.2) | |||
var p = 1 + (count64 * 0.2) |
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 not sure what this line changes. isn't it already float64?
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.
var p
doesn't require float64
type definition as it's inferred from count64
. Moreover now I realized it doesn't require var
keyword as well.
p := 1 + (count64 * 0.2)
just works.
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 PR is good (minus changes to yamls)! Especially liked that you got the Stackdriver logging fields right. 👌 Thanks a lot for the work.
Current questions I have:
- why only Go services? do we need other languages to move to structured logging too?
- we can probably set out to stderr and get the same result?
Thanks @ahmetb for taking a look.
You're right. They should have omitted 😅 Answering the following questions
This is just a first step. Once this PR merged, I'll work on other services written in other languages.
https://cloud.google.com/kubernetes-engine/docs/how-to/logging |
This is the PR for #47. This PR effects all the services written in Go.
The summary of this PR is:
For 3 and 4, I'll revert them to the original once the objective is approved.