From b0beff5c10f7e0d386bb9f6644472466f2247301 Mon Sep 17 00:00:00 2001 From: Alex Castilio dos Santos Date: Thu, 16 Jan 2025 12:20:46 +0000 Subject: [PATCH] feat: add metricscardinality to heartbeat Signed-off-by: Alex Castilio dos Santos --- pkg/telemetry/telemetry.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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)