Skip to content

BugFix: Add perCore neuron empty metric as datapoints instead of individual metric object #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
)

const (
statusType = "status_type"
errorType = "error_type"
memoryLocation = "memory_location"
percentile = "percentile"
statusType = "status_type"
errorType = "error_type"
memoryLocation = "memory_location"
percentile = "percentile"
RuntimeTagOverride = "DEFAULT"
)

var attributeConfig = map[string][]string{
Expand Down Expand Up @@ -116,14 +117,21 @@ func populateCoreMetrics(metrics pmetric.MetricSlice, metricName string, hardwar
return
}

metricToAdd := pmetric.NewMetric()
metricToAdd.SetEmptyGauge()
metricToAdd.SetName(metricName)
emptyDatapoints := metricToAdd.Gauge().DataPoints()
for coreIndex := 0; coreIndex < neuronCoresPerDevice*neuronDeviceCount; coreIndex++ {
metricToAdd := createNewMetricFromHardwareInfo(hardwareInfo, metricName)
metricBody := metricToAdd.Gauge().DataPoints().At(0)

metricBody.Attributes().PutStr(neuronCoreAttributeKey, strconv.Itoa(coreIndex))
metricBody.Attributes().PutStr(neuronDeviceAttributeKey, strconv.Itoa(coreIndex/neuronCoresPerDevice))
metricToAdd.CopyTo(metrics.AppendEmpty())
datapoint := emptyDatapoints.AppendEmpty()
hardwareInfo.Sum().DataPoints().At(0).CopyTo(datapoint)
datapoint.SetDoubleValue(0)
datapoint.Attributes().PutStr(neuronCoreAttributeKey, strconv.Itoa(coreIndex))
datapoint.Attributes().PutStr(neuronCoreOriginalAttributeKey, strconv.Itoa(coreIndex))
datapoint.Attributes().PutStr(neuronDeviceAttributeKey, strconv.Itoa(coreIndex/neuronCoresPerDevice))
datapoint.Attributes().PutStr("runtime_tag", RuntimeTagOverride)
}

metricToAdd.CopyTo(metrics.AppendEmpty())
}

// returns the device count for neuron from the hardwareInfo metric
Expand All @@ -149,7 +157,7 @@ func createNewMetricFromHardwareInfo(hardwareInfo pmetric.Metric, metricName str
metricToAdd.SetName(metricName)
metricBody := metricToAdd.Gauge().DataPoints().At(0)
metricBody.SetDoubleValue(0)
metricBody.Attributes().PutStr("runtime_tag", "default")
metricBody.Attributes().PutStr("runtime_tag", RuntimeTagOverride)

return metricToAdd
}
Loading
Loading