-
Notifications
You must be signed in to change notification settings - Fork 214
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
Use structured logs and export traces #1831
Conversation
@@ -63,7 +63,7 @@ func buildBundleBuildCommand(p *porter.Porter) *cobra.Command { | |||
return opts.Validate(p) | |||
}, | |||
RunE: func(cmd *cobra.Command, args []string) error { | |||
return p.Build(opts) | |||
return p.Build(cmd.Context(), opts) |
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.
FYI, short of using global package variables (which would cause problems for anyone using porter as a library) we are going to just have to pass context around everywhere going forward.
It's useful for other things, like cancel support, so it's not the worst, just ugly. 😀
96320a8
to
fd6984b
Compare
if b.IsVerbose() { | ||
out = b.Out | ||
if b.IsVerbose() || b.Config.IsFeatureEnabled(experimental.FlagStructuredLogs) { | ||
ctx, log = log.StartSpan("buildkit", attribute.String("source", "porter.build.buildkit")) |
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 would like to have a source set for all log lines to help filter by source. It will need more experimentation though so for now I'm using it just here and we can complete that in a follow-up if it turns out to be helpful.
@vdice This is a big PR and I'm out on leave for the rest of the year. Just giving you time to review or try it out locally. I won't attempt to get this merged until when I'm back in January. |
4e94d5f
to
ae5859b
Compare
Log to a file in ~/.porter/logs/CORRELLATION_ID.json and in colored human readable output to stderr. When stderr is not a TTY, color is omitted (which is what we need for piping to a file or running on headless CI servers). Tracing has been enabled using open-telemetry and can be configured with the standard OTEL environment variables. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specify-protocol This is just a stub of the final tracing and log switch over, that lays down a framework for converting the rest and instrumenting more commands. For now we start a trace for the command executed. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
ae5859b
to
631831f
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.
LGTM! 👏
The integration tests accidentally were passing nil for the context after I added context.Context as a parameter to some Porter commands in getporter#1831. This passes in context.Background to fix the nil pointer exceptions that was causing. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
The integration tests accidentally were passing nil for the context after I added context.Context as a parameter to some Porter commands in getporter#1831. This passes in context.Background to fix the nil pointer exceptions that was causing. Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com> Signed-off-by: joshuabezaleel <joshua.bezaleel@gmail.com>
What does this change
Log to a file in ~/.porter/logs/CORRELLATION_ID.json and in colored human readable
output to stderr. When stderr is not a TTY, color is omitted (which is
what we need for piping to a file or running on headless CI servers).
Tracing has been enabled using open-telemetry and can be configured with
the standard OTEL environment variables.
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specify-protocol
This is just a stub of the final tracing and log switch over, that lays
down a framework for converting the rest and instrumenting more
commands. For now we start a trace for the command executed,
a little bit of the execute bundle flow, and the buildkit build driver.
If a trace cannot be written to the server (due to misconfiguration or the trace endpoint is offline),
porter will keep on truckin' and print something like this:
Updated documentation
What issue does it fix
Closes #1429
Notes for the reviewer
Checklist