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

Update logging calls to take advantage of structured logging #9454

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

jsternberg
Copy link
Contributor

Includes a style guide that details the basics of how to log.

@ghost ghost assigned jsternberg Feb 15, 2018
@ghost ghost added the review label Feb 15, 2018
### Context Key Names

The key for the dynamic content in the context should be formatted in
camelCase. For acronyms, each letter of the acronym should match the
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall, really great documentation and guidelines. It may seem pedantic, however, I would like you to consider the use of snake_case, for a couple of reasons:

  • they are less ambiguous in some cases. For example isIllicitIgloo vs is_illicit_igloo
  • based on an empirical study using engineers, the researchers found it required more effort to comprehend the camel-case identifiers. I imagine that will be quiet relevant in a sea of log lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally like using dashes, but I think last time I brought this up, someone requested camelCase. We should just put it to a vote. I'm not a big fan of snake case mostly because I think it looks ugly in output, but whichever one a plurality wants, I'll take.

@@ -681,7 +686,7 @@ func (h *Handler) serveWrite(w http.ResponseWriter, r *http.Request, user meta.U
atomic.AddInt64(&h.stats.WriteRequestBytesReceived, int64(buf.Len()))

if h.Config.WriteTracing {
h.Logger.Info(fmt.Sprintf("Write body received by handler: %s", buf.Bytes()))
h.Logger.Info("Write body received by handler", zap.ByteString("body", buf.Bytes()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if these values are truncated? Repeated requests with a huge payload it could cause storage issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not. It is probably not. I think that's a separate issue though.

@@ -851,7 +856,7 @@ func (h *Handler) servePromWrite(w http.ResponseWriter, r *http.Request, user me
atomic.AddInt64(&h.stats.WriteRequestBytesReceived, int64(buf.Len()))

if h.Config.WriteTracing {
h.Logger.Info(fmt.Sprintf("Prom write body received by handler: %s", buf.Bytes()))
h.Logger.Info("Prom write body received by handler", zap.ByteString("body", buf.Bytes()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if these values are truncated? Repeated requests with a huge payload it could cause storage issues.

@@ -389,8 +389,7 @@ func (m *Monitor) createInternalStorage() {
}

if _, err := m.MetaClient.CreateDatabaseWithRetentionPolicy(m.storeDatabase, &spec); err != nil {
m.Logger.Info(fmt.Sprintf("failed to create database '%s', failed to create storage: %s",
m.storeDatabase, err.Error()))
m.Logger.Info("Failed to create storage", zap.String("db", m.storeDatabase), zap.Error(err))
Copy link
Contributor

@stuartcarnie stuartcarnie Feb 15, 2018

Choose a reason for hiding this comment

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

you will be interested in my PR, as I have added some common Field helpers in your logging package to ensure we use consistent keys in the log context. For example:

// Database returns a field for tracking the name of a database.
func Database(name string) zapcore.Field

// Database returns a field for tracking the name of a database.
func RetentionPolicy(name string) zapcore.Field

// Shard returns a field for tracking the shard identifier.
func Shard(id uint64) zapcore.Field

@jsternberg jsternberg force-pushed the js-structured-logging branch 3 times, most recently from d12843d to 791f7a7 Compare February 17, 2018 15:52
@jsternberg jsternberg requested a review from goller February 20, 2018 15:17
Includes a style guide that details the basics of how to log.
@jsternberg jsternberg force-pushed the js-structured-logging branch from 791f7a7 to 2bbd967 Compare February 20, 2018 16:04
@jsternberg jsternberg removed the request for review from rbetts February 21, 2018 15:14
@jsternberg jsternberg merged commit d38413a into master Feb 21, 2018
@jsternberg jsternberg deleted the js-structured-logging branch February 21, 2018 15:14
@ghost ghost removed the review label Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants