chore(openmetrics): use "app_id" label instead of "app_name"

Signed-off-by: Jyrki Gadinger <nilsding@nilsding.org>
This commit is contained in:
Jyrki Gadinger 2026-04-20 11:38:44 +02:00
parent 3e5daac0c5
commit e7b1b69e66
No known key found for this signature in database
GPG key ID: 2A6140D57BE5BB5A
2 changed files with 6 additions and 6 deletions

View file

@ -50,7 +50,7 @@ class AppInfo implements IMetricFamily {
$apps = [];
$enabledApps = $this->appManager->getEnabledApps();
foreach ($this->appManager->getAppInstalledVersions(false) as $appId => $version) {
yield new Metric(in_array($appId, $enabledApps, true) ? 1 : 0, ['app_name' => $appId, 'version' => $version]);
yield new Metric(in_array($appId, $enabledApps, true) ? 1 : 0, ['app_id' => $appId, 'version' => $version]);
}
}
}

View file

@ -39,14 +39,14 @@ class AppInfoTest extends ExporterTestCase {
public function testMetrics(): void {
$this->assertCount(4, $this->metrics);
foreach ($this->appList as $appName => $appVersion) {
$metricForApp = array_find($this->metrics, function (Metric $metric) use ($appName) {
return $metric->label('app_name') === $appName;
foreach ($this->appList as $appId => $appVersion) {
$metricForApp = array_find($this->metrics, function (Metric $metric) use ($appId) {
return $metric->label('app_id') === $appId;
});
$expectedMetricValue = in_array($appName, $this->installedAppsList) ? 1 : 0;
$expectedMetricValue = in_array($appId, $this->installedAppsList) ? 1 : 0;
$this->assertEquals($expectedMetricValue, $metricForApp->value);
$this->assertSame(['app_name' => $appName, 'version' => $appVersion], $metricForApp->labels);
$this->assertSame(['app_id' => $appId, 'version' => $appVersion], $metricForApp->labels);
}
}
}