Coverage Summary for Class: ServiceKt (dev.suresh.routes)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
ServiceKt |
0%
(0/4)
|
|
0%
(0/8)
|
0%
(0/93)
|
ServiceKt$mediaApiCall$1 |
|
ServiceKt$respondLogStream$2 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/27)
|
ServiceKt$services$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/31)
|
ServiceKt$services$1$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/22)
|
ServiceKt$services$2 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/31)
|
ServiceKt$services$2$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/22)
|
ServiceKt$services$3 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/31)
|
ServiceKt$services$3$1 |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/22)
|
ServiceKt$services$4 |
0%
(0/1)
|
|
0%
(0/2)
|
0%
(0/58)
|
Total |
0%
(0/12)
|
|
0%
(0/17)
|
0%
(0/337)
|
package dev.suresh.routes
import dev.suresh.JFR
import dev.suresh.http.MediaApiClient
import dev.suresh.lang.FFM
import dev.suresh.lang.VThread
import dev.suresh.log.RespLogger
import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.opentelemetry.instrumentation.annotations.WithSpan
import java.io.Writer
private val logger = KotlinLogging.logger {}
fun Routing.services() {
get("/ffm") { call.respondLogStream { FFM.memoryLayout() } }
get("/vthreads") { call.respondLogStream { VThread.virtualThreads() } }
get("/jfr") { call.respondLogStream { JFR.recordingStream() } }
get("/trace") {
call.respond(
mapOf("OpenTelemetry" to BuildConfig.otelInstr, "Image Size" to mediaApiCall().toString()))
}
}
@WithSpan suspend fun mediaApiCall() = MediaApiClient().images().size
suspend fun ApplicationCall.respondLogStream(
contentType: ContentType = ContentType.Text.EventStream,
block:
suspend context(KLogger)
Writer.() -> Unit
) {
respondTextWriter(contentType = contentType) { block(RespLogger(this, logger), this) }
}