Skip to content

Commit 5b6b782

Browse files
committed
refactor: best guess transformer
1 parent 6f1de48 commit 5b6b782

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/kotlin/spp/protocol/artifact/metrics/MetricType.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ data class MetricType(val metricId: String) {
5959
Endpoint_RespTime_Percentiles,
6060
INSTANCE_JVM_CPU
6161
)
62+
63+
fun fromBestGuess(source: String): MetricType {
64+
val metricId = source.lowercase().replace(" ", "_")
65+
val metricType = ALL.firstOrNull { it.metricId == metricId }
66+
if (metricType != null) return metricType
67+
return MetricType(metricId)
68+
}
6269
}
6370

6471
constructor(jsonObject: JsonObject) : this(

0 commit comments

Comments
 (0)