Skip to content

Instantly share code, notes, and snippets.

@bcotton
Created January 9, 2019 00:08
Show Gist options
  • Save bcotton/5d4c035846697e6a20a43d37cbb15937 to your computer and use it in GitHub Desktop.
Save bcotton/5d4c035846697e6a20a43d37cbb15937 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
memoryTicker := time.NewTicker(time.Millisecond * 5)
leak := make(map[int][]byte)
i := 0
go func() {
for range memoryTicker.C {
leak[i] = make([]byte, 1024)
i++
}
}()
fileTicker := time.NewTicker(time.Millisecond * 5)
go func() {
os.Create("/tmp/file")
buffer := make([]byte, 1024)
defer f.Close()
for range fileTicker.C {
f.Write(buffer)
f.Sync()
}
}()
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":8081", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment