Skip to content

Commit 9643e52

Browse files
committed
Document tracing configuration
1 parent 34db440 commit 9643e52

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Sources/Valkey/Connection/ValkeyConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public final actor ValkeyConnection: ValkeyClientProtocol, Sendable {
267267
@usableFromInline
268268
func applyCommonAttributes(to attributes: inout SpanAttributes, commandName: String) {
269269
attributes[self.configuration.tracing.attributeNames.databaseOperationName] = commandName
270-
attributes[self.configuration.tracing.attributeNames.databaseSystemName] = self.configuration.tracing.attributeValue.databaseSystem
270+
attributes[self.configuration.tracing.attributeNames.databaseSystemName] = self.configuration.tracing.attributeValues.databaseSystem
271271
attributes[self.configuration.tracing.attributeNames.networkPeerAddress] = channel.remoteAddress?.ipAddress
272272
attributes[self.configuration.tracing.attributeNames.networkPeerPort] = channel.remoteAddress?.port
273273
attributes[self.configuration.tracing.attributeNames.serverAddress] = address?.hostOrSocketPath

Sources/Valkey/Connection/ValkeyConnectionConfiguration.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public struct ValkeyConnectionConfiguration: Sendable {
117117
public var clientName: String?
118118

119119
#if DistributedTracingSupport
120+
/// The distributed tracing configuration to use for this connection.
121+
/// Defaults to using the globally bootstrapped tracer with OpenTelemetry semantic conventions.
120122
public var tracing: ValkeyTracingConfiguration = .init()
121123
#endif
122124

@@ -148,13 +150,19 @@ public struct ValkeyConnectionConfiguration: Sendable {
148150

149151
#if DistributedTracingSupport
150152
@available(valkeySwift 1.0, *)
153+
/// A configuration object that defines distributed tracing behavior of a Valkey client.
151154
public struct ValkeyTracingConfiguration: Sendable {
152-
155+
/// The tracer to use, or `nil` to disable tracing.
156+
/// Defaults to the globally bootstrapped tracer.
153157
public var tracer: (any Tracer)? = InstrumentationSystem.tracer
154158

159+
/// The attribute names used in spans created by Valkey. Defaults to OpenTelemetry semantics.
155160
public var attributeNames: AttributeNames = .init()
156-
public var attributeValue: AttributeValues = .init()
157161

162+
/// The static attribute values used in spans created by Valkey.
163+
public var attributeValues: AttributeValues = .init()
164+
165+
/// Attribute names used in spans created by Valkey.
158166
public struct AttributeNames: Sendable {
159167
public var databaseOperationName: String = "db.operation.name"
160168
public var databaseSystemName: String = "db.system.name"
@@ -164,6 +172,7 @@ public struct ValkeyTracingConfiguration: Sendable {
164172
public var serverPort: String = "server.port"
165173
}
166174

175+
/// Static attribute values used in spans created by Valkey.
167176
public struct AttributeValues: Sendable {
168177
public var databaseSystem: String = "valkey"
169178
}

Sources/Valkey/ValkeyClientConfiguration.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public struct ValkeyClientConfiguration: Sendable {
119119
public var tls: TLS
120120

121121
#if DistributedTracingSupport
122+
/// The distributed tracing configuration to use for the Valkey connection.
123+
/// Defaults to using the globally bootstrapped tracer with OpenTelemetry semantic conventions.
122124
public var tracing: ValkeyTracingConfiguration = .init()
123125
#endif
124126

0 commit comments

Comments
 (0)