diff options
Diffstat (limited to 'kamon-jdbc/src')
-rw-r--r-- | kamon-jdbc/src/main/scala/kamon/jdbc/instrumentation/StatementInstrumentation.scala | 4 | ||||
-rw-r--r-- | kamon-jdbc/src/test/scala/kamon/jdbc/instrumentation/StatementInstrumentationSpec.scala | 26 |
2 files changed, 15 insertions, 15 deletions
diff --git a/kamon-jdbc/src/main/scala/kamon/jdbc/instrumentation/StatementInstrumentation.scala b/kamon-jdbc/src/main/scala/kamon/jdbc/instrumentation/StatementInstrumentation.scala index d169a4c7..aa9295db 100644 --- a/kamon-jdbc/src/main/scala/kamon/jdbc/instrumentation/StatementInstrumentation.scala +++ b/kamon-jdbc/src/main/scala/kamon/jdbc/instrumentation/StatementInstrumentation.scala @@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit.{ NANOSECONDS ⇒ nanos } import kamon.Kamon import kamon.jdbc.{ JdbcExtension, Jdbc } import kamon.jdbc.metric.StatementsMetrics -import kamon.trace.{ TraceContext, SegmentCategory } +import kamon.trace.{ Tracer, TraceContext, SegmentCategory } import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut } import org.slf4j.LoggerFactory @@ -43,7 +43,7 @@ class StatementInstrumentation { @Around("onExecuteStatement(sql) || onExecutePreparedStatement(sql) || onExecutePreparedCall(sql)") def aroundExecuteStatement(pjp: ProceedingJoinPoint, sql: String): Any = { - TraceContext.map { ctx ⇒ + Tracer.currentContext.collect { ctx ⇒ val metricsExtension = Kamon.metrics val jdbcExtension = Kamon(Jdbc) implicit val statementRecorder = metricsExtension.register(StatementsMetrics, "jdbc-statements").map(_.recorder) diff --git a/kamon-jdbc/src/test/scala/kamon/jdbc/instrumentation/StatementInstrumentationSpec.scala b/kamon-jdbc/src/test/scala/kamon/jdbc/instrumentation/StatementInstrumentationSpec.scala index e150d967..8ad5faa8 100644 --- a/kamon-jdbc/src/test/scala/kamon/jdbc/instrumentation/StatementInstrumentationSpec.scala +++ b/kamon-jdbc/src/test/scala/kamon/jdbc/instrumentation/StatementInstrumentationSpec.scala @@ -21,7 +21,7 @@ import com.typesafe.config.ConfigFactory import kamon.jdbc.{ Jdbc, JdbcNameGenerator, SqlErrorProcessor, SlowQueryProcessor } import kamon.metric.TraceMetricsSpec import kamon.testkit.BaseKamonSpec -import kamon.trace.{ SegmentCategory, TraceContext } +import kamon.trace.{ Tracer, SegmentCategory } class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { import TraceMetricsSpec.SegmentSyntax @@ -61,14 +61,14 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { "the StatementInstrumentation" should { "record the execution time of INSERT operation" in { - TraceContext.withContext(newContext("jdbc-trace-insert")) { + Tracer.withContext(newContext("jdbc-trace-insert")) { for (id ← 1 to 100) { val insert = s"INSERT INTO Address (Nr, Name) VALUES($id, 'foo')" val insertStatement = connection.prepareStatement(insert) insertStatement.execute() } - TraceContext.currentContext.finish() + Tracer.currentContext.finish() } val jdbcSnapshot = takeSnapshotOf("jdbc-statements", "jdbc-statements") @@ -81,14 +81,14 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { } "record the execution time of SELECT operation" in { - TraceContext.withContext(newContext("jdbc-trace-select")) { + Tracer.withContext(newContext("jdbc-trace-select")) { for (id ← 1 to 100) { val select = s"SELECT * FROM Address where Nr = $id" val selectStatement = connection.createStatement() selectStatement.execute(select) } - TraceContext.currentContext.finish() + Tracer.currentContext.finish() } val jdbcSnapshot = takeSnapshotOf("jdbc-statements", "jdbc-statements") @@ -101,14 +101,14 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { } "record the execution time of UPDATE operation" in { - TraceContext.withContext(newContext("jdbc-trace-update")) { + Tracer.withContext(newContext("jdbc-trace-update")) { for (id ← 1 to 100) { val update = s"UPDATE Address SET Name = 'bar$id' where Nr = $id" val updateStatement = connection.prepareStatement(update) updateStatement.execute() } - TraceContext.currentContext.finish() + Tracer.currentContext.finish() } val jdbcSnapshot = takeSnapshotOf("jdbc-statements", "jdbc-statements") @@ -121,14 +121,14 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { } "record the execution time of DELETE operation" in { - TraceContext.withContext(newContext("jdbc-trace-delete")) { + Tracer.withContext(newContext("jdbc-trace-delete")) { for (id ← 1 to 100) { val delete = s"DELETE FROM Address where Nr = $id" val deleteStatement = connection.createStatement() deleteStatement.execute(delete) } - TraceContext.currentContext.finish() + Tracer.currentContext.finish() } val jdbcSnapshot = takeSnapshotOf("jdbc-statements", "jdbc-statements") @@ -142,14 +142,14 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { } "record the execution time of SLOW QUERIES based on the kamon.jdbc.slow-query-threshold" in { - TraceContext.withContext(newContext("jdbc-trace-slow")) { + Tracer.withContext(newContext("jdbc-trace-slow")) { for (id ← 1 to 2) { val select = s"SELECT * FROM Address; CALL SLEEP(100)" val selectStatement = connection.createStatement() selectStatement.execute(select) } - TraceContext.currentContext.finish() + Tracer.currentContext.finish() } val jdbcSnapshot = takeSnapshotOf("jdbc-statements", "jdbc-statements") @@ -158,7 +158,7 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { } "count all SQL ERRORS" in { - TraceContext.withContext(newContext("jdbc-trace-errors")) { + Tracer.withContext(newContext("jdbc-trace-errors")) { for (_ ← 1 to 10) { intercept[SQLException] { val error = "SELECT * FROM NO_EXISTENT_TABLE" @@ -167,7 +167,7 @@ class StatementInstrumentationSpec extends BaseKamonSpec("jdbc-spec") { } } - TraceContext.currentContext.finish() + Tracer.currentContext.finish() } val jdbcSnapshot = takeSnapshotOf("jdbc-statements", "jdbc-statements") |