Skip to content

Commit

Permalink
feat: add metricscardinality to heartbeat
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Castilio dos Santos <[email protected]>
  • Loading branch information
alexcastilio committed Jan 17, 2025
1 parent 2bdd493 commit b0beff5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b0beff5

Please sign in to comment.