Unlimited services in the new APM plans! Monitor unlimited services with the new APM plans!

You are viewing documentation for an outdated version. Do you wish to see documentation for the latest version?

JDBC #

The bytecode instrumentation provided by the kamon-jdbc module hooks into the JDBC API to automatically start and finish segments for requests that are issued within a trace. This translates into you having metrics about how the requests you are doing are behaving.

Dependency Installation #


libraryDependencies += "io.kamon" %% "kamon-jdbc" % "1.0.2"



    <dependency>
      <groupId>io.kamon</groupId>
      <artifactId>kamon-jdbc_2.13</artifactId>
      <version>1.0.2</version>
    </dependency>


implementation 'io.kamon:kamon-jdbc_2.13:1.0.2'

You must start your application with the instrumentation agent for this module to work properly.

Metrics #

The following metrics will be recorded:

  • reads: a histogram that tracks the reads requests latency (SELECT statement).
  • writes: a histogram that tracks the writes requests latency (INSERT, UPDATE, and DELETE statements).
  • slows: a simple counter with the number of measured slow requests.
  • errors: a simple counter with the number of failures.

Naming Segments #

By default, the name generator bundled with the kamon-jdbc module will use the statement name as the name to the automatically generated segment (i.e SELECT, INSERT, etc). Currently, the only way to override that name would be to provide your own implementation of kamon.jdbc.JdbcNameGenerator which is used to assign the segment name

Slow Requests #

Requests that take longer to execute than the configured kamon.jdbc.slow-query-threshold can be processed by user-defined kamon.jdbc.DefaultSlowQueryProcessor. The default processor logs a warning message

Error Processor #

Requests that error can be processed by user-defined kamon.jdbc.SqlErrorProcessor. The default processor logs an error message

Configuration #

kamon {
  jdbc {
    slow-query-threshold = 2 seconds

    # Fully qualified name of the implementation of kamon.jdbc.SlowQueryProcessor.
    slow-query-processor = kamon.jdbc.DefaultSlowQueryProcessor

    # Fully qualified name of the implementation of kamon.jdbc.SqlErrorProcessor.
    sql-error-processor = kamon.jdbc.DefaultSqlErrorProcessor

    # Fully qualified name of the implementation of kamon.jdbc.JdbcNameGenerator that will be used for assigning names to segments.
    name-generator = kamon.jdbc.DefaultJdbcNameGenerator
  }
}