Skip to content

Commit 12b040a

Browse files
committed
fix
1 parent 1775c76 commit 12b040a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Sources/Tracing/Tracer.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ extension Tracer {
275275
)
276276
defer { span.end() }
277277
do {
278-
return try await Baggage.withValue(span.baggage) {
278+
return try await Baggage.$current.withValue(span.baggage) {
279279
try await operation(span)
280280
}
281281
} catch {
@@ -312,7 +312,7 @@ extension Tracer {
312312
let span = self.startSpan(operationName, baggage: baggage, ofKind: kind, function: function, file: fileID, line: line)
313313
defer { span.end() }
314314
do {
315-
return try await Baggage.withValue(span.baggage) {
315+
return try await Baggage.$current.withValue(span.baggage) {
316316
try await operation(span)
317317
}
318318
} catch {

Tests/TracingTests/DynamicTracepointTracerTests.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ final class DynamicTracepointTracerTests: XCTestCase {
8787
}
8888

8989
func logic(fakeLine: UInt) {
90+
#if swift(>=5.5)
9091
InstrumentationSystem.tracer.withSpan("\(#function)-dont", line: fakeLine) { _ in
9192
}
93+
#endif
9294
}
9395

9496
func traceMeLogic(fakeLine: UInt) {
@@ -166,13 +168,14 @@ final class DynamicTracepointTestTracer: Tracer {
166168
}
167169

168170
private func shouldRecord(tracepoint: TracepointID) -> Bool {
171+
#if swift(>=5.5.0)
169172
if self.isActive(tracepoint: tracepoint) {
170173
// this tracepoint was specifically activated!
171174
return true
172175
}
173176

174177
// else, perhaps there is already an active span, if so, attach to it
175-
guard let baggage = Baggage.current else { // TODO: we could make this such that we only ever once pick-up 🧳
178+
guard let baggage = Baggage.$current.withValue else { // TODO: we could make this such that we only ever once pick-up 🧳
176179
return false
177180
}
178181

@@ -184,6 +187,9 @@ final class DynamicTracepointTestTracer: Tracer {
184187
// there is some active trace already, so we should record as well
185188
// TODO: this logic may need to become smarter
186189
return true
190+
#else
191+
return false
192+
#endif
187193
}
188194

189195
func isActive(tracepoint: TracepointID) -> Bool {

0 commit comments

Comments
 (0)