Skip to content

Commit b4d9954

Browse files
committed
Enable struct Spans with reference semantics; optimal NoopSpan
**Motivation:** We want a noop span to be NOT ref counted. **Modifications:** Allow spans to be value types through they must have reference semantics **Result:** Efficient noop spans
1 parent a7e66b3 commit b4d9954

File tree

11 files changed

+290
-316
lines changed

11 files changed

+290
-316
lines changed

Sources/Tracing/NoOpTracer.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public struct NoOpTracer: LegacyTracerProtocol {
4747
// no-op
4848
}
4949

50-
public final class NoOpSpan: Span {
50+
public struct NoOpSpan: Span {
5151
public let baggage: Baggage
5252
public var isRecording: Bool {
5353
false
@@ -57,7 +57,7 @@ public struct NoOpTracer: LegacyTracerProtocol {
5757
get {
5858
"noop"
5959
}
60-
set {
60+
nonmutating set {
6161
// ignore
6262
}
6363
}
@@ -78,11 +78,19 @@ public struct NoOpTracer: LegacyTracerProtocol {
7878
get {
7979
[:]
8080
}
81-
set {
81+
nonmutating set {
8282
// ignore
8383
}
8484
}
8585

86+
public func setAttribute(name: String, _ value: some SpanAttributeConvertible) {
87+
// ignore
88+
}
89+
90+
public func getAttribute(name: String) -> (SpanAttributeConvertible)? {
91+
nil
92+
}
93+
8694
public func end(at time: DispatchWallTime) {
8795
// ignore
8896
}

0 commit comments

Comments
 (0)