Skip to content

Commit 36226d0

Browse files
authored
Merge pull request #1028 from SimunKaracic/1027-jedis-fix
Remove element matcher, replace with pattern match
2 parents 1a75ab2 + 641935c commit 36226d0

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
kanela.modules {
22
redis {
33
name = "Redis Instrumentation"
4-
# Does it provide metrics? No.
5-
description = "Provides tracing and metrics for the Jedis library"
4+
description = "Provides tracing for the Jedis library"
65

76
instrumentations = [
87
"kamon.instrumentation.jedis.JedisInstrumentation",
98
]
109

1110
within = [
12-
"redis.clients.jedis..*",
11+
"redis.clients.jedis.Protocol",
1312
]
1413
}
1514
}

instrumentation/kamon-redis/src/main/scala/kamon/instrumentation/jedis/JedisInstrumentation.scala

+9-8
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ import redis.clients.jedis.commands.ProtocolCommand
88

99
class JedisInstrumentation extends InstrumentationBuilder {
1010
onType("redis.clients.jedis.Protocol")
11-
.advise(method("sendCommand").and(withArgument(1, classOf[ProtocolCommand])), classOf[SendCommandAdvice])
11+
.advise(method("sendCommand"), classOf[SendCommandAdvice])
1212
}
1313

1414
class SendCommandAdvice
15-
1615
object SendCommandAdvice {
1716
@Advice.OnMethodEnter()
18-
def enter(@Advice.Argument(1) command: ProtocolCommand) = {
19-
val spanName = s"redis.command.${command}"
20-
val span = Kamon.clientSpanBuilder(spanName, "redis.client.jedis")
21-
.start()
22-
23-
span
17+
def enter(@Advice.Argument(1) command: Any) = {
18+
command match {
19+
case command: ProtocolCommand =>
20+
val spanName = s"redis.command.${command}"
21+
Kamon.clientSpanBuilder(spanName, "redis.client.jedis")
22+
.start()
23+
case _ => Span.Empty
24+
}
2425
}
2526

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

0 commit comments

Comments
 (0)