Skip to content

Enable struct Spans with reference semantics; optimal NoopSpan #94

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

Merged
merged 3 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Sources/Tracing/NoOpTracer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Dispatch

/// Tracer that ignores all operations, used when no tracing is required.
public struct NoOpTracer: LegacyTracerProtocol {
public typealias Span = NoOpSpan
public typealias TracerSpan = NoOpSpan

public init() {}

Expand All @@ -28,7 +28,7 @@ public struct NoOpTracer: LegacyTracerProtocol {
at time: DispatchWallTime,
function: String,
file fileID: String,
line: UInt) -> any SpanProtocol
line: UInt) -> any Span
{
NoOpSpan(baggage: baggage())
}
Expand All @@ -47,7 +47,7 @@ public struct NoOpTracer: LegacyTracerProtocol {
// no-op
}

public final class NoOpSpan: SpanProtocol {
public struct NoOpSpan: Span {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic.

public let baggage: Baggage
public var isRecording: Bool {
false
Expand All @@ -57,7 +57,7 @@ public struct NoOpTracer: LegacyTracerProtocol {
get {
"noop"
}
set {
nonmutating set {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"whoa whoa whoa" this saved the day.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

// ignore
}
}
Expand All @@ -78,7 +78,7 @@ public struct NoOpTracer: LegacyTracerProtocol {
get {
[:]
}
set {
nonmutating set {
// ignore
}
}
Expand Down
Loading