bugfix: fix type of the prometheus metric act req as count (#370)
* bugfix: change action request cnt type as Counter * bugfix: fix type of act req count and typo * bugfix: change to correct type of act req in TC --------- Co-authored-by: wushuzh <wushuzh@outlook.com>
This commit is contained in:
parent
ffcd19e748
commit
d9e921950f
|
|
@ -0,0 +1,16 @@
|
||||||
|
#
|
||||||
|
# Integration Test Config: General
|
||||||
|
#
|
||||||
|
|
||||||
|
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||||
|
|
||||||
|
logLevel: "DEBUG"
|
||||||
|
checkForUpdates: false
|
||||||
|
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
defaultGoMetrics: false
|
||||||
|
|
||||||
|
actions:
|
||||||
|
- title: Hello OliveTin
|
||||||
|
shell: echo "Hello OliveTin"
|
||||||
|
|
@ -25,6 +25,10 @@ class OliveTinTestRunner {
|
||||||
baseUrl() {
|
baseUrl() {
|
||||||
return this.BASE_URL
|
return this.BASE_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metricsUrl() {
|
||||||
|
return new URL('metrics', this.baseUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OliveTinTestRunnerStartLocalProcess extends OliveTinTestRunner {
|
class OliveTinTestRunnerStartLocalProcess extends OliveTinTestRunner {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { describe, it, before, after } from 'mocha'
|
||||||
|
import { expect } from 'chai'
|
||||||
|
|
||||||
|
import { By } from 'selenium-webdriver'
|
||||||
|
|
||||||
|
let metrics = [
|
||||||
|
{'name': 'olivetin_actions_requested_count', 'type': 'counter', 'desc': 'The actions requested count'},
|
||||||
|
{'name': 'olivetin_config_action_count', 'type': 'gauge', 'desc': 'The number of actions in the config file'},
|
||||||
|
{'name': 'olivetin_config_reloaded_count', 'type': 'counter', 'desc': 'The number of times the config has been reloaded'},
|
||||||
|
{'name': 'olivetin_sv_count', 'type': 'gauge', 'desc': 'The number entries in the sv map'},
|
||||||
|
]
|
||||||
|
|
||||||
|
describe('config: prometheus', function () {
|
||||||
|
before(async function () {
|
||||||
|
await runner.start('prometheus')
|
||||||
|
})
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
await runner.stop()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Metrics are available with correct types', async () => {
|
||||||
|
webdriver.get(runner.metricsUrl())
|
||||||
|
const prometheusOutput = await webdriver.findElement(By.tagName('pre')).getText()
|
||||||
|
|
||||||
|
expect(prometheusOutput).to.not.be.null
|
||||||
|
metrics.forEach(({name, type, desc}) => {
|
||||||
|
const metaLines = `# HELP ${name} ${desc}\n`
|
||||||
|
+ `# TYPE ${name} ${type}\n`
|
||||||
|
expect(prometheusOutput).to.match(new RegExp(metaLines))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
var (
|
var (
|
||||||
metricConfigActionCount = promauto.NewGauge(prometheus.GaugeOpts{
|
metricConfigActionCount = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "olivetin_config_action_count",
|
Name: "olivetin_config_action_count",
|
||||||
Help: "Then number of actions in the config file",
|
Help: "The number of actions in the config file",
|
||||||
})
|
})
|
||||||
|
|
||||||
metricConfigReloadedCount = promauto.NewCounter(prometheus.CounterOpts{
|
metricConfigReloadedCount = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
metricActionsRequested = promauto.NewGauge(prometheus.GaugeOpts{
|
metricActionsRequested = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
Name: "olivetin_actions_requested_count",
|
Name: "olivetin_actions_requested_count",
|
||||||
Help: "The actions requested count",
|
Help: "The actions requested count",
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue