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
@@ -19,7 +19,28 @@ import Dispatch
19
19
/// with it. A `Span` can be created from a `Baggage` which contains span information, in which case this span should
20
20
/// be considered as "child" of the previous span.
21
21
///
22
-
/// Creating a `Span` is delegated to a ``Tracer`` and end users should never create them directly.
22
+
/// Creating a `Span` is delegated to an implementation of ``TracerProtocol`` and end-users should never instantiate spans directly.
23
+
/// Most commonly, a span is started using the `withSpan` API of a tracer, like this:
24
+
///
25
+
/// ```
26
+
/// tracer.withSpan("working-on-\(thing)") { span in
27
+
/// // ...
28
+
/// }
29
+
/// ```
30
+
///
31
+
/// Once started, a span contains its start time and additional metadata necessary for the tracing backend to handle e.g.
32
+
/// further child spans.
33
+
///
34
+
/// ### Child Spans
35
+
///
36
+
///
37
+
/// ## Manual lifetime management
38
+
/// In some situations it may not be possible
39
+
///
40
+
/// > Warning: Generally spans should be started using the ``TracerProtocol/withSpan(_:ofKind:_:)-11n3y`` method,
41
+
/// > however it may sometimes be necessary to use the alternate ``TracerProtocol/startSpan(_:baggage:ofKind:)`` API.
42
+
/// > If the `startSpan` API is used to create a span, it must be explicitly ended using ``end()`` on *every* code-path
43
+
/// > leading to the logical end of the span. Omitting to end a span or ending it twice is a programmer error.
23
44
///
24
45
/// - SeeAlso: For more details refer to the [OpenTelemetry Specification: Span](https://github.com/open-telemetry/opentelemetry-specification/blob/v0.7.0/specification/trace/api.md#span) which this type is compatible with.
25
46
publicprotocolSpan:AnyObject{
@@ -84,6 +105,7 @@ extension Span {
84
105
}
85
106
86
107
/// Adds a ``SpanLink`` between this `Span` and the given `Span`.
108
+
///
87
109
/// - Parameter other: The `Span` to link to.
88
110
/// - Parameter attributes: The ``SpanAttributes`` describing this link. Defaults to no attributes.
0 commit comments