Skip to content

Commit 51927c5

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 51927c5

11 files changed

+324
-349
lines changed

Sources/Tracing/NoOpTracer.swift

+12-5
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
}
@@ -68,21 +68,28 @@ public struct NoOpTracer: LegacyTracerProtocol {
6868

6969
public func setStatus(_ status: SpanStatus) {}
7070

71-
public func addLink(_ link: SpanLink) {}
71+
public func addLink(_ link: SpanLink<Self>) {}
7272

73-
public func addEvent(_ event: SpanEvent) {}
73+
public func addEvent(_ event: SpanEvent<Self>) {}
7474

7575
public func recordError(_ error: Error, attributes: SpanAttributes) {}
7676

7777
public var attributes: SpanAttributes {
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+
public func getAttribute(name: String) -> (SpanAttributeConvertible)? {
90+
nil
91+
}
92+
8693
public func end(at time: DispatchWallTime) {
8794
// ignore
8895
}

0 commit comments

Comments
 (0)