New Relic Kotlin Instrumentation for Kotlin Coroutine. It successfully handles thread changes in suspend states.

Overview

new-relic-kotlin-coroutine

New Relic Kotlin Instrumentation for Kotlin Coroutine. It successfully handles thread changes in suspend states.

Usage

1- Update the context of your coroutine by using new relic coroutine context elements

suspend fun <T> withMdcContext(
    block: suspend CoroutineScope.() -> T,
): T {
    val txn = NewRelic.getAgent().transaction
    val token = txn.token
    return withContext(
        MDCContext() + NewRelicTransaction(txn) + NewRelicToken(token),
    ) {
        return@withContext try {
            block.invoke(this)
        } finally {
            token.expire()
        }
    }
}

@Trace(dispatcher = true)
suspend fun testEndpoint() = withMdcContext {
    ...
}

2- Add segment to trace specific block of the code

override suspend fun findAll(): List<Any> =
        withNewRelicSegment("findAll", "Couchbase", "yourDb") {
            val query =
                "SELECT * FROM yourDb"
            ...
        }
You might also like...
Demonstration of Object Pool Design Pattern using Kotlin language and Coroutine
Demonstration of Object Pool Design Pattern using Kotlin language and Coroutine

Object Pool Design Pattern with Kotlin Demonstration of Thread Safe Object Pool Design Pattern using Kotlin language and Coroutine. Abstract The objec

🚀 🥳 MVVM based sample currency converter application using Room, Koin, ViewModel, LiveData, Coroutine
🚀 🥳 MVVM based sample currency converter application using Room, Koin, ViewModel, LiveData, Coroutine

Currency Converter A demo currency converter app using Modern Android App Development techniques Tech stack & Open-source libraries Minimum SDK level

MVVM ,Hilt DI ,LiveData ,Flow ,SharedFlow ,Room ,Retrofit ,Coroutine , Navigation Component ,DataStore ,DataBinding , ViewBinding, Coil
MVVM ,Hilt DI ,LiveData ,Flow ,SharedFlow ,Room ,Retrofit ,Coroutine , Navigation Component ,DataStore ,DataBinding , ViewBinding, Coil

RickMorty This is a simple app which has been implemented using Clean Architecture alongside MVVM design to run (online/offline) using : [ MVVM ,Hilt

Kotlin Tutorials for new learners.

Kotlin Programming Tutorial for Beginners Learn Kotlin Programming, its basics and Fundamentals from scratch. Topics to be covered Overview Course int

HelloKMM - Hello World in Kotlin Multiplatform Mobile (new empty project)
HelloKMM - Hello World in Kotlin Multiplatform Mobile (new empty project)

Hello KMM! Hello World in Kotlin Multiplatform Mobile (new empty project) Gettin

New style for app design Online Sunglasses Shop App UI made in Jetpack Compose.😉😎
New style for app design Online Sunglasses Shop App UI made in Jetpack Compose.😉😎

JetSunglassUI-Android New style for app design Online Sunglasses Shop App UI made in Jetpack Compose. 😉 😎 (Navigation Components, Dagger-Hilt, Mater

This is our new version of chatkit

ChatKitV4 (This read me is under develop) This is our new version of chatkit. Here we seprate Core Logic and UI sections. You can use it as seprate mo

CodeLab for the workshop: A Composable New World
CodeLab for the workshop: A Composable New World

A Composable New World! Compose is here! 🙌 I've created a codelab where you can follow step by step the development of android application using Comp

A sandbox where I will experiment with new techniques, concepts, and technologies.
A sandbox where I will experiment with new techniques, concepts, and technologies.

A sandbox where I will experiment with new techniques, concepts, and technologies. Here you will find some DDD, CQRS, Clean Architecture, Event-Driven Architecture, Serverless, Microservices, RabbitMQ, gRPC, SOLID, Design Patterns, and more.

Owner
Mehmet Sezer
Focusing on design distributed, scalable, available, fault-tolerant, consistent, clean architecture(CQRS, TDD, DDD, Hexagonal, Onion) microservice systems.
Mehmet Sezer
Multi-thread ZX0 data compressor in Kotlin

ZX0-Kotlin ZX0-Kotlin is a multi-thread implementation of the ZX0 data compressor in Kotlin. Requirements To run this compressor, you must have instal

Einar Saukas 2 Apr 14, 2022
Kafka bindings for Kotlin `suspend`, and Kafka streaming operators for KotlinX Flow.

Module kotlin-kafka Rationale Goals Example This project is still under development, andd started as a playground where I was playing around with Kafk

Simon Vergauwen 34 Dec 30, 2022
Kotlin compiler plugin for converting suspend functions to platform-compatible functions

Kotlin suspend transform compiler plugin Summary Kotlin compiler plugin for generating platform-compatible functions for suspend functions. JVM class

ForteScarlet 5 Oct 12, 2022
🧙 Sharding backend infrastructure for Nino v2, handles as a sharding operator for Nino.

shibe ?? Sharding backend infrastructure for Nino v2, handles as a sharding operator for Nino. Why? I feel like this was needed because I wanted to ke

Nino 3 Aug 9, 2021
This library handles conversion between Request Params and JPA Specification.

Spring Jpa Magic Filter This library handles conversion between spring rest Request Params and JPA Specification. It can be considered a simpler alter

Verissimo Joao Ribeiro 4 Jan 12, 2022
A fork of CloudStream-3, with additional features and changes

CloudStream-3XXX A fork of CloudStream-3, with additional features and changes. Features All features of CloudStream 3, corresponding to this commit h

Jace 137 Jan 9, 2023
ViewModel-Lifecycle - ViewModel Lifecycle allows you to track and observe Jetpack ViewModel's lifecycle changes

ViewModel Lifecycle ?? ViewModel Lifecycle allows you to track and observe Jetpa

Jaewoong Eum 97 Nov 25, 2022
Viewmodel-lifecycle - ViewModel Lifecycle allows you to track and observe Jetpack ViewModel's lifecycle changes

ViewModel Lifecycle ?? ViewModel Lifecycle allows you to track and observe Jetpa

Jaewoong Eum 36 Feb 6, 2022
Android Multi Theme Switch Library ,use kotlin language ,coroutine ,and so on ...

Magic Mistletoe Android多主题(换肤)切换框架 背景 时隔四年,在网易换肤之前的思路下,做了几点改进,现在完全通过反射创建View,并且在SkinLoadManager中提供一个configCustomAttrs以支持自定义View的属性插队替换 摈弃了之前的AsyncTask

Mistletoe 18 Jun 17, 2022
R2DBC Sharding Example with Kotlin Coroutine

R2DBC Sharding Example with Kotlin Coroutine A minimal sharding example with R2DBC and coroutine, where user table is divided into 2 different shards.

K.S. Yim 0 Oct 4, 2021