mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
Merge pull request #57764 from nextcloud/fix/openmetrics_labels
This commit is contained in:
commit
8af5e06b62
3 changed files with 24 additions and 6 deletions
|
|
@ -52,8 +52,8 @@ class InstanceInfo implements IMetricFamily {
|
|||
yield new Metric(
|
||||
1,
|
||||
[
|
||||
'full version' => $this->serverVersion->getHumanVersion(),
|
||||
'major version' => (string)$this->serverVersion->getVersion()[0],
|
||||
'full_version' => $this->serverVersion->getHumanVersion(),
|
||||
'major_version' => (string)$this->serverVersion->getVersion()[0],
|
||||
'build' => $this->serverVersion->getBuild(),
|
||||
'installed' => $this->systemConfig->getValue('installed', false) ? '1' : '0',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -25,12 +25,30 @@ abstract class ExporterTestCase extends TestCase {
|
|||
$this->metrics = iterator_to_array($this->exporter->metrics());
|
||||
}
|
||||
|
||||
public function testNotEmptyData() {
|
||||
public function testNotEmptyData(): void {
|
||||
$this->assertNotEmpty($this->exporter->name());
|
||||
$this->assertNotEmpty($this->metrics);
|
||||
}
|
||||
|
||||
protected function assertLabelsAre(array $expectedLabels) {
|
||||
public function testValidNames(): void {
|
||||
$labelNames = [];
|
||||
foreach ($this->metrics as $metric) {
|
||||
foreach ($metric->labels as $label => $value) {
|
||||
$labelNames[$label] = $label;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($labelNames)) {
|
||||
$this->expectNotToPerformAssertions();
|
||||
return;
|
||||
}
|
||||
foreach ($labelNames as $label) {
|
||||
$this->assertMatchesRegularExpression('/^[a-z_][a-z0-9_]*$/i', $label);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function assertLabelsAre(array $expectedLabels): void {
|
||||
$foundLabels = [];
|
||||
foreach ($this->metrics as $metric) {
|
||||
$foundLabels[] = $metric->labels;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ class InstanceInfoTest extends ExporterTestCase {
|
|||
$this->assertCount(1, $this->metrics);
|
||||
$metric = array_pop($this->metrics);
|
||||
$this->assertSame([
|
||||
'full version' => '33.13.17 Gold',
|
||||
'major version' => '33',
|
||||
'full_version' => '33.13.17 Gold',
|
||||
'major_version' => '33',
|
||||
'build' => 'dev',
|
||||
'installed' => '0',
|
||||
], $metric->labels);
|
||||
|
|
|
|||
Loading…
Reference in a new issue