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

Add workflow trace #520

Merged
merged 11 commits into from
Apr 10, 2024
Merged

Conversation

sebneira
Copy link
Contributor

@sebneira sebneira commented Apr 3, 2024

What was changed

Ported over trace to the new cli rewrite.

Added a couple of fixes to get this to work:

  • Moved all the tracer printing logic to the WorkflowTracer (see Minor refactor and fixes to workflow trace #507 for the isolated changes). This was the initial fix I was working on. This should remove the issues when state == nil and the weirdness with the setupUpdateChannels.
  • Removed ExecutionState's GetDuration and GetStartTime time reference since the events now use durationpb.Duration and timestamppb.Timestamp and the conversion to non-pointer values makes more sense. Adjusted the templates to present this data correctly.

Why?

Ported the command to the cli rewrite and provided fixes for the nil pointer issues reported by Chad.

Checklist

  1. Closes

  2. How was this tested:

All unit tests are running and I've run the tool against a couple different workflow executions with temporalite.

  1. Any docs updates needed?

@CLAassistant
Copy link

CLAassistant commented Apr 3, 2024

CLA assistant check
All committers have signed the CLA.

@cretz
Copy link
Member

cretz commented Apr 3, 2024

This is great! Will review when you mark "ready for review"

@sebneira sebneira marked this pull request as ready for review April 4, 2024 11:54
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Not too concerned with the details of the internal/trace package, so didn't review that closely.

temporalcli/commands.gen.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Show resolved Hide resolved
temporalcli/internal/trace/execution_state.go Outdated Show resolved Hide resolved
Sebastian Neira and others added 2 commits April 4, 2024 14:36
Co-authored-by: Chad Retz <chad.retz@gmail.com>

#### Options

* `--fold` (string) - Statuses for which Child Workflows will be folded in (this will reduce the number of information fetched and displayed). Case-insensitive and ignored if no-fold supplied. Available values: running, completed, failed, canceled, terminated, timedout, continueasnew. Default: completed,canceled,terminated.
Copy link
Member

Choose a reason for hiding this comment

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

If we supported it, would suggest string-enum[] as the type, but in the meantime, might as well just have string[] as the type. This allows them to specify --fold multiple times instead of using commas. However, default not supported for string[]. You can either add support in commandsmd/code.go or just have something like "Default is completed, canceled, terminated" which won't trigger the parser and let you set the default at runtime.

Copy link
Contributor Author

@sebneira sebneira Apr 4, 2024

Choose a reason for hiding this comment

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

I'm happy to do this is a later iteration so we can move this (already pretty big thing) forward. Does this work for you? Tbh, I think this is a flag that will very rarely be used, since the provided default is the most reasonable.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, but it will be a backwards-incompatible alteration at that time unfortunately.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you pass multiple statuses to a single instance of --fold? The help text says "Statuses", which makes me think this is possible, but we should make it explicit in the help text that commas are needed.

Copy link
Contributor Author

@sebneira sebneira Apr 8, 2024

Choose a reason for hiding this comment

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

How would y'all feel about not using the flag for now and working this out in a future PR? I think it's a non-trivial decision that we would benefit from putting some good thinking behind (and not delay this PR).

Copy link
Member

Choose a reason for hiding this comment

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

Will defer to @josh-berry. I do think however it is fairly trivial to just change this to string[] and wait until you see an empty slice at runtime to set the default 3 values.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not having the flag and adding it later is fine by me; so is accepting []string. The only thing I'm not thrilled about is making a breaking change (i.e. commas now and []string later).

Copy link
Member

@cretz cretz Apr 8, 2024

Choose a reason for hiding this comment

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

👍 @sebneira - can you make this type string[] and set the defaults in code on empty slice when no-fold is not set? You can still write "Defaults are completed, canceled, and terminated." and it won't be read as a special option like Default: is.

I think after this we can merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I updated the PR to include the string[] flag for fold which defaults to the completed, canceled and terminated if the flag is empty.

Also, as I was moving the options struct around it kinda dawned on me that the pkg made more sense as tracer rather than trace. Let me know if this doesn't make sense.

Copy link
Member

@cretz cretz Apr 9, 2024

Choose a reason for hiding this comment

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

👍 Not too concerned with internal package name (workflowtrace is probably the best tbh, but doesn't really matter here)

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Just pedantic stuff (would like to see fixed since easy though if you don't mind). Marking approved, LGTM overall.

temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace.go Outdated Show resolved Hide resolved
temporalcli/commands.workflow_trace_test.go Outdated Show resolved Hide resolved
Sebastian Neira and others added 3 commits April 9, 2024 15:35
Co-authored-by: Chad Retz <chad.retz@gmail.com>
Co-authored-by: Chad Retz <chad.retz@gmail.com>
Co-authored-by: Chad Retz <chad.retz@gmail.com>
@cretz cretz merged commit 4a14b05 into temporalio:cli-rewrite Apr 10, 2024
6 checks passed
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.

4 participants