-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package args | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
|
||
"github.com/grafana/pyroscope-go" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
func InitPyroscope() (*pyroscope.Profiler, error) { | ||
klog.Info("initializing pyroscope") | ||
|
||
runtime.SetMutexProfileFraction(5) | ||
runtime.SetBlockProfileRate(5) | ||
|
||
return pyroscope.Start(pyroscope.Config{ | ||
ApplicationName: "deployment-operator", | ||
|
||
// replace this with the address of pyroscope server | ||
ServerAddress: PyroscopeAddress(), | ||
|
||
// you can disable logging by setting this to nil | ||
Logger: pyroscope.StandardLogger, | ||
|
||
// optionally, if authentication is enabled, specify the API key: | ||
// AuthToken: os.Getenv("PYROSCOPE_AUTH_TOKEN"), | ||
|
||
// you can provide static tags via a map: | ||
Tags: map[string]string{"hostname": os.Getenv("HOSTNAME")}, | ||
|
||
ProfileTypes: []pyroscope.ProfileType{ | ||
// these profile types are enabled by default: | ||
pyroscope.ProfileCPU, | ||
pyroscope.ProfileAllocObjects, | ||
pyroscope.ProfileAllocSpace, | ||
pyroscope.ProfileInuseObjects, | ||
pyroscope.ProfileInuseSpace, | ||
|
||
// these profile types are optional: | ||
pyroscope.ProfileGoroutines, | ||
pyroscope.ProfileMutexCount, | ||
pyroscope.ProfileMutexDuration, | ||
pyroscope.ProfileBlockCount, | ||
pyroscope.ProfileBlockDuration, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters