Skip to content

Commit 53cf9ff

Browse files
committed
avoid error on 5.6 when sendable convertible used
1 parent 0a947e1 commit 53cf9ff

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

Sources/Tracing/Span.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,18 @@ extension Array: SpanAttributeConvertible where Element: SpanAttributeConvertibl
392392
return .boolArray(value)
393393
} else if let value = self as? [String] {
394394
return .stringArray(value)
395-
} else if let value = self as? [CustomStringConvertible] {
395+
}
396+
#if swift(>=5.6.0)
397+
if let value = self as? [CustomStringConvertible & Sendable] {
398+
return .stringConvertibleArray(value)
399+
}
400+
#else
401+
if let value = self as? [CustomStringConvertible] {
396402
return .stringConvertibleArray(value)
397-
} else {
398-
fatalError("Not supported SpanAttribute array type: \(type(of: self))")
399403
}
404+
#endif
405+
406+
fatalError("Not supported SpanAttribute array type: \(type(of: self))")
400407
}
401408
}
402409

Tests/TracingTests/DynamicTracepointTracerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,6 @@ extension DynamicTracepointTestTracer {
292292
}
293293

294294
#if compiler(>=5.6.0)
295-
extension DynamicTracepointTestTracer: @unchecked Sendable {}
296-
extension DynamicTracepointTestTracer.TracepointSpan: @unchecked Sendable {}
295+
extension DynamicTracepointTestTracer: @unchecked Sendable {} // only intended for single threaded testing
296+
extension DynamicTracepointTestTracer.TracepointSpan: @unchecked Sendable {} // only intended for single threaded testing
297297
#endif

Tests/TracingTests/SpanTests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public struct HTTPAttributes: SpanAttributeNamespace {
244244
}
245245
}
246246

247-
public struct CustomAttributeValue: Equatable, CustomStringConvertible, SpanAttributeConvertible {
247+
public struct CustomAttributeValue: Equatable, _CustomAttributeValueSendable, CustomStringConvertible, SpanAttributeConvertible {
248248
public func toSpanAttribute() -> SpanAttribute {
249249
.stringConvertible(self)
250250
}
@@ -255,6 +255,12 @@ public struct CustomAttributeValue: Equatable, CustomStringConvertible, SpanAttr
255255
}
256256
#endif
257257

258+
#if swift(>=5.6.0)
259+
typealias _CustomAttributeValueSendable = Sendable
260+
#else
261+
typealias _CustomAttributeValueSendable = Any
262+
#endif
263+
258264
private struct TestBaggageContextKey: BaggageKey {
259265
typealias Value = String
260266
}

Tests/TracingTests/TestTracer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ final class TestSpan: Span {
160160
}
161161

162162
#if compiler(>=5.6.0)
163-
extension TestTracer: @unchecked Sendable {}
164-
extension TestSpan: @unchecked Sendable {}
163+
extension TestTracer: @unchecked Sendable {} // only intended for single threaded testing
164+
extension TestSpan: @unchecked Sendable {} // only intended for single threaded testing
165165
#endif

Tests/TracingTests/TracedLockTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,5 @@ private final class TracedLockPrintlnTracer: Tracer {
162162

163163
#if compiler(>=5.6.0)
164164
extension TracedLockPrintlnTracer: Sendable {}
165-
extension TracedLockPrintlnTracer.TracedLockPrintlnSpan: @unchecked Sendable {}
165+
extension TracedLockPrintlnTracer.TracedLockPrintlnSpan: @unchecked Sendable {} // only intended for single threaded testing
166166
#endif

0 commit comments

Comments
 (0)