-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #640 from Darkren/feature/victoria-metrics
Swap Prometheus with Victoria Metrics
- Loading branch information
Showing
693 changed files
with
24,806 additions
and
69,576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
package setupmetrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/skycoin/skywire/pkg/routing" | ||
) | ||
|
||
// NewEmpty creates a new metrics implementation that does nothing. | ||
func NewEmpty() Metrics { | ||
return empty{} | ||
func NewEmpty() Empty { | ||
return Empty{} | ||
} | ||
|
||
type empty struct{} | ||
// Empty is a `Metrics` implementation which does nothing. | ||
type Empty struct{} | ||
|
||
func (empty) Collectors() []prometheus.Collector { | ||
return nil | ||
} | ||
func (empty) RecordRequest(routing.BidirectionalRoute) func(*routing.EdgeRules, *error) { | ||
// RecordRequest implements `Metrics`. | ||
func (Empty) RecordRequest() func(*routing.EdgeRules, *error) { | ||
return func(*routing.EdgeRules, *error) {} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package setupmetrics | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/VictoriaMetrics/metrics" | ||
|
||
"github.com/skycoin/dmsg/metricsutil" | ||
|
||
"github.com/skycoin/skywire/pkg/routing" | ||
) | ||
|
||
// Metrics collects metrics in prometheus format. | ||
type Metrics interface { | ||
RecordRequest() func(*routing.EdgeRules, *error) | ||
} | ||
|
||
// VictoriaMetrics implements `Metrics` using Victoria Metrics. | ||
type VictoriaMetrics struct { | ||
activeRequests *metricsutil.VictoriaMetricsIntGaugeWrapper | ||
reqDurationsFailed *metrics.Histogram | ||
reqDurationsSuccesses *metrics.Histogram | ||
} | ||
|
||
// NewVictoriaMetrics returns the Victoria Metrics implementation of Metrics. | ||
func NewVictoriaMetrics() *VictoriaMetrics { | ||
return &VictoriaMetrics{ | ||
activeRequests: metricsutil.NewVictoriaMetricsIntGauge("active_request_count"), | ||
reqDurationsFailed: metrics.GetOrCreateHistogram("request_durations{success=\"true\"}"), | ||
reqDurationsSuccesses: metrics.GetOrCreateHistogram("request_durations{success=\"false\"}"), | ||
} | ||
} | ||
|
||
// RecordRequest implements `Metrics`. | ||
func (m *VictoriaMetrics) RecordRequest() func(rules *routing.EdgeRules, err *error) { | ||
start := time.Now() | ||
m.activeRequests.Inc() | ||
|
||
return func(rules *routing.EdgeRules, err *error) { | ||
if *err == nil { | ||
m.reqDurationsSuccesses.UpdateDuration(start) | ||
} else { | ||
m.reqDurationsFailed.UpdateDuration(start) | ||
} | ||
|
||
m.activeRequests.Dec() | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.