You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-12 23:50:13 +02:00
datadog example
This commit is contained in:
9
examples/datadog/go.mod
Normal file
9
examples/datadog/go.mod
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module github.com/felixge/go-profiler-notes/examples/datadog
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/DataDog/datadog-go v4.2.0+incompatible // indirect
|
||||||
|
github.com/google/uuid v1.1.4 // indirect
|
||||||
|
gopkg.in/DataDog/dd-trace-go.v1 v1.28.0
|
||||||
|
)
|
7
examples/datadog/go.sum
Normal file
7
examples/datadog/go.sum
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
github.com/DataDog/datadog-go v4.2.0+incompatible h1:Q73jzyKHwyA04Gf4SSukRF+KR4wJEimU6tAuU0B8Y4Y=
|
||||||
|
github.com/DataDog/datadog-go v4.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||||
|
github.com/google/uuid v1.1.4 h1:0ecGp3skIrHWPNGPJDaBIghfA6Sp7Ruo2Io8eLKzWm0=
|
||||||
|
github.com/google/uuid v1.1.4/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
|
gopkg.in/DataDog/dd-trace-go.v1 v1.28.0 h1:EmglUJuykRsTwsQDcKaAo3CmOunWU6Dqk7U2lo7Pjss=
|
||||||
|
gopkg.in/DataDog/dd-trace-go.v1 v1.28.0/go.mod h1:Sp1lku8WJMvNV0kjDI4Ni/T7J/U3BO5ct5kEaoVU8+I=
|
43
examples/datadog/main.go
Normal file
43
examples/datadog/main.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
_ "net/http/pprof"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gopkg.in/DataDog/dd-trace-go.v1/profiler"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := run(); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run() error {
|
||||||
|
if err := startProfiler(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer profiler.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func startProfiler() error {
|
||||||
|
return profiler.Start(
|
||||||
|
profiler.WithService("datadog-example"),
|
||||||
|
profiler.WithEnv("localhost"),
|
||||||
|
profiler.WithVersion("1.0"),
|
||||||
|
profiler.WithProfileTypes(
|
||||||
|
profiler.CPUProfile,
|
||||||
|
profiler.HeapProfile,
|
||||||
|
profiler.MutexProfile,
|
||||||
|
profiler.GoroutineProfile,
|
||||||
|
profiler.BlockProfile,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
Reference in New Issue
Block a user