Skip to content

Commit

Permalink
Merge pull request #1028 from SimunKaracic/1027-jedis-fix
Browse files Browse the repository at this point in the history
Remove element matcher, replace with pattern match
  • Loading branch information
SimunKaracic committed May 28, 2021
2 parents 1a75ab2 + 641935c commit 36226d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions instrumentation/kamon-redis/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
kanela.modules {
redis {
name = "Redis Instrumentation"
# Does it provide metrics? No.
description = "Provides tracing and metrics for the Jedis library"
description = "Provides tracing for the Jedis library"

instrumentations = [
"kamon.instrumentation.jedis.JedisInstrumentation",
]

within = [
"redis.clients.jedis..*",
"redis.clients.jedis.Protocol",
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ import redis.clients.jedis.commands.ProtocolCommand

class JedisInstrumentation extends InstrumentationBuilder {
onType("redis.clients.jedis.Protocol")
.advise(method("sendCommand").and(withArgument(1, classOf[ProtocolCommand])), classOf[SendCommandAdvice])
.advise(method("sendCommand"), classOf[SendCommandAdvice])
}

class SendCommandAdvice

object SendCommandAdvice {
@Advice.OnMethodEnter()
def enter(@Advice.Argument(1) command: ProtocolCommand) = {
val spanName = s"redis.command.${command}"
val span = Kamon.clientSpanBuilder(spanName, "redis.client.jedis")
.start()

span
def enter(@Advice.Argument(1) command: Any) = {
command match {
case command: ProtocolCommand =>
val spanName = s"redis.command.${command}"
Kamon.clientSpanBuilder(spanName, "redis.client.jedis")
.start()
case _ => Span.Empty
}
}

@Advice.OnMethodExit(onThrowable = classOf[Throwable])
Expand Down

0 comments on commit 36226d0

Please sign in to comment.