-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
508 additions
and
113 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,78 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/spacemeshos/go-spacemesh/metrics" | ||
) | ||
|
||
const ( | ||
namespace = "server" | ||
protoLabel = "protocol" | ||
) | ||
|
||
var ( | ||
targetQueue = metrics.NewGauge( | ||
"target_queue", | ||
namespace, | ||
"target size of the queue", | ||
[]string{protoLabel}, | ||
) | ||
queue = metrics.NewGauge( | ||
"queue", | ||
namespace, | ||
"actual size of the queue", | ||
[]string{protoLabel}, | ||
) | ||
targetRps = metrics.NewGauge( | ||
"rps", | ||
namespace, | ||
"target requests per second", | ||
[]string{protoLabel}, | ||
) | ||
requests = metrics.NewCounter( | ||
"requests", | ||
namespace, | ||
"requests counter", | ||
[]string{protoLabel, "state"}, | ||
) | ||
clientLatency = metrics.NewHistogramWithBuckets( | ||
"client_latency_seconds", | ||
namespace, | ||
"latency since initiating a request", | ||
[]string{protoLabel, "result"}, | ||
prometheus.ExponentialBuckets(0.01, 2, 10), | ||
) | ||
serverLatency = metrics.NewHistogramWithBuckets( | ||
"server_latency_seconds", | ||
namespace, | ||
"latency since accepting new stream", | ||
[]string{protoLabel}, | ||
prometheus.ExponentialBuckets(0.01, 2, 10), | ||
) | ||
) | ||
|
||
func newTracker(protocol string) *tracker { | ||
return &tracker{ | ||
targetQueue: targetQueue.WithLabelValues(protocol), | ||
queue: queue.WithLabelValues(protocol), | ||
targetRps: targetRps.WithLabelValues(protocol), | ||
completed: requests.WithLabelValues(protocol, "completed"), | ||
accepted: requests.WithLabelValues(protocol, "accepted"), | ||
dropped: requests.WithLabelValues(protocol, "dropped"), | ||
serverLatency: serverLatency.WithLabelValues(protocol), | ||
clientLatency: clientLatency.WithLabelValues(protocol, "success"), | ||
clientLatencyFailure: clientLatency.WithLabelValues(protocol, "failure"), | ||
} | ||
} | ||
|
||
type tracker struct { | ||
targetQueue prometheus.Gauge | ||
queue prometheus.Gauge | ||
targetRps prometheus.Gauge | ||
completed prometheus.Counter | ||
accepted prometheus.Counter | ||
dropped prometheus.Counter | ||
serverLatency prometheus.Observer | ||
clientLatency, clientLatencyFailure prometheus.Observer | ||
} |
Oops, something went wrong.