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 16, 2025
1 parent 2bdd493 commit 4efa73e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"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 +175,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.Metric)

Check failure on line 185 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (linux, amd64)

avoid direct access to proto field mf.Metric, use mf.GetMetric() instead (protogetter)

Check failure on line 185 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (linux, arm64)

avoid direct access to proto field mf.Metric, use mf.GetMetric() instead (protogetter)

Check failure on line 185 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (windows, amd64)

avoid direct access to proto field mf.Metric, use mf.GetMetric() instead (protogetter)

Check failure on line 185 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (windows, arm64)

avoid direct access to proto field mf.Metric, use mf.GetMetric() instead (protogetter)
}
props["metricscardinality"] = fmt.Sprintf("%d", metricscardinality)

Check failure on line 187 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (linux, amd64)

fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)

Check failure on line 187 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (linux, arm64)

fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)

Check failure on line 187 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (windows, amd64)

fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)

Check failure on line 187 in pkg/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / Lint (windows, arm64)

fmt.Sprintf can be replaced with faster strconv.Itoa (perfsprint)

maps.Copy(props, cpuProps)
maps.Copy(props, t.profile.GetMemoryUsage())
t.TrackEvent("heartbeat", props)
Expand Down

0 comments on commit 4efa73e

Please sign in to comment.