Skip to content

Commit

Permalink
[performance-tests][metric-collector] provide a way to specify warmup…
Browse files Browse the repository at this point in the history
… openTelemetry span

warmup spans note collected to performance.json file, but still exist in openTelemetry.json

GitOrigin-RevId: 40e8d88bbd5ec76c33009402b42343f74dfc897d
  • Loading branch information
Litemn authored and intellij-monorepo-bot committed Aug 28, 2023
1 parent 83650ee commit 26e39a7
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun getSpansMetricsMap(file: File,
val spanToMetricMap = mutableMapOf<String, MutableList<MetricWithAttributes>>()
for (span in allSpans) {
val operationName = span.get("operationName").textValue()
if (spanFilter.filter(operationName)) {
if (spanFilter.filter(operationName) && !isWarmup(span)) {
val metric = MetricWithAttributes(Metric(Duration(operationName), getDuration(span)))
populateAttributes(metric, span)
spanToMetricMap.getOrPut(operationName) { mutableListOf() }.add(metric)
Expand All @@ -82,7 +82,9 @@ fun getDurationBetweenSpans(name: String, file: File, parentSpanName: String, fr
for (span in allSpans) {
val operationName = span.get("operationName").textValue()
if (operationName == parentSpanName) {
processChildrenSemantic(fromSpans, toSpans, allSpans, fromSpan, toSpan, span.get("spanID").textValue())
if (!isWarmup(allSpans)) {
processChildrenSemantic(fromSpans, toSpans, allSpans, fromSpan, toSpan, span.get("spanID").textValue())
}
}
}
val sortedFromSpans = fromSpans.sortedByDescending { info -> info.timeStamp }
Expand Down Expand Up @@ -111,7 +113,7 @@ fun processChildrenSemantic(fromSpans: MutableList<SpanInfo>, toSpans: MutableLi
span.get("references")?.forEach { reference ->
if (reference.get("refType")?.textValue() == "CHILD_OF") {
val spanId = reference.get("spanID").textValue()
if (spanId == parentSpanId) {
if (spanId == parentSpanId && !isWarmup(span)) {
val spanName = span.get("operationName").textValue()
if (spanName == toSpan) {
val value = getDuration(span)
Expand All @@ -131,6 +133,19 @@ fun processChildrenSemantic(fromSpans: MutableList<SpanInfo>, toSpans: MutableLi

}

private fun isWarmup(span: JsonNode) : Boolean {
val tagNode = span.get("tags")
if (tagNode == null) {
return false
}
val tags = tagNode.mapNotNull {
val key = it.get("key")?.textValue()
val value = it.get("value")?.textValue()
Pair(key, value)
}
return tags.find { it.first == "warmup" && it.second == "true" } != null
}

data class SpanInfo(val name: String, val duration: Long, val timeStamp: Long)

fun processSpans(
Expand Down Expand Up @@ -229,7 +244,7 @@ private fun processChildren(spanToMetricMap: MutableMap<String, MutableList<Metr
span.get("references")?.forEach { reference ->
if (reference.get("refType")?.textValue() == "CHILD_OF") {
val spanId = reference.get("spanID").textValue()
if (spanId == parentSpanId) {
if (spanId == parentSpanId && !isWarmup(span)) {
val spanName = span.get("operationName").textValue()
val value = getDuration(span)
if (value != 0L || !shouldAvoidIfZero(span)) {
Expand Down

0 comments on commit 26e39a7

Please sign in to comment.