mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
UsageStats: Expose what ds types should be reported (#35916)
This commit is contained in:
parent
ec45afa6b0
commit
d9e500b654
@ -28,6 +28,7 @@ func init() {
|
||||
type UsageStats interface {
|
||||
GetUsageReport(context.Context) (UsageReport, error)
|
||||
RegisterMetricsFunc(MetricsFunc)
|
||||
ShouldBeReported(string) bool
|
||||
}
|
||||
|
||||
type MetricsFunc func() (map[string]interface{}, error)
|
||||
|
@ -109,7 +109,7 @@ func (uss *UsageStatsService) GetUsageReport(ctx context.Context) (UsageReport,
|
||||
// as sending that name could be sensitive information
|
||||
dsOtherCount := 0
|
||||
for _, dsStat := range dsStats.Result {
|
||||
if uss.shouldBeReported(dsStat.Type) {
|
||||
if uss.ShouldBeReported(dsStat.Type) {
|
||||
metrics["stats.ds."+dsStat.Type+".count"] = dsStat.Count
|
||||
} else {
|
||||
dsOtherCount += dsStat.Count
|
||||
@ -152,7 +152,7 @@ func (uss *UsageStatsService) GetUsageReport(ctx context.Context) (UsageReport,
|
||||
|
||||
alertingOtherCount := 0
|
||||
for dsType, usageCount := range alertingUsageStats.DatasourceUsage {
|
||||
if uss.shouldBeReported(dsType) {
|
||||
if uss.ShouldBeReported(dsType) {
|
||||
addAlertingUsageStats(dsType, usageCount)
|
||||
} else {
|
||||
alertingOtherCount += usageCount
|
||||
@ -179,7 +179,7 @@ func (uss *UsageStatsService) GetUsageReport(ctx context.Context) (UsageReport,
|
||||
|
||||
access := strings.ToLower(dsAccessStat.Access)
|
||||
|
||||
if uss.shouldBeReported(dsAccessStat.Type) {
|
||||
if uss.ShouldBeReported(dsAccessStat.Type) {
|
||||
metrics["stats.ds_access."+dsAccessStat.Type+"."+access+".count"] = dsAccessStat.Count
|
||||
} else {
|
||||
old := dsAccessOtherCount[access]
|
||||
@ -336,7 +336,7 @@ func (uss *UsageStatsService) updateTotalStats() {
|
||||
}
|
||||
}
|
||||
|
||||
func (uss *UsageStatsService) shouldBeReported(dsType string) bool {
|
||||
func (uss *UsageStatsService) ShouldBeReported(dsType string) bool {
|
||||
ds := uss.PluginManager.GetDataSource(dsType)
|
||||
if ds == nil {
|
||||
return false
|
||||
|
@ -53,6 +53,10 @@ func (usm *usageStatsMock) GetUsageReport(_ context.Context) (usagestats.UsageRe
|
||||
return usagestats.UsageReport{Metrics: all}, nil
|
||||
}
|
||||
|
||||
func (usm *usageStatsMock) ShouldBeReported(_ string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type evaluatingPermissionsTestCase struct {
|
||||
desc string
|
||||
user userTestCase
|
||||
|
Loading…
Reference in New Issue
Block a user