Skip to content
share library_books


Tracing Scala Apps

Sematext application and infrastructure monitoring platform lets you trace transactions for Scala apps. In order to define custom pointcuts for a Scala app you need to follow the convention Scala uses to generate JVM classes. Below you can find a simple example that covers all basic cases:

trait UserService {
  def getUsers(): List[String]
class UserServiceImpl extends UserService {
  def getUsers(): List[String] =
sealed trait Type {
  def typeName: String
case object Original extends Type {
  val typeName: String = "original"
case object Retweet extends Type  {
  val typeName: String = "retweet"
case class Tweet(text: String, t: Type = Original) {
  def vowelsCount: Int = {
class TweetService {
  def getTweets(user: String): List[Tweet] =
    Tweet("What a lovely day!")::Nil
object StatisticsService extends App {
  val userService = new UserServiceImpl
  val tweetService = new TweetService
  def vowelsCount(): Int = {
    val count = for {
      user <- userService.getUsers()
      tweet <- tweetService.getTweets(user) if tweet.t.typeName == "original"
    } yield tweet.vowelsCount
  def serve(): Unit = {

Custom pointcuts definition:

<instrumentation-descriptor name="scala">
    <pointcut name="foo" entry-point="true">
      <method signature="int StatisticsService$#vowelsCount()"/>
    <pointcut name="userService">
      <method signature="scala.collection.immutable.List UserService#getUsers()"/>
    <pointcut name="tweetService">
      <method signature="scala.collection.immutable.List TweetService#getTweets(java.lang.String users)"/>
    <pointcut name="type">
      <method signature="java.lang.String Original$#typeName()"/>
      <method signature="java.lang.String Retweet$#typeName()"/>