diff --git a/pkg/telemetry/telemetry.go b/pkg/telemetry/telemetry.go index 4984df42db5..14cf57627fc 100644 --- a/pkg/telemetry/telemetry.go +++ b/pkg/telemetry/telemetry.go @@ -10,11 +10,13 @@ import ( "os" "runtime" "runtime/debug" + "strconv" "sync" "time" "github.com/microsoft/ApplicationInsights-Go/appinsights" "github.com/microsoft/ApplicationInsights-Go/appinsights/contracts" + "github.com/microsoft/retina/pkg/exporter" "github.com/microsoft/retina/pkg/log" ) @@ -174,6 +176,17 @@ func (t *TelemetryClient) heartbeat(ctx context.Context) { if err != nil { t.trackWarning(err, "failed to get cpu usage") } + + metricFamilies, err := exporter.CombinedGatherer.Gather() + if err != nil { + t.trackWarning(err, "failed to get metrics cardinality") + } + metricscardinality := 0 + for _, mf := range metricFamilies { + metricscardinality += len(mf.GetMetric()) + } + props["metricscardinality"] = strconv.Itoa(metricscardinality) + maps.Copy(props, cpuProps) maps.Copy(props, t.profile.GetMemoryUsage()) t.TrackEvent("heartbeat", props)