-
Notifications
You must be signed in to change notification settings - Fork 203
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
pkg/{porter,tracing}, cmd/porter: add tracing instrumentation for list #1864
Conversation
66262af
to
7f55bbd
Compare
command This PR adds instrumentation for list command. It also adds support for automatically setting span name during creation by the caller function name. Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
7f55bbd
to
f977a35
Compare
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.
Looks good, I just have some comments to help improve readability
pkg/tracing/scopedLogger.go
Outdated
|
||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
type ScopedLogger interface { | ||
StartSpan(op string, attrs ...attribute.KeyValue) (context.Context, ScopedLogger) | ||
StartSpanNamed(attrs ...attribute.KeyValue) (context.Context, ScopedLogger) |
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.
When should someone use StartSpan and explicitly name the op vs. using StartSpanNamed and have the op named after the current function?
Also it's not clear to me what StartSpanNamed will do. How about we tweak the name a bit so it's clear that the span will be named after the function, like StartSpanFromFunction
or StartSpanNamedByFunction
or something else like that?
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.
From my perspective, a span is for a logical unit that usually contains side affect on a state. That often happens within a function. It also helps to create a trace that easily relate back to the code. We will know exactly which function created a span. I also changed the name to StartSpanNamedByCaller
. Let me know what do you think?
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.
When would someone use StartSpan vs StartSpanByCaller? Or should we remove StartSpan and never give a custom name to a span?
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 was thinking maybe someone would want multiple spans within a complex function and then they will need to manually provide names for them.
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.
Maybe what we could do is to have this interface instead
type ScopedLogger interface {
StartSpan(attrs ...attribute.KeyValue)
StarSpanByCustomName(op string, attrs ...attribute.KeyValue)
...
}
That way the default behavior is to use callerFunc()
, and then if someone wants to use a custom name they will use the other one
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
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.
Let's think about when a developer would use StartSpan vs StartSpanByCaller and consider if we should just have a single function that uses the callerFunc. Right now I think other devs working on Porter will be unsure when to use each function.
I just checked out the failed build, and it's not from your changes. I think it's a flakey test and the next time it runs, it should pass. |
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
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.
Everything looks great, I just have one more question (below).
Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com>
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 is great thank you for setting up some patterns for us to follow as we instrument the rest of Porter! 💯
/azp run porter-integration |
Azure Pipelines successfully started running 1 pipeline(s). |
Two pull requests, getporter#1864 and getporter#1851, were merged, and while it didn't cause a merge conflict, they didn't play well together and it broke the build. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
getporter#1864) * pkg/{porter,tracing}, cmd/porter: add tracing instrumentation for list command This PR adds instrumentation for list command. It also adds support for automatically setting span name during creation by the caller function name. Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com> * add readability Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com> * use new interface for creating a span Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com> * add unit test Signed-off-by: Yingrong Zhao <yingrong.zhao@gmail.com> Signed-off-by: joshuabezaleel <joshua.bezaleel@gmail.com>
Two pull requests, getporter#1864 and getporter#1851, were merged, and while it didn't cause a merge conflict, they didn't play well together and it broke the build. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com> Signed-off-by: joshuabezaleel <joshua.bezaleel@gmail.com>
command
What does this change
This PR adds instrumentation for list command. It also adds support for
automatically setting span name during creation by the caller function
name.
Some fixes for unclosed spans is included as well
What issue does it fix
related to #1857
Notes for the reviewer
Put any questions or notes for the reviewer here.
Checklist
Reviewer Checklist