-
Notifications
You must be signed in to change notification settings - Fork 41
NeuronCore mapping bug fix #341
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
Changes from 14 commits
c7fadf0
2c55bcb
9fa544a
11c141a
aaf7cb9
765c17f
ceeeaaf
f83b620
172d46b
d1a3432
72826d3
e2cd573
4511720
62781da
7485d61
9274724
13b3124
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,12 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| statusType = "status_type" | ||
| errorType = "error_type" | ||
| memoryLocation = "memory_location" | ||
| percentile = "percentile" | ||
| RuntimeTagOverride = "DEFAULT" | ||
| statusType = "status_type" | ||
| errorType = "error_type" | ||
| memoryLocation = "memory_location" | ||
| percentile = "percentile" | ||
| RuntimeTagOverride = "DEFAULT" | ||
| DefaultNeuronCorePerDevice = 2 | ||
| ) | ||
|
|
||
| var attributeConfig = map[string][]string{ | ||
|
|
@@ -66,6 +67,13 @@ func (ed *EmptyMetricDecorator) ConsumeMetrics(ctx context.Context, md pmetric.M | |
| neuronHardwareInfo, neuronHardwareInfoFound := findNeuronHardwareInfo(metrics) | ||
| if neuronHardwareInfoFound { | ||
| ed.addEmptyMetrics(neuronHardwareInfo, metrics) | ||
| neuronCoresPerDevice, foundCoresPerDevice := getNeuronCoresPerDevice(neuronHardwareInfo) | ||
| if foundCoresPerDevice { | ||
| ed.addNeuronCorePerDeviceAttribute(metrics, neuronCoresPerDevice) | ||
| } else { | ||
| // Always add the Default if the above is not found, should never happen | ||
| ed.addNeuronCorePerDeviceAttribute(metrics, DefaultNeuronCorePerDevice) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -129,7 +137,6 @@ func populateCoreMetrics(metrics pmetric.MetricSlice, metricName string, hardwar | |
| datapoint.Attributes().PutStr(neuronCoreOriginalAttributeKey, strconv.Itoa(coreIndex)) | ||
| datapoint.Attributes().PutStr(neuronDeviceAttributeKey, strconv.Itoa(coreIndex/neuronCoresPerDevice)) | ||
| datapoint.Attributes().PutStr("runtime_tag", RuntimeTagOverride) | ||
| datapoint.Attributes().PutStr("runtime_tag", RuntimeTagOverride) | ||
| } | ||
|
|
||
| metricToAdd.CopyTo(metrics.AppendEmpty()) | ||
|
|
@@ -159,7 +166,38 @@ func createNewMetricFromHardwareInfo(hardwareInfo pmetric.Metric, metricName str | |
| metricBody := metricToAdd.Gauge().DataPoints().At(0) | ||
| metricBody.SetDoubleValue(0) | ||
| metricBody.Attributes().PutStr("runtime_tag", RuntimeTagOverride) | ||
| metricBody.Attributes().PutStr("runtime_tag", RuntimeTagOverride) | ||
|
|
||
| return metricToAdd | ||
| } | ||
|
|
||
| // method to add neuroncore_per_device_count attribute to all metrics | ||
| func (ed *EmptyMetricDecorator) addNeuronCorePerDeviceAttribute(metrics pmetric.MetricSlice, neuronCoresPerDevice int) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this have to be a datapoint attribute? Cant it be a resource attr?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We chose to do it like this because we don't have access to the resource later on. But this would be a good idea for future refactoring. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its the same pmetric getting passed to the processor right? I dont get why it wont be available later on.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do, thank you for pointing this out |
||
| attributeValue := strconv.Itoa(neuronCoresPerDevice) | ||
| for i := 0; i < metrics.Len(); i++ { | ||
| m := metrics.At(i) | ||
| switch m.Type() { | ||
| case pmetric.MetricTypeGauge: | ||
| ed.addAttributeToNumberDataPoints(m.Gauge().DataPoints(), attributeValue) | ||
| case pmetric.MetricTypeSum: | ||
| ed.addAttributeToNumberDataPoints(m.Sum().DataPoints(), attributeValue) | ||
| case pmetric.MetricTypeHistogram: | ||
| dataPoints := m.Histogram().DataPoints() | ||
| for j := 0; j < dataPoints.Len(); j++ { | ||
| dataPoints.At(j).Attributes().PutStr(neuronCorePerDeviceKey, attributeValue) | ||
| } | ||
| case pmetric.MetricTypeSummary: | ||
| dataPoints := m.Summary().DataPoints() | ||
| for j := 0; j < dataPoints.Len(); j++ { | ||
| dataPoints.At(j).Attributes().PutStr(neuronCorePerDeviceKey, attributeValue) | ||
| } | ||
| default: | ||
| ed.Logger.Info("Metric type not supported", zap.String("metricType", m.Type().String())) | ||
|
petruanica marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| func (ed *EmptyMetricDecorator) addAttributeToNumberDataPoints(dataPoints pmetric.NumberDataPointSlice, attributeValue string) { | ||
| for j := 0; j < dataPoints.Len(); j++ { | ||
| dataPoints.At(j).Attributes().PutStr(neuronCorePerDeviceKey, attributeValue) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit for better readability