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 the first iteration of the blocks viewer cli tool #2697

Merged
merged 11 commits into from
Nov 17, 2023
Merged

Conversation

aleks-p
Copy link
Contributor

@aleks-p aleks-p commented Nov 15, 2023

Addresses #2541

Usage:

  1. profilecli tool blocks web --bucket-name <object_store_bucket_name>
  2. Open http://localhost:4201/blocks/index in a browser (the URL is also printed to stdout)

Notes:

  • data comes from a object store bucket, though some things are cached on disk (e.g., the meta.json data)
  • will use existing user credentials (tested with GCS only)
  • blocks are grouped by "min time" to make them easier to navigate
  • block groups are sorted by "min time" (descending), blocks within a group are sorted by "upload time" (descending)

Next steps (outside of this PR):

  • porting it to an admin page
  • adding a visualization that can show overlapping blocks
Screen.Recording.2023-11-17.at.07.55.34.mov

@aleks-p aleks-p marked this pull request as ready for review November 17, 2023 11:59
@aleks-p aleks-p requested a review from a team as a code owner November 17, 2023 11:59
Comment on lines 54 to 55
blocksWebToolCmd.Flag("object-store-type", "The type of the object storage (e.g., gcs).").Default("gcs").StringVar(&params.objectStoreType)
blocksWebToolCmd.Flag("bucket-name", "The name of the object storage bucket.").StringVar(&params.bucketName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I really would prefer if we could mimic flags from pyroscope itself and support all the options by calling RegisterFlags.

Unsure that might be also incredibly hard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried but it doesn't seem simple enough to do without a bigger refactor, can plan this for later though.

Copy link
Contributor

@simonswine simonswine left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM, just a a few comments, I don't think anything is really blocking before merging, but have a look and adapt things that make sense to you 🙂

@@ -0,0 +1 @@
package admin
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure we need this at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that is a leftover from something else, good catch!

cmd/profilecli/main.go Outdated Show resolved Hide resolved
out := output(ctx)

fmt.Fprintf(out, "The blocks web tool is available at http://localhost:%d/blocks/index\n", t.params.httpListenPort)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good idea and perhaps it needs to be behind a flag if someone finds getting multiple tabs from multiple runs annoying. One issue with most solutions though is they are not robust enough. For example, to open the browser only when the server is successfully up we need to do something like https://stackoverflow.com/questions/32738188/how-can-i-start-the-browser-after-the-server-started-listening/32742904#32742904 but we can't since we don't start the server this way.

Copy link
Contributor

@simonswine simonswine left a comment

Choose a reason for hiding this comment

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

Ticked the wrong box

@aleks-p aleks-p merged commit d87e810 into main Nov 17, 2023
17 checks passed
@aleks-p aleks-p deleted the block-viewer-cli branch November 17, 2023 19:54
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.

None yet

2 participants