You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Tracing/Span.swift
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -48,13 +48,35 @@ public protocol Span: AnyObject {
48
48
49
49
/// End this `Span` at the given timestamp.
50
50
///
51
-
/// Ending a `Span` MUST be idempotent.
51
+
/// ### Rules about ending Spans
52
+
/// A Span must be ended only ONCE. Ending a Span multiple times or never at all is considered a programming error.
53
+
///
54
+
/// A tracer implementation MAY decide to crash the application if e.g. running in debug mode and noticing such misuse.
55
+
///
56
+
/// Implementations SHOULD prevent double-emitting by marking a span as ended internally, however it still is a
57
+
/// programming mistake to rely on this behavior.
58
+
///
52
59
/// - Parameter timestamp: The `Timestamp` at which the span ended.
60
+
///
61
+
/// - SeeAlso: `Span.end()` which automatically uses the "current" time as timestamp.
53
62
func end(at timestamp:Timestamp)
54
63
}
55
64
56
65
extensionSpan{
57
66
/// End this `Span` at the current timestamp.
67
+
///
68
+
/// ### Rules about ending Spans
69
+
/// A Span must be ended only ONCE. Ending a Span multiple times or never at all is considered a programming error.
70
+
///
71
+
/// A tracer implementation MAY decide to crash the application if e.g. running in debug mode and noticing such misuse.
72
+
///
73
+
/// Implementations SHOULD prevent double-emitting by marking a span as ended internally, however it still is a
74
+
/// programming mistake to rely on this behavior.
75
+
///
76
+
/// - Parameter timestamp: The `Timestamp` at which the span ended.
77
+
///
78
+
/// - SeeAlso: `Span.end(at:)` which allows passing in a specific timestamp, e.g. if the operation was ended and recorded somewhere and we need to post-factum record it.
79
+
/// Generally though prefer using the `end()` version of this API in user code and structure your system such that it can be called in the right place and time.
0 commit comments