| 1081 | } |
| 1082 | |
| 1083 | func (c *scrapeCache) setUnit(mfName, unit []byte) ([]byte, *metaEntry) { |
| 1084 | c.metaMtx.Lock() |
| 1085 | defer c.metaMtx.Unlock() |
| 1086 | |
| 1087 | e, ok := c.metadata[string(mfName)] |
| 1088 | if !ok { |
| 1089 | e = &metaEntry{Metadata: metadata.Metadata{Type: model.MetricTypeUnknown}} |
| 1090 | c.metadata[string(mfName)] = e |
| 1091 | } |
| 1092 | if e.Unit != string(unit) { |
| 1093 | e.Unit = string(unit) |
| 1094 | e.lastIterChange = c.iter |
| 1095 | } |
| 1096 | e.lastIter = c.iter |
| 1097 | return mfName, e |
| 1098 | } |
| 1099 | |
| 1100 | // GetMetadata returns metadata given the metric family name. |
| 1101 | func (c *scrapeCache) GetMetadata(mfName string) (MetricMetadata, bool) { |