Skip to content

Commit

Permalink
Adjusted kelon metrics (#99)
Browse files Browse the repository at this point in the history
* Renamed telemetry provider file
* Removed prometheus metrics for databases and adjusted labels of common prom http metrics
  • Loading branch information
Matthias Jörg committed Dec 22, 2020
1 parent 5f56cf2 commit df44dbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
37 changes: 5 additions & 32 deletions pkg/telemetry/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ var (
Name: "http_requests_total",
Help: "Count of all HTTP requests",
}, []string{"code", "method"})
errorsCount = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "errors_total",
Help: "A gauge of non-fatal errors.",
})
databaseRequestsTotal = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "datastore_requests_total",
Help: "Count of all Datastore requests",
})
databaseErrorsCount = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "datastore_errors_total",
Help: "A gauge of non-fatal errors during datastore requests errors.",
})
inFlightRequests = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "in_flight_requests",
Help: "A gauge of requests currently being served by the wrapped handler.",
Expand All @@ -51,15 +39,7 @@ var (
Help: "A histogram of latencies for requests.",
Buckets: []float64{.05, .1, .5, 1, 2.5, 10},
},
[]string{"handler", "method"},
)
datastoreRequestDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "datastore_request_duration_seconds",
Help: "A histogram of latencies for datastore requests.",
Buckets: []float64{.05, .1, .5, 1, 2.5, 10},
},
[]string{"database"},
[]string{"handler", "method", "code"},
)
// responseSize has no labels, making it a zero-dimensional
// ObserverVec.
Expand All @@ -69,7 +49,7 @@ var (
Help: "A histogram of request sizes.",
Buckets: []float64{100, 400, 900, 1500},
},
[]string{},
[]string{"code", "method"},
)
)

Expand All @@ -79,9 +59,7 @@ func (p *Prometheus) Configure() error {
// System stats
p.registry.MustRegister(version, prometheus.NewGoCollector(), prometheus.NewBuildInfoCollector())
// Http
p.registry.MustRegister(httpRequestsTotal, inFlightRequests, duration, requestSize, errorsCount)
// Datastores
p.registry.MustRegister(databaseRequestsTotal, datastoreRequestDuration, databaseErrorsCount)
p.registry.MustRegister(httpRequestsTotal, inFlightRequests, duration, requestSize)

log.Infoln("Configured Prometheus.")
}
Expand All @@ -105,16 +83,11 @@ func (p *Prometheus) GetHTTPMetricsHandler() (http.Handler, error) {
}

func (p *Prometheus) CheckError(err error) {
errorsCount.Inc()
// not needed in prometheus
}

func (p *Prometheus) MeasureRemoteDependency(request *http.Request, alias string, dependencyType string, queryTime time.Duration, data string, success bool) {
databaseRequestsTotal.Inc()
if success {
datastoreRequestDuration.With(prometheus.Labels{"database": alias}).Observe(queryTime.Seconds())
} else {
databaseErrorsCount.Inc()
}
// not needed in prometheus
}

func (p *Prometheus) Shutdown() {}
File renamed without changes.

0 comments on commit df44dbe

Please sign in to comment.