Files
coder/codersdk/appname_internal_test.go
T
Ehab Younes bacb4fc6ed feat: expose per-app session counts (#29351)
Track individual applications across deployment statistics, Prometheus, telemetry, and the dashboard instead of exposing only fixed family totals. Preserve existing fields and gauges so current consumers can migrate without breaking.

- Add per-app counts with normalized identifiers and registry-backed display names, families, and bundled icons. Unrecognized apps retain their identifiers.
- Limit each statistics report to 64 distinct app names, combining excess names into an explicit overflow bucket.
- Group dashboard connections by family, including an Other category, with alphabetical per-app tooltips and distinct loading and empty states.
- Export app-keyed Prometheus counts separately from current family metadata, allowing queries to enrich historical counts without rewriting stored samples.
- Document family queries with unknown fallback, deployment isolation, and replica handling, alongside collection behavior and migration guidance.
- Include per-app counts in telemetry, update API schemas and documentation, and add regression coverage across collection, metrics, and dashboard behavior.

Closes #27411
2026-09-24 15:12:28 +03:00

33 lines
1.0 KiB
Go

package codersdk
import (
"testing"
"github.com/stretchr/testify/require"
)
// Lookups fold input through NormalizeAppName before probing, so map keys
// that are not already normalized can never match.
func TestAppNameFamilyKeysAreNormalized(t *testing.T) {
t.Parallel()
for name := range sessionApps {
require.NotEmpty(t, name)
require.Equal(t, NormalizeAppName(name), name)
}
}
// Families reach the queries as jsonb values and metric labels, so a blank
// entry would attribute sessions to an unusable name. AppFamilyUnknown is the
// fold destination for unregistered apps, not something to register.
func TestAppNameFamilyValuesAreUsable(t *testing.T) {
t.Parallel()
for appName, app := range sessionApps {
family := app.family
require.NotEmpty(t, family, "app %q has no family", appName)
require.NotEqual(t, AppFamilyUnknown, family,
"app %q must not register the unknown family", appName)
require.Equal(t, NormalizeAppName(string(family)), string(family),
"family %q must be normalized", family)
}
}