forked from woggioni/rbcs
Generalize OTEL API and add memcache tracing support
- Rename RedisSpan -> SpanHandle for generic span handling - Generalize TelemetryController methods: startSpan/endSpan with dbSystem param - Rename RedisOtelSpan -> OtelSpanHandle in rbcs-server-otel - Update Redis cache handler to use new generic API - Add OpenTelemetry tracing for memcache GET and SET commands - Add channel property to MemcacheRequestController for server address attribution - Add uses TelemetryController directive in memcache module-info Memcache spans follow the same pattern as Redis: db.system=memcache, db.operation=GET|SET, server.address, server.port
This commit is contained in:
+10
-10
@@ -38,7 +38,7 @@ import net.woggioni.rbcs.api.message.CacheMessage.CachePutResponse
|
||||
import net.woggioni.rbcs.api.message.CacheMessage.CacheValueFoundResponse
|
||||
import net.woggioni.rbcs.api.message.CacheMessage.CacheValueNotFoundResponse
|
||||
import net.woggioni.rbcs.api.message.CacheMessage.LastCacheContent
|
||||
import net.woggioni.rbcs.api.RedisSpan
|
||||
import net.woggioni.rbcs.api.SpanHandle
|
||||
import net.woggioni.rbcs.api.TelemetryController
|
||||
import net.woggioni.rbcs.common.ByteBufInputStream
|
||||
import net.woggioni.rbcs.common.ByteBufOutputStream
|
||||
@@ -252,7 +252,7 @@ class RedisCacheHandler(
|
||||
}
|
||||
val keyBytes = processCacheKey(msg.key, keyPrefix, digestAlgorithm)
|
||||
val keyString = String(keyBytes, StandardCharsets.UTF_8)
|
||||
val redisSpan = telemetryController?.startRedisSpan("GET", keyString)
|
||||
val redisSpan = telemetryController?.startSpan("GET", keyString, "redis")
|
||||
val responseHandler = object : RedisResponseHandler {
|
||||
override fun responseReceived(response: RedisMessage) {
|
||||
try {
|
||||
@@ -276,7 +276,7 @@ class RedisCacheHandler(
|
||||
|
||||
is ErrorRedisMessage -> {
|
||||
val ex = RedisException("Redis error for GET ${msg.key}: ${response.content()}")
|
||||
telemetryController?.endRedisSpan(redisSpan, ex)
|
||||
telemetryController?.endSpan(redisSpan, ex)
|
||||
this@RedisCacheHandler.exceptionCaught(ctx, ex)
|
||||
}
|
||||
|
||||
@@ -288,12 +288,12 @@ class RedisCacheHandler(
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
telemetryController?.endRedisSpan(redisSpan)
|
||||
telemetryController?.endSpan(redisSpan)
|
||||
}
|
||||
}
|
||||
|
||||
override fun exceptionCaught(ex: Throwable) {
|
||||
telemetryController?.endRedisSpan(redisSpan, ex)
|
||||
telemetryController?.endSpan(redisSpan, ex)
|
||||
this@RedisCacheHandler.exceptionCaught(ctx, ex)
|
||||
}
|
||||
}
|
||||
@@ -363,7 +363,7 @@ class RedisCacheHandler(
|
||||
|
||||
val expirySeconds = maxAge.toSeconds().toString()
|
||||
|
||||
val redisSpan = telemetryController?.startRedisSpan("SET", request.keyString)
|
||||
val redisSpan = telemetryController?.startSpan("SET", request.keyString, "redis")
|
||||
|
||||
val responseHandler = object : RedisResponseHandler {
|
||||
override fun responseReceived(response: RedisMessage) {
|
||||
@@ -378,23 +378,23 @@ class RedisCacheHandler(
|
||||
|
||||
is ErrorRedisMessage -> {
|
||||
val ex = RedisException("Redis error for SET ${request.keyString}: ${response.content()}")
|
||||
telemetryController?.endRedisSpan(redisSpan, ex)
|
||||
telemetryController?.endSpan(redisSpan, ex)
|
||||
this@RedisCacheHandler.exceptionCaught(ctx, ex)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val ex = RedisException("Unexpected response for SET ${request.keyString}: ${response.javaClass.name}")
|
||||
telemetryController?.endRedisSpan(redisSpan, ex)
|
||||
telemetryController?.endSpan(redisSpan, ex)
|
||||
this@RedisCacheHandler.exceptionCaught(ctx, ex)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
telemetryController?.endRedisSpan(redisSpan)
|
||||
telemetryController?.endSpan(redisSpan)
|
||||
}
|
||||
}
|
||||
|
||||
override fun exceptionCaught(ex: Throwable) {
|
||||
telemetryController?.endRedisSpan(redisSpan, ex)
|
||||
telemetryController?.endSpan(redisSpan, ex)
|
||||
this@RedisCacheHandler.exceptionCaught(ctx, ex)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user