Skip to content

Bring the Pyroscope banner back #2293

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

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ebpf/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/cilium/ebpf v0.11.0
github.com/go-kit/log v0.2.1
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8
github.com/hashicorp/golang-lru/v2 v2.0.3
github.com/hashicorp/golang-lru/v2 v2.0.5
github.com/klauspost/compress v1.16.7
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
Expand Down
4 changes: 2 additions & 2 deletions ebpf/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 h1:n6vlPhxsA+BW/XsS5+
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww=
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A=
github.com/hashicorp/golang-lru/v2 v2.0.3 h1:kmRrRLlInXvng0SmLxmQpQkpbYAvcXm7NPDrgxJa9mE=
github.com/hashicorp/golang-lru/v2 v2.0.3/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/grafana/pyroscope
go 1.19

require (
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59
github.com/bufbuild/connect-go v1.9.0
github.com/bufbuild/connect-grpchealth-go v1.0.0
github.com/cespare/xxhash/v2 v2.2.0
Expand All @@ -11,6 +12,7 @@ require (
github.com/dgryski/go-groupvarint v0.0.0-20230630160417-2bfb7969fb3c
github.com/drone/envsubst v1.0.3
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.15.0
github.com/felixge/fgprof v0.9.4-0.20221116204635-ececf7638e93
github.com/felixge/httpsnoop v1.0.3
github.com/go-kit/log v0.2.1
Expand Down Expand Up @@ -114,7 +116,6 @@ require (
github.com/efficientgo/core v1.0.0-rc.2 // indirect
github.com/efficientgo/e2e v0.14.1-0.20230710114240-c316eb95ae5b // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.17.7 h1:9Mtq1KM6nD8/+HStvWcvYnixJ5N8
github.com/aws/aws-sdk-go-v2/service/sts v1.17.7/go.mod h1:+lGbb3+1ugwKrNTWcf2RT05Xmp543B06zDFTwiTLp7I=
github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8=
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 h1:WWB576BN5zNSZc/M9d/10pqEx5VHNhaQ/yOVAkmj5Yo=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
github.com/baidubce/bce-sdk-go v0.9.138 h1:/1P4MT2QQtR6dG1n3SaQYfmzWWdI871mEL0458lYODo=
github.com/baidubce/bce-sdk-go v0.9.138/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
15 changes: 15 additions & 0 deletions pkg/phlare/phlare.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/grafana/pyroscope/pkg/tracing"
"github.com/grafana/pyroscope/pkg/usagestats"
"github.com/grafana/pyroscope/pkg/util"
"github.com/grafana/pyroscope/pkg/util/cli"
"github.com/grafana/pyroscope/pkg/validation"
"github.com/grafana/pyroscope/pkg/validation/exporter"
)
Expand Down Expand Up @@ -359,7 +360,21 @@ func (f *Phlare) setupModuleManager() error {
return nil
}

// made here https://patorjk.com/software/taag/#p=display&f=Doom&t=grafana%20pyroscope
// also needed to replace all ` with '
var banner = `
/ _|
__ _ _ __ __ _| |_ __ _ _ __ __ _ _ __ _ _ _ __ ___ ___ ___ ___ _ __ ___
/ _' | '__/ _' | _/ _' | '_ \ / _' | | '_ \| | | | '__/ _ \/ __|/ __/ _ \| '_ \ / _ \
| (_| | | | (_| | || (_| | | | | (_| | | |_) | |_| | | | (_) \__ \ (_| (_) | |_) | __/
\__, |_| \__,_|_| \__,_|_| |_|\__,_| | .__/ \__, |_| \___/|___/\___\___/| .__/ \___|
__/ | | | __/ | | |
|___/ |_| |___/ |_|
`

func (f *Phlare) Run() error {
_ = cli.GradientBanner(banner, os.Stderr)

serviceMap, err := f.ModuleManager.InitModuleServices(f.Cfg.Target...)
if err != nil {
return err
Expand Down
44 changes: 44 additions & 0 deletions pkg/util/cli/banner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cli

import (
"io"
"strings"

"github.com/aybabtme/rgbterm"
"github.com/fatih/color"
)

const (
startColor = 0xffd651
endColor = 0xf64d3d
)

func GradientBanner(banner string, w io.Writer) error {
if color.NoColor {
_, err := w.Write([]byte(banner + "\n"))
return err
}

arr := strings.Split(banner, "\n")
l := len(arr)
for i, line := range arr {
if len(line) == 0 {
continue
}
progress := float64(i) / float64(l-1)
r := gradient(startColor, endColor, 16, progress)
g := gradient(startColor, endColor, 8, progress)
b := gradient(startColor, endColor, 0, progress)
_, err := w.Write([]byte(rgbterm.FgString(line, r, g, b) + "\n"))
if err != nil {
return nil
}
}
return nil
}

func gradient(start, end, offset int, progress float64) uint8 {
start = (start >> offset) & 0xff
end = (end >> offset) & 0xff
return uint8(start + int(float64(end-start)*progress))
}