Skip to content

feat: added support for streaming stdout when --progress=plain - #7069

Merged
jedevc merged 6 commits into
dagger:mainfrom
morlay:streaming-output
Apr 10, 2024
Merged

jedevc merged 6 commits into
dagger:mainfrom
morlay:streaming-output

Conversation

@morlay

@morlay morlay commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

fix #7057

@morlay
morlay force-pushed the streaming-output branch from 7d86438 to 2db590e Compare April 10, 2024 02:38
@morlay

morlay commented Apr 10, 2024 •

Copy link
Copy Markdown
Contributor Author
image

logs in real CI. (no idea about the color lost issue)

Comment thread dagql/idtui/streaming_output.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the span name is not always get cause otel emit the spans until span.End() called.
may consider set span name in log attrs too.

@morlay
morlay force-pushed the streaming-output branch 2 times, most recently from b8b2b38 to 74f8714 Compare April 10, 2024 04:59
@jedevc

jedevc commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

I think this makes sense 🎉 I'm really not familiar with how frontend.go works though.

To me, it feels confusing that the logic for adding new views/etc is really complex - ideally, we'd have an interface that a new view would be able to implement. Then the fancy new progress view and the plain one would all just be implementations of that interface.

@jedevc
jedevc requested a review from vito April 10, 2024 10:57
@jedevc

jedevc commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

There were still some color issues (particularly in the summary that's still printed at the end), so pushed a fix for that (the extra WithTTY calls can be removed once vito/progrock#14 is merged and updated).

@jedevc

jedevc commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

I'd like to do some further refactoring of this later, but for now, this fixes the issue, and it would be awesome to include this in v0.11.1, so going to approve now, and I'll happily iterate on this after the release.

@jedevc jedevc added this to the v0.11.1 milestone Apr 10, 2024
func (w *batchPrinter) render(out *termenv.Output, final bool) {
w.mu.Lock()
defer w.mu.Unlock()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jedevc

it could ignore logs without spanName for now.

spanName := w.getSpanName(w.spanID)
if spanName == "" {
    return
}

@morlay

morlay commented Apr 10, 2024

Copy link
Copy Markdown
Contributor Author

This is needed for printing out the final data!

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc

jedevc commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

@morlay can you share an example of where span is empty?

@morlay

morlay commented Apr 10, 2024 •

Copy link
Copy Markdown
Contributor Author

@morlay can you share an example of where span is empty?

this first 6: in that image.

It logs before trace span emitted.

@jedevc

jedevc commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

Right, yeah, I meant, do you have a publicly-available example I can run to get this?

I'm trying to understand why this can happen.

@morlay

morlay commented Apr 10, 2024 •

Copy link
Copy Markdown
Contributor Author

Right, yeah, I meant, do you have a publicly-available example I can run to get this?

I'm trying to understand why this can happen.

It from github actions logs of my tool.
https://github.com/octohelm/piper

It base dagger for container.
But could execute in local/remote hosts.
Like some build system or the Ansible did.

To make logs in same view, I reuse idtui when dagger v0.11.0 released.

So in local host execution, it will be fast.
Then got the issue. 😂

All tasks defined by cue lang.
https://github.com/octohelm/piper/blob/main/piper.cue

It could be run TTY=0 make build with this project

To see the issue should delete this condition
https://github.com/octohelm/piper/blob/main/internal/logger/steaming_exporter.go#L152

@jedevc jedevc linked an issue Apr 10, 2024 that may be closed by this pull request
@morlay

morlay commented Apr 10, 2024

Copy link
Copy Markdown
Contributor Author

https://github.com/dagger/dagger/blob/main/dagql/idtui/types.go#L133

Btw, in my case. It will make my final report hide some spans. 😂

Could we make it configable?

@vito

vito commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

To me, it feels confusing that the logic for adding new views/etc is really complex - ideally, we'd have an interface that a new view would be able to implement. Then the fancy new progress view and the plain one would all just be implementations of that interface.

This view is fundamentally different so it makes sense to me. Normally we're rendering into a viewport and dynamically redrawing parts of the screen, TUI style. This one just needs to print output directly without any funny business and let it go into the scrollback infinitely, skipping past all those moving parts and disregarding screen size and all that.

In the end they're both implementing an interface, just perhaps a lower level one than you might have expected (OpenTelemetry span/log exporter).

@vito

vito commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

Could we make it configable?

Already is - if you pass -vvv (verbosity level 3) it'll show everything. Probably need that in our docs. :)

@morlay

morlay commented Apr 10, 2024

Copy link
Copy Markdown
Contributor Author

Already is - if you pass -vvv (verbosity level 3) it'll show everything. Probably need that in our docs. :)

but with it, the final reporter is too noisy. 😂
May some option could define the should show.

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a great start, but I noticed it seems impossible to interrupt it at the moment with Ctrl+C. But, I think that was already broken in plain mode, so approving anyway; this is still a net positive. I think we can merge this as-is and I can try to fix that + maybe do some refactoring after. Thanks a bunch!

@jedevc
jedevc merged commit 2bc90a5 into dagger:main Apr 10, 2024
@vito

vito commented Apr 10, 2024

Copy link
Copy Markdown
Contributor

but with it, the final reporter is too noisy. 😂
May some option could define the should show.

I'd prefer to avoid a bunch of flags, but feel free to make it a param or var instead of a const, if you're using this code directly.

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.

🐞 --progress=plain stopped streaming stdout with Dagger v0.11.0 [v0.11.0] dagger logs lost colors in CI env, without setting NO_COLOR

3 participants