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

Remove debug.Stack() from logger #1053

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

glazychev-art
Copy link
Contributor

Signed-off-by: Artem Glazychev artem.glazychev@xored.com

Description

It seems we don't actually need debug.Stack(), because errors.New() already has a stack:

// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are
// invoked. This information can be retrieved with the following interface:
//
//     type stackTracer interface {
//             StackTrace() errors.StackTrace
//     }

Even if we create error without using errors package, trace chain element will wrap it to the struct with stack trace (errors.Wrapf(...)).

We do not need to call debug.Stack() for every Errorf() call, because we already have this information.
And we need to set "%+v" if we want to print error with stack trace - link

Issue link

networkservicemesh/deployments-k8s#2368

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionallity
  • Documentation
  • Refactoring
  • CI

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
@glazychev-art
Copy link
Contributor Author

There are several cases if error happen:

  1. Print stack trace for each chain element:
    + full info about an error (including line number)
    - a huge number of duplicate logs
  2. Print only if the error hasn't stack trace (current behavior in trace chain element):
    + for some cases we print a stack trace only once
    - if the error already has a stack trace, we don't print it

@glazychev-art glazychev-art changed the title Correct work with stack tracer Remove debug.Stack() from logger Aug 5, 2021
@glazychev-art
Copy link
Contributor Author

@edwarnicke
Do you have any thoughts on this?

@denis-tingaikin
Copy link
Member

I think we can try this and if it will make logs not informative then we can revert this patch and consider another solution.

@glazychev-art glazychev-art marked this pull request as ready for review August 10, 2021 11:16
@denis-tingaikin denis-tingaikin merged commit eb7b86c into networkservicemesh:main Aug 10, 2021
nsmbot pushed a commit to networkservicemesh/cmd-nse-icmp-responder that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr-proxy that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-registry-memory that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-registry-proxy-dns that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vfio that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-kernel that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-k8s that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsc-init that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-k8s that referenced this pull request Aug 10, 2021
…k@main

PR link: networkservicemesh/sdk#1053

Commit: eb7b86c
Author: Artem Glazychev
Date: 2021-08-10 18:17:26 +0700
Message:
  - Correct work with stack tracer (#1053)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
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