Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arussellsaw/telemetry
Metric reporting for Go applications
https://github.com/arussellsaw/telemetry
Last synced: 6 days ago
JSON representation
Metric reporting for Go applications
- Host: GitHub
- URL: https://github.com/arussellsaw/telemetry
- Owner: arussellsaw
- Created: 2015-05-03T10:06:21.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-13T22:24:25.000Z (over 9 years ago)
- Last Synced: 2024-08-02T07:11:22.974Z (3 months ago)
- Language: Go
- Homepage:
- Size: 258 KB
- Stars: 78
- Watchers: 5
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-influxdb - telemetry - metric reporting for Go applications (Collecting data into InfluxDB / Libraries)
README
# telemetry
[![build-status](https://travis-ci.org/arussellsaw/telemetry.svg?branch=master)](https://travis-ci.org/arussellsaw/telemetry) [![code-coverage](http://gocover.io/_badge/github.com/arussellsaw/telemetry)](http://gocover.io/github.com/arussellsaw/telemetry)
[![go-doc](https://godoc.org/github.com/arussellsaw/telemetry?status.svg)](https://godoc.org/github.com/arussellsaw/telemetry)metric reporting for Go applications
sample usage:
```go
package mainimport(
"github.com/arussellsaw/telemetry"
"github.com/arussellsaw/telemetry/reporters"
"time"
"net/http"
)func main() {
//New telemetry object (prefix, maintainance schedule)
tel := telemetry.New("test", 5 * time.Second)
avg := telemetry.NewAverage(tel, "average", 60 * time.Second)//Register influxdb reporter
influx := reporters.InfluxReporter{
Host: "192.168.1.100:8086",
Interval: 60 * time.Second,
Tel: tel,
Database: "telemetry"
}
influx.Report() //trigger reporting loop//Create http handler for json metrics
telemetryHandler := reporters.TelemetryHandler{
Tel: tel,
}
http.HandleFunc("/metrics", telemetryHandler.ServeHTTP)
http.ListenAndServe(":8080", nil)start = time.Now()
somethingYouWantToTime()
avg.Add(tel, float64(time.Since(start).Nanoseconds()))
}```