Skip to content

Commit

Permalink
Deprecate runtime tag (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam6134 authored Aug 8, 2024
1 parent 3276b6b commit bcecbc1
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
Kubernetes = "kubernetes"
Region = "region"
SubnetId = "subnet_id"
RuntimeTagOverride = "DEFAULT"
NeuronExecutionErrorsAggregatedMetric = containerinsightscommon.NeuronExecutionErrors + "_total"
NeuronDeviceHardwareEccEventsAggregatedMetric = containerinsightscommon.NeuronDeviceHardwareEccEvents + "_total"
)
Expand Down Expand Up @@ -121,7 +122,7 @@ func (md *AwsNeuronMetricModifier) ModifyMetric(originalMetric pmetric.Metric, m
}
// Neuron metrics sent by the neuron monitor don't have any units so we add them in the agent.
addUnit(originalMetric)
prefixCoreAndDeviceLabels(originalMetric)
updateCoreDeviceRuntimeLabels(originalMetric)
resetStaleDatapoints(originalMetric)

originalMetricName := originalMetric.Name()
Expand Down Expand Up @@ -248,7 +249,7 @@ func (md *AwsNeuronMetricModifier) extractDatapointsAsMetricsAndAggregate(origin

// This method prefixes NeuronCore and NeuronDevice values with `core` and `device` respectively
// to make the attribute values more verbose
func prefixCoreAndDeviceLabels(originalMetric pmetric.Metric) {
func updateCoreDeviceRuntimeLabels(originalMetric pmetric.Metric) {
dps := originalMetric.Sum().DataPoints()
for i := 0; i < dps.Len(); i++ {
dp := dps.At(i)
Expand All @@ -257,6 +258,7 @@ func prefixCoreAndDeviceLabels(originalMetric pmetric.Metric) {
dp.Attributes().PutStr(attributeKey, attributeValuePrefix+value.Str())
}
}
dp.Attributes().PutStr(RuntimeTag, RuntimeTagOverride)
}
}

Expand Down Expand Up @@ -313,7 +315,7 @@ func resetStaleDatapoints(originalMetric pmetric.Metric) {
dp := dps.At(i)
if dp.ValueType() == pmetric.NumberDataPointValueTypeEmpty || dp.Flags().NoRecordedValue() {
dp.SetDoubleValue(dp.DoubleValue())
dp.Attributes().PutStr(RuntimeTag, "default")
dp.Attributes().PutStr(RuntimeTag, RuntimeTagOverride)
dp.SetFlags(dp.Flags().WithNoRecordedValue(false))
}
}
Expand Down
Loading

0 comments on commit bcecbc1

Please sign in to comment.