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

Consolidate rootLogger and scopedLogger #1878

Merged
merged 3 commits into from
Jan 28, 2022

Conversation

carolynvs
Copy link
Member

@carolynvs carolynvs commented Jan 27, 2022

What does this change

By only allowing the porter application context to create a root span,
we can consolidate rootlogger and scoped logger into a single
TraceLogger, and simplify logic around setting attributes on the root
span.

What issue does it fix

N/A

Notes for the reviewer

N/A

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

By only allowing the porter application context to create a root span,
we can consolidate rootlogger and scoped logger into a single
TraceLogger, and simplify logic around setting attributes on the root
span.

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs carolynvs force-pushed the do-not-use-root-logger branch from 618c73c to 2d684e0 Compare January 27, 2022 20:34
Sometimes the stack looks like this when we ask for the calling function
name:

InstallBundle
  -> tracing.TraceLogger.StartSpan
    -> tracing.callerFunc

other times it looks like this
ExecuteBundle
-> tracing.StartSpan
  -> tracing.TraceLogger.StartSpan
    -> tracing.callerFunc

So I have tweaked how we look up the stack to keep checking until we
find a function that isn't in the tracing package

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs
Copy link
Member Author

I noticed when working on this that callerFunc is returning funny names when the function had a pointer receiver.

So for porter list, we are getting get.porter.sh/porter/pkg/porter.(*Porter).ListInstallations for the function name from the call stack which turns into (*Porter).ListInstallations instead of what I believe was intended to be just ListInstallations.

@VinozzZ can you take a look after this PR is merged? (After because I edited the same file in this PR)

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs carolynvs requested a review from VinozzZ January 27, 2022 22:53
@carolynvs carolynvs marked this pull request as ready for review January 27, 2022 22:53
Copy link
Contributor

@VinozzZ VinozzZ left a comment

Choose a reason for hiding this comment

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

This looks awesome! Thanks you for all the documentation

@carolynvs carolynvs merged commit 550a56a into getporter:release/v1 Jan 28, 2022
@carolynvs carolynvs deleted the do-not-use-root-logger branch January 28, 2022 16:36
@carolynvs
Copy link
Member Author

@VinozzZ Thanks for pushing me to clean up the tracing package! 🙇‍♀️

joshuabezaleel pushed a commit to joshuabezaleel/porter that referenced this pull request Feb 8, 2022
* Consolidate rootLogger and scopedLogger

By only allowing the porter application context to create a root span,
we can consolidate rootlogger and scoped logger into a single
TraceLogger, and simplify logic around setting attributes on the root
span.

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Allow for a variable stack size when finding the function name

Sometimes the stack looks like this when we ask for the calling function
name:

InstallBundle
  -> tracing.TraceLogger.StartSpan
    -> tracing.callerFunc

other times it looks like this
ExecuteBundle
-> tracing.StartSpan
  -> tracing.TraceLogger.StartSpan
    -> tracing.callerFunc

So I have tweaked how we look up the stack to keep checking until we
find a function that isn't in the tracing package

Signed-off-by: Carolyn Van Slyck <[email protected]>

* Document more of the tracing package

Signed-off-by: Carolyn Van Slyck <[email protected]>
Signed-off-by: joshuabezaleel <[email protected]>
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