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

Feature/add thread #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Eduard-Voiculescu
Copy link

@Eduard-Voiculescu Eduard-Voiculescu commented Feb 21, 2024

Parse the below keys, if they are present:

  • timestamp
  • process_id
  • thread_id
  • thread

Comment on lines -275 to -278
if lineData[timeField] == nil {
timeField = "timestamp"
timeValue = lineData[timeField]
}
Copy link
Owner

Choose a reason for hiding this comment

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

Ok what's that change exactly? Tests are probably failing straight with this change.

The zapdriver had it's own format, I don't think we should change it. I see two options, those changes are reverted or you add a new method maybePrettyPrintGCPCloudLoggingLine(...) that deals with correct format.

@@ -269,13 +302,10 @@ func tsFieldToTimestamp(input interface{}) (*time.Time, error) {
return &zeroTime, fmt.Errorf("don't know how to turn %T (value %s) into a time.Time object", input, input)
}

// Using the log fields of stack driver: https://cloud.google.com/logging/docs/structured-logging
Copy link
Owner

Choose a reason for hiding this comment

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

This is sadly not totally true. StackDriver had its own format and was acquired by Google at some point. They are now using the new format for which you added the log line but this function was seems it's not fully dealing with old logging.

I prefer that we keep backward compatibility, tests should sufficient to ensure nothing is broken.

delete(lineData, "msg")
delete(lineData, "message")

if os.Getenv("ZAP_PRETTY_PRINT_THREADS") != "" {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if os.Getenv("ZAP_PRETTY_PRINT_THREADS") != "" {
if os.Getenv("ZAP_PRETTY_THREAD_ON_HEADER") != "" {

Copy link
Owner

Choose a reason for hiding this comment

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

And create a function that will check this so the environment name is specified at a single place.

Comment on lines +329 to +342
var threadId *string
var thread *string
if os.Getenv("ZAP_PRETTY_PRINT_THREADS") != "" {
if v := lineData["thread_id"]; v != nil {
threadIdF64 := v.(float64)
threadIdStr := strconv.FormatFloat(threadIdF64, 'f', -1, 64)
threadId = &threadIdStr
}

if v := lineData["thread"]; v != nil {
threadStr := v.(string)
thread = &threadStr
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Totally duplicated logic, please refactor.

@@ -194,19 +195,20 @@ func (p *processor) processLine(line string) {
}

func (p *processor) maybePrettyPrintLine(line string, lineData map[string]interface{}) (string, error) {
Copy link
Owner

Choose a reason for hiding this comment

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

Please keep backward compatibility.

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.

2 participants