diff --git a/pkg/modules/authdomain/authdomain.go b/pkg/modules/authdomain/authdomain.go index 1cf2af9c4f..0905c3419e 100644 --- a/pkg/modules/authdomain/authdomain.go +++ b/pkg/modules/authdomain/authdomain.go @@ -4,6 +4,7 @@ import ( "context" "net/http" + "github.com/SigNoz/signoz/pkg/statsreporter" "github.com/SigNoz/signoz/pkg/types/authtypes" "github.com/SigNoz/signoz/pkg/valuer" ) @@ -32,6 +33,8 @@ type Module interface { // Get the IDP info of the domain provided. GetAuthNProviderInfo(context.Context, *authtypes.AuthDomain) *authtypes.AuthNProviderInfo + + statsreporter.StatsCollector } type Handler interface { diff --git a/pkg/modules/authdomain/implauthdomain/module.go b/pkg/modules/authdomain/implauthdomain/module.go index 08d2486670..c0953b4e71 100644 --- a/pkg/modules/authdomain/implauthdomain/module.go +++ b/pkg/modules/authdomain/implauthdomain/module.go @@ -52,3 +52,25 @@ func (module *module) ListByOrgID(ctx context.Context, orgID valuer.UUID) ([]*au func (module *module) Update(ctx context.Context, domain *authtypes.AuthDomain) error { return module.store.Update(ctx, domain) } + +func (module *module) Collect(ctx context.Context, orgID valuer.UUID) (map[string]any, error) { + domains, err := module.store.ListByOrgID(ctx, orgID) + if err != nil { + return nil, err + } + + stats := make(map[string]any) + + for _, domain := range domains { + key := "authdomain." + domain.AuthDomainConfig().AuthNProvider.StringValue() + ".count" + if value, ok := stats[key]; ok { + stats[key] = value.(int64) + 1 + } else { + stats[key] = int64(1) + } + } + + stats["authdomain.count"] = len(domains) + + return stats, nil +} diff --git a/pkg/signoz/signoz.go b/pkg/signoz/signoz.go index 113f29e236..b1badcfa2b 100644 --- a/pkg/signoz/signoz.go +++ b/pkg/signoz/signoz.go @@ -415,6 +415,7 @@ func New( licensing, tokenizer, config, + modules.AuthDomain, } // Initialize stats reporter from the available stats reporter provider factories