-
Notifications
You must be signed in to change notification settings - Fork 11
Add Distributed Tracing support #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
14d5172
8560eca
061f031
c95c599
ef47244
a4e8772
db86f71
a6e27b7
29d5ba0
a63dc6b
baff60c
d1b16e7
ada0aa2
784f53e
5b59b04
4d0066e
f1667d6
a1b605f
960c035
bb8839b
34db440
faf9dcc
60c0a01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ | |
|
||
import NIOSSL | ||
|
||
#if DistributedTracingSupport | ||
import Tracing | ||
#endif | ||
|
||
/// A configuration object that defines how to connect to a Valkey server. | ||
/// | ||
/// `ValkeyConnectionConfiguration` allows you to customize various aspects of the connection, | ||
|
@@ -112,6 +116,12 @@ public struct ValkeyConnectionConfiguration: Sendable { | |
/// Default value is `nil` (no client name is set). | ||
public var clientName: String? | ||
|
||
#if DistributedTracingSupport | ||
/// The distributed tracing configuration to use for this connection. | ||
/// Defaults to using the globally bootstrapped tracer with OpenTelemetry semantic conventions. | ||
public var tracing: ValkeyTracingConfiguration = .init() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On this one maybe just a small note that picks global bootstrapped tracer at this point in time and allows configuring tracing? |
||
#endif | ||
|
||
/// Creates a new Valkey connection configuration. | ||
/// | ||
/// Use this initializer to create a configuration object that can be used to establish | ||
|
@@ -137,3 +147,34 @@ public struct ValkeyConnectionConfiguration: Sendable { | |
self.clientName = clientName | ||
} | ||
} | ||
|
||
#if DistributedTracingSupport | ||
@available(valkeySwift 1.0, *) | ||
/// A configuration object that defines distributed tracing behavior of a Valkey client. | ||
public struct ValkeyTracingConfiguration: Sendable { | ||
/// The tracer to use, or `nil` to disable tracing. | ||
/// Defaults to the globally bootstrapped tracer. | ||
public var tracer: (any Tracer)? = InstrumentationSystem.tracer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth some docs here how this is
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If global tracer is NoOp tracer is it worth setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had asked about this over here #177 (comment) and had a chat with @fabianfett about it. So there seems to be minor differences and although the performance is roughly the same it seems to have caused an odd allocation here and there, whereas without it the allocation count in valkey was a solid 0... The NoopTracer is definitely nicer to use but if you truly want to go with the If we were to suggest people in libraries, I think you're very right -- doing It's not that the allocations come from the noop-spans btw, they are structs... so I'm uncertain where they were coming from; we'd need to do more digging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slashmo Can we get some comments on ValkeyTracingConfiguration and its members. This is currently a public symbol without any comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, let me add some. |
||
|
||
/// The attribute names used in spans created by Valkey. Defaults to OpenTelemetry semantics. | ||
public var attributeNames: AttributeNames = .init() | ||
|
||
/// The static attribute values used in spans created by Valkey. | ||
public var attributeValues: AttributeValues = .init() | ||
|
||
/// Attribute names used in spans created by Valkey. | ||
public struct AttributeNames: Sendable { | ||
public var databaseOperationName: String = "db.operation.name" | ||
public var databaseSystemName: String = "db.system.name" | ||
public var networkPeerAddress: String = "network.peer.address" | ||
public var networkPeerPort: String = "network.peer.port" | ||
public var serverAddress: String = "server.address" | ||
public var serverPort: String = "server.port" | ||
} | ||
|
||
/// Static attribute values used in spans created by Valkey. | ||
public struct AttributeValues: Sendable { | ||
public var databaseSystem: String = "valkey" | ||
} | ||
} | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.