package main
import (
"context"
su "github.com/ppzxc/go-prom-pprof-utils"
"github.com/sirupsen/logrus"
"net"
"os"
"time"
)
func main() {
ctx, _ := context.WithCancel(context.Background())
addr := net.TCPAddr{
IP: net.ParseIP("0.0.0.0"),
Port: 8080,
}
logger := logrus.Logger{
Out: os.Stdout,
Formatter: &logrus.TextFormatter{},
ReportCaller: true,
Level: logrus.TraceLevel,
}
err := su.NewStatUtils(ctx, "TEST", true, &addr, &logger)
if err != nil {
panic(err)
}
su.SetGauge("fill")
su.SetGauge("session", "type")
su.SetCounter("fill2")
su.SetCounter("session2", "type")
su.SetHistogram("fill3", []float64{0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.5, 1, 5, 10, 20, 30})
su.SetHistogram("session3", []float64{0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.5, 1, 5, 10, 20, 30}, "type", "query", "dd")
go func() {
for {
now := time.Now()
su.Increase("fill")
su.Increase("session", "tcp")
su.Increase("session", "websocket")
su.Increase("fill2")
su.Increase("session2", "tcp")
su.Increase("session2", "websocket")
su.IncreaseHistogram("fill3", now)
su.IncreaseHistogram("session3", now, "db", "query1", "ee")
su.IncreaseHistogram("session3", now, "db", "query3", "ee")
su.IncreaseHistogram("session3", now, "db", "query2", "ee")
su.IncreaseHistogram("session3", now, "db", "query5", "ee")
time.Sleep(1 * time.Second)
}
}()
su.Serve()
}
go-prom-pprof-utils's Introduction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.