feat: sso stats reporting (#10062)

This commit is contained in:
Karan Balani
2026-01-21 00:27:35 +05:30
committed by GitHub
parent 865a7a5a31
commit ea15ce4e04
3 changed files with 26 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -415,6 +415,7 @@ func New(
licensing,
tokenizer,
config,
modules.AuthDomain,
}
// Initialize stats reporter from the available stats reporter provider factories