Using DripStat API Annotations to measure custom code

Let’s say you have a block of code whose performance you want to measure in DripStat.

Example:

class HelloWorldResource {
  void testSegment() {
    // long running operation here...
  }
}

Since this is your custom application code, it is not instrumented natively by our agent.

Using DripStat API

You can use the DripStat API and add a couple of annotations and it will be visible in your DripStat dashboard. 

1 . First include the dependency to the dripstat-api.jar.
Example (for Gradle):

dependencies {
     compile 'com.dripstat:dripstat-api:2.0.1'
}

2 . Add the @TxnSegment annotations on the methods you want to track. Also add the @TxnSegmentContainer annotation on the classes containing these methods.

@TxnSegmentContainer
class HelloWorldResource { 

  @TxnSegment
  void testSegment() {
    // long running operation here...
  }  
}

3 . Run your application and you should see the segments inside DripStat!

Notes:

  • You can add values to the annotations to give your segments a friendlier name inside DripStat.
  • Make sure to use atleast DripStat agent version 5.1.9 to use these annotations.
  • DripStat API documentation
Show Comments