Skip to content

Commit

Permalink
Add doc (#2)
Browse files Browse the repository at this point in the history
* Add doc

* Update for review comments

* More review comments
  • Loading branch information
plorenz authored Sep 15, 2022
1 parent 6db5171 commit d7f79ec
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- release-v*
pull_request:
workflow_dispatch:

env:
Expand Down Expand Up @@ -88,6 +89,7 @@ jobs:
./gradlew build
./gradlew copyDeps
jpackage --verbose --app-version $($(go env GOPATH)/bin/ziti-ci -q -l java get-next-version) "@jpackage.cfg" "@jpackage-darwin.cfg"
mv build/distributions/goroutine-analyzer-$($(go env GOPATH)/bin/ziti-ci -q -l java get-next-version).dmg build/distributions/goroutine-analyzer-$($(go env GOPATH)/bin/ziti-ci -q -l java get-next-version)-amd64.dmg
- id: upload-installer
name: Upload installer
Expand Down Expand Up @@ -147,5 +149,14 @@ jobs:
./gradlew build
./gradlew copyDeps
jpackage --verbose --app-version $($(go env GOPATH)/bin/ziti-ci -q -l java get-next-version) "@jpackage.cfg" "@jpackage-linux.cfg"
- id: publish
name: Publish
if: github.repository_owner == 'openziti' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-v'))
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ziti_ci_gpg_key: ${{ secrets.ZITI_CI_GPG_KEY }}
ziti_ci_gpg_key_id: ${{ secrets.ZITI_CI_GPG_KEY_ID }}
run: |
$(go env GOPATH)/bin/ziti-ci tag -v -f version
gh release create $($(go env GOPATH)/bin/ziti-ci -q get-current-version) build/distributions/*
89 changes: 83 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,92 @@
# goroutine-analyzer

This is GUI tool for helping analyze golang goroutine dumps. It lets you organize dumps by grouping sets of similar goroutines (inspired by: https://github.com/linuxerwang/goroutine-inspect). It also lets you group goroutines by using regular expressions. Muliple dumps can be viewed at once, though there aren't any tools yet to diff dumps.
## Overview
This is a GUI tool for helping analyze golang goroutine dumps. It has the following features:

The tool is written in Java for expediency on the UI front and was also inspired by TDA (thread dump analyzer).
* Working with multiple dumps
* Grouping, extracting or hiding similar goroutines, either manually or automatically
* Regex based grouping

To run, download and execute `./gradlew run`
The tool was written to support production deployments of [OpenZiti](https://github.com/openziti/ziti).
It works well together with the [agent library](https://github.com/openziti/agent) which supports
debugging operations such as extracting stackdumps and getting pprof dumps.

The tool is written in Java for expediency on the UI front.

## Installation
Installers can be downloaded for the latest release at https://github.com/openziti/goroutine-analyzer/releases/latest

The following are available:

* Windows x64
* MacOS x64
* MacOS M1 support will be provided once GitHub actions provides M1 runners. In the meantime, you can use an
application bundle or just clone and run.
* Linux .deb
* rpm builds are currently unavailable as GitHub actions only provides ubuntu runners. If anyone is interested
an appimage build would probably be straightforward to add.
* Application bundles with start scripts if Java is pre-installed on your system

The application can also be run from source by cloning the repository and running `./gradlew run`. I run with
Java 17, but it will likely work with older versions as well.

## How to use
### Opening Stack Dumps
Stack dumps can be opened from the file system. Multiple can be selected, and more can be added to the open set at any
time.

![Open Dialog](./doc/opening.png "Open Dialog")

Once opened, the stack dumps will be shown unfiltered. Here the set of routines has been expanded. Whatever
goroutine group or individual goroutine has been selected will be shown in the window on the right.

![Initial View](./doc/initial-view.png "Initial View")

### Auto-Sorting Goroutines
Usually the first thing I'll do when looking at a stack dump is to group all the similar gorotines together. This
can be done as follows:

![Extracting Duplicated Goroutines](./doc/extract-duplicated.png "Extracting Duplicated Goroutines")

When the operation is complete, you'll see anything which is duplicated pulled out into its own group. Any unique
goroutines will be left in the initial routines view.

In order to group goroutines, they are compared ignoring any object pointers. As long as the methods and line numbers
match up, they will be considered equivalent.

![Extract Duplicates Results](./doc/extract-duplicated-results.png "Extract Duplicates Results")

### Filtering
Sometimes you want to find all goroutines related to a given package, method or pointer. You can do this with a filter.

![Create Filter Option](./doc/create-filter.png "Create Filter Option")

A filter is specified using a regular expression and will be matched against the full text of each goroutine.

![Create Filter](./doc/create-filter-2.png "Create Filter")

Any goroutines matching the regular expression will be placed into their own group.

![Create Filter Result](./doc/filter-result.png "Create Filter Result")

After the filter is created, it can be edited or deleted.

### Other Operations
In addition, if you're trying to narrow things down iteratively, you can select individual goroutines and perform
the following operations.

![Other Operations](./doc/stack-options.png "Other Operations")

* `Group Goroutines Like This` - find other goroutines like this and put them in a group, leaving them in the routines group
* `Hide Goroutine` - hide this goroutine from view. Display of hidden goroutines can be toggle on and off at the group level
* `Unide Goroutine` - show this goroutine again. Only displays for hidden goroutines
* `Hide Goroutines Like This` - hides all goroutines matching this one
* `Separate Goroutines Like This` - acts like the group option except that the goroutines are also removed from the current group.

## Thank you
This tool was inspired by
This tool was inspired by the following:

* TDA (thread dump analyzer). I tried to find a link to this, but was unable to find the original. Ping me if you've got a link
* [TDA (thread dump analyzer)](https://github.com/mkbrv/tda) - Original version at https://java.net/projects/tda doesn't seem to be available anymore
* [goroutine-inspect](https://github.com/linuxerwang/goroutine-inspect)

The build was helped along by [this very helpful example repo from github user sualeh](https://github.com/sualeh/build-jpackage)
The build was helped along by [this very helpful example repo from GitHub user sualeh](https://github.com/sualeh/build-jpackage)
Binary file added doc/create-filter-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/create-filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/extract-duplicated-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/extract-duplicated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/filter-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/initial-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/opening.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/stack-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d7f79ec

Please sign in to comment.