Skip to content

Commit b797230

Browse files
authored
fix(server): move registering artifact metrics to after call response (#1828)
As commented in #1824 (comment), the status metrics is not obtained because we try to get it before the call happens. This commit adjusts that by placing the metric increment to be after the call is processed.
1 parent bb6baf8 commit b797230

File tree

1 file changed

+4
-4
lines changed
  • jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver

1 file changed

+4
-4
lines changed

jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ private fun Route.headArtifact(
5656

5757
val file = call.parameters["file"] ?: return@head call.respondNotFound()
5858

59-
incrementArtifactCounter(prometheusRegistry, call)
60-
6159
if (file in bindingArtifacts) {
6260
call.respondText("Exists", status = HttpStatusCode.OK)
6361
} else {
6462
call.respondNotFound()
6563
}
64+
65+
incrementArtifactCounter(prometheusRegistry, call)
6666
}
6767
}
6868

@@ -77,14 +77,14 @@ private fun Route.getArtifact(
7777

7878
val file = call.parameters["file"] ?: return@get call.respondNotFound()
7979

80-
incrementArtifactCounter(prometheusRegistry, call)
81-
8280
val artifact = bindingArtifacts[file] ?: return@get call.respondNotFound()
8381

8482
when (artifact) {
8583
is TextArtifact -> call.respondText(artifact.data())
8684
is JarArtifact -> call.respondBytes(artifact.data(), ContentType.parse("application/java-archive"))
8785
}
86+
87+
incrementArtifactCounter(prometheusRegistry, call)
8888
}
8989
}
9090

0 commit comments

Comments
 (0)