Skip to content

How to log latency for suspend function #1502

Answered by samuelAndalon
vgoyal200 asked this question in Q&A
Discussion options

You must be logged in to vote

Example

@Component
class LogInstrumentation : Instrumentation {
    override fun beginFieldFetch(
        parameters: InstrumentationFieldFetchParameters,
        state: InstrumentationState?
    ): InstrumentationContext<Any>? {
        val start = System.currentTimeMillis();
        println("begin field fetch ${parameters.field.name}")
        return object : InstrumentationContext<Any> 
            override fun onDispatched(result: CompletableFuture<Any>?) {
            }
            override fun onCompleted(result: Any?, t: Throwable?) {
                val finish = System.currentTimeMillis();
                println("completed field fetch ${parameters.field.name}")
                pr…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@vgoyal200
Comment options

@samuelAndalon
Comment options

Comment options

You must be logged in to vote
2 replies
@vgoyal200
Comment options

@samuelAndalon
Comment options

Answer selected by samuelAndalon
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants