@@ -23,6 +23,10 @@ import Network
2323import NIOTransportServices
2424#endif
2525
26+ #if DistributedTracingSupport
27+ import Tracing
28+ #endif
29+
2630/// A single connection to a Valkey database.
2731@available ( valkeySwift 1 . 0 , * )
2832public final actor ValkeyConnection : ValkeyClientProtocol , Sendable {
@@ -159,16 +163,20 @@ public final actor ValkeyConnection: ValkeyClientProtocol, Sendable {
159163
160164 @inlinable
161165 func _execute< Command: ValkeyCommand > ( command: Command ) async throws -> RESPToken {
162- let requestID = Self . requestIDGenerator. next ( )
163- return try await withTaskCancellationHandler {
164- if Task . isCancelled {
165- throw ValkeyClientError ( . cancelled)
166- }
167- return try await withCheckedThrowingContinuation { continuation in
168- self . channelHandler. write ( command: command, continuation: continuation, requestID: requestID)
166+ try await withSpan ( Command . name, ofKind: . client) { span in
167+ span. attributes [ " db.system.name " ] = " valkey "
168+
169+ let requestID = Self . requestIDGenerator. next ( )
170+ return try await withTaskCancellationHandler {
171+ if Task . isCancelled {
172+ throw ValkeyClientError ( . cancelled)
173+ }
174+ return try await withCheckedThrowingContinuation { continuation in
175+ self . channelHandler. write ( command: command, continuation: continuation, requestID: requestID)
176+ }
177+ } onCancel: {
178+ self . cancel ( requestID: requestID)
169179 }
170- } onCancel: {
171- self . cancel ( requestID: requestID)
172180 }
173181 }
174182
0 commit comments