-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
instrument server with prometheus metrics; fixes #267
Signed-off-by: Denys Smirnov <[email protected]>
- Loading branch information
Showing
8 changed files
with
301 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package daemon | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
// Enry metrics | ||
var ( | ||
totalEnryCalls = promauto.NewCounter(prometheus.CounterOpts{ | ||
Name: "bblfshd_enry_total", | ||
Help: "The total number of calls to Enry to detect the language", | ||
}) | ||
enryLangResults = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "bblfshd_enry_langs", | ||
Help: "The total number of Enry results for each programming language", | ||
}, []string{"lang"}) | ||
enryOtherResults = enryLangResults.WithLabelValues("other") | ||
enryDetectLatency = promauto.NewHistogram(prometheus.HistogramOpts{ | ||
Name: "bblfshd_enry_seconds", | ||
Help: "Time spent for detecting the language (seconds)", | ||
}) | ||
) | ||
|
||
var ( | ||
driverLabelNames = []string{"lang", "image"} | ||
) | ||
|
||
// Driver Control API metrics | ||
var ( | ||
driverInstallCalls = promauto.NewCounter(prometheus.CounterOpts{ | ||
Name: "bblfshd_driver_install_total", | ||
Help: "The total number of calls to install a driver", | ||
}) | ||
driverRemoveCalls = promauto.NewCounter(prometheus.CounterOpts{ | ||
Name: "bblfshd_driver_remove_total", | ||
Help: "The total number of calls to remove a driver", | ||
}) | ||
) | ||
|
||
// Public API metrics | ||
var ( | ||
parseCalls = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "bblfshd_parse_total", | ||
Help: "The total number of parse requests", | ||
}, []string{"vers"}) | ||
parseErrors = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "bblfshd_parse_errors", | ||
Help: "The total number of failed parse requests", | ||
}, []string{"vers"}) | ||
parseLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: "bblfshd_parse_seconds", | ||
Help: "Time spent on parse requests (seconds)", | ||
}, []string{"vers"}) | ||
parseContentSize = promauto.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: "bblfshd_parse_bytes", | ||
Help: "Size of parsed files", | ||
}, []string{"vers"}) | ||
|
||
parseCallsV1 = parseCalls.WithLabelValues("v1") | ||
parseErrorsV1 = parseErrors.WithLabelValues("v1") | ||
parseLatencyV1 = parseLatency.WithLabelValues("v1") | ||
parseContentSizeV1 = parseContentSize.WithLabelValues("v1") | ||
|
||
parseCallsV2 = parseCalls.WithLabelValues("v2") | ||
parseErrorsV2 = parseErrors.WithLabelValues("v2") | ||
parseLatencyV2 = parseLatency.WithLabelValues("v2") | ||
parseContentSizeV2 = parseContentSize.WithLabelValues("v2") | ||
|
||
versionCalls = promauto.NewCounter(prometheus.CounterOpts{ | ||
Name: "bblfshd_version_total", | ||
Help: "The total number of version requests", | ||
}) | ||
languagesCalls = promauto.NewCounter(prometheus.CounterOpts{ | ||
Name: "bblfshd_languages_total", | ||
Help: "The total number of supported languages requests", | ||
}) | ||
) | ||
|
||
// Scaling metrics | ||
var ( | ||
driversSpawned = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "bblfshd_driver_spawn", | ||
Help: "The total number of driver spawn requests", | ||
}, driverLabelNames) | ||
driversSpawnErrors = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "bblfshd_driver_spawn_errors", | ||
Help: "The total number of errors for driver spawn requests", | ||
}, driverLabelNames) | ||
driversKilled = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "bblfshd_driver_kill", | ||
Help: "The total number of driver kill requests", | ||
}, driverLabelNames) | ||
|
||
driversRunning = promauto.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "bblfshd_driver_scaling_total", | ||
Help: "The total number of drivers running", | ||
}, driverLabelNames) | ||
driversIdle = promauto.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "bblfshd_driver_scaling_idle", | ||
Help: "The total number of idle drivers", | ||
}, driverLabelNames) | ||
driversRequests = promauto.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "bblfshd_driver_scaling_load", | ||
Help: "The total number of requests waiting for a driver", | ||
}, driverLabelNames) | ||
driversTarget = promauto.NewGaugeVec(prometheus.GaugeOpts{ | ||
Name: "bblfshd_driver_scaling_target", | ||
Help: "The target number of drivers instances", | ||
}, driverLabelNames) | ||
) |
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
Oops, something went wrong.