@@ -20,8 +20,7 @@ import Dispatch
20
20
public protocol LegacyTracerProtocol : InstrumentProtocol {
21
21
/// Start a new span returning an existential ``Span`` reference.
22
22
///
23
- /// This API will be deprecated as soon as Swift 5.9 is released, and the Swift 5.7 requiring `TracerProtocol`
24
- /// is recommended instead.
23
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
25
24
///
26
25
/// The current task-local `Baggage` is picked up and provided to the underlying tracer.
27
26
/// It is also possible to pass a specific `baggage` explicitly, in which case attempting
@@ -75,8 +74,7 @@ extension LegacyTracerProtocol {
75
74
76
75
/// Start a new span returning an existential ``Span`` reference.
77
76
///
78
- /// This API will be deprecated as soon as Swift 5.9 is released, and the Swift 5.7 requiring `TracerProtocol`
79
- /// is recommended instead.
77
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
80
78
///
81
79
/// The current task-local `Baggage` is picked up and provided to the underlying tracer.
82
80
/// It is also possible to pass a specific `baggage` explicitly, in which case attempting
@@ -122,6 +120,34 @@ extension LegacyTracerProtocol {
122
120
)
123
121
}
124
122
123
+ /// Start a new span returning an existential ``Span`` reference.
124
+ ///
125
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
126
+ ///
127
+ ///
128
+ /// The current task-local `Baggage` is picked up and provided to the underlying tracer.
129
+ /// It is also possible to pass a specific `baggage` explicitly, in which case attempting
130
+ /// to pick up the task-local baggage is prevented. This can be useful when we know that
131
+ /// we're about to start a top-level span, or if a span should be started from a different,
132
+ /// stored away previously,
133
+ ///
134
+ /// - Note: Legacy API, prefer using ``startSpan(_:baggage:ofKind:at:
135
+ ///
136
+ /// - Note: Prefer ``withSpan(_:baggage:ofKind:at:function:file:line:operation:)`` to start
137
+ /// a span as it automatically takes care of ending the span, and recording errors when thrown.
138
+ /// Use `startSpan` iff you need to pass the span manually to a different
139
+ /// location in your source code to end it.
140
+ ///
141
+ /// - Warning: You must `end()` the span when it the measured operation has completed explicitly,
142
+ /// otherwise the span object will potentially never be released nor reported.
143
+ ///
144
+ /// - Parameters:
145
+ /// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
146
+ /// - baggage: The `Baggage` providing information on where to start the new ``Span``.
147
+ /// - kind: The ``SpanKind`` of the new ``Span``.
148
+ /// - function: The function name in which the span was started
149
+ /// - fileID: The `fileID` where the span was started.
150
+ /// - line: The file line where the span was started.
125
151
public func startAnySpan(
126
152
_ operationName: String ,
127
153
baggage: @autoclosure ( ) -> Baggage = . current ?? . topLevel,
@@ -143,6 +169,29 @@ extension LegacyTracerProtocol {
143
169
144
170
// ==== withAnySpan + sync ------------------------------------------------
145
171
172
+ /// Start a new ``Span`` and automatically end when the `operation` completes,
173
+ /// including recording the `error` in case the operation throws.
174
+ ///
175
+ /// The current task-local `Baggage` is picked up and provided to the underlying tracer.
176
+ /// It is also possible to pass a specific `baggage` explicitly, in which case attempting
177
+ /// to pick up the task-local baggage is prevented. This can be useful when we know that
178
+ /// we're about to start a top-level span, or if a span should be started from a different,
179
+ /// stored away previously,
180
+ ///
181
+ /// - Warning: You MUST NOT ``Span/end()`` the span explicitly, because at the end of the `withSpan`
182
+ /// operation closure returning the span will be closed automatically.
183
+ ///
184
+ /// - Parameters:
185
+ /// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
186
+ /// - baggage: The `Baggage` providing information on where to start the new ``Span``.
187
+ /// - kind: The ``SpanKind`` of the new ``Span``.
188
+ /// - clock: The clock to use as time source for the start time of the ``Span``
189
+ /// - function: The function name in which the span was started
190
+ /// - fileID: The `fileID` where the span was started.
191
+ /// - line: The file line where the span was started.
192
+ /// - operation: The operation that this span should be measuring
193
+ /// - Returns: the value returned by `operation`
194
+ /// - Throws: the error the `operation` has thrown (if any)
146
195
public func withAnySpan< T, Clock: TracerClock > (
147
196
_ operationName: String ,
148
197
clock: Clock ,
@@ -173,6 +222,30 @@ extension LegacyTracerProtocol {
173
222
}
174
223
}
175
224
225
+ /// Start a new ``Span`` and automatically end when the `operation` completes,
226
+ /// including recording the `error` in case the operation throws.
227
+ ///
228
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
229
+ ///
230
+ /// The current task-local `Baggage` is picked up and provided to the underlying tracer.
231
+ /// It is also possible to pass a specific `baggage` explicitly, in which case attempting
232
+ /// to pick up the task-local baggage is prevented. This can be useful when we know that
233
+ /// we're about to start a top-level span, or if a span should be started from a different,
234
+ /// stored away previously,
235
+ ///
236
+ /// - Warning: You MUST NOT ``Span/end()`` the span explicitly, because at the end of the `withSpan`
237
+ /// operation closure returning the span will be closed automatically.
238
+ ///
239
+ /// - Parameters:
240
+ /// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
241
+ /// - baggage: The `Baggage` providing information on where to start the new ``Span``.
242
+ /// - kind: The ``SpanKind`` of the new ``Span``.
243
+ /// - function: The function name in which the span was started
244
+ /// - fileID: The `fileID` where the span was started.
245
+ /// - line: The file line where the span was started.
246
+ /// - operation: The operation that this span should be measuring
247
+ /// - Returns: the value returned by `operation`
248
+ /// - Throws: the error the `operation` has thrown (if any)
176
249
public func withAnySpan< T> (
177
250
_ operationName: String ,
178
251
baggage: @autoclosure ( ) -> Baggage = . current ?? . topLevel,
@@ -196,6 +269,30 @@ extension LegacyTracerProtocol {
196
269
197
270
// ==== withAnySpan async -------------------------------------------------
198
271
272
+ /// Start a new ``Span`` and automatically end when the `operation` completes,
273
+ /// including recording the `error` in case the operation throws.
274
+ ///
275
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
276
+ ///
277
+ /// The current task-local `Baggage` is picked up and provided to the underlying tracer.
278
+ /// It is also possible to pass a specific `baggage` explicitly, in which case attempting
279
+ /// to pick up the task-local baggage is prevented. This can be useful when we know that
280
+ /// we're about to start a top-level span, or if a span should be started from a different,
281
+ /// stored away previously,
282
+ ///
283
+ /// - Warning: You MUST NOT ``Span/end()`` the span explicitly, because at the end of the `withSpan`
284
+ /// operation closure returning the span will be closed automatically.
285
+ ///
286
+ /// - Parameters:
287
+ /// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
288
+ /// - baggage: The `Baggage` providing information on where to start the new ``Span``.
289
+ /// - kind: The ``SpanKind`` of the new ``Span``.
290
+ /// - function: The function name in which the span was started
291
+ /// - fileID: The `fileID` where the span was started.
292
+ /// - line: The file line where the span was started.
293
+ /// - operation: The operation that this span should be measuring
294
+ /// - Returns: the value returned by `operation`
295
+ /// - Throws: the error the `operation` has thrown (if any)
199
296
public func withAnySpan< T, Clock: TracerClock > (
200
297
_ operationName: String ,
201
298
clock: Clock ,
@@ -226,6 +323,30 @@ extension LegacyTracerProtocol {
226
323
}
227
324
}
228
325
326
+ /// Start a new ``Span`` and automatically end when the `operation` completes,
327
+ /// including recording the `error` in case the operation throws.
328
+ ///
329
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
330
+ ///
331
+ /// The current task-local `Baggage` is picked up and provided to the underlying tracer.
332
+ /// It is also possible to pass a specific `baggage` explicitly, in which case attempting
333
+ /// to pick up the task-local baggage is prevented. This can be useful when we know that
334
+ /// we're about to start a top-level span, or if a span should be started from a different,
335
+ /// stored away previously,
336
+ ///
337
+ /// - Warning: You MUST NOT ``Span/end()`` the span explicitly, because at the end of the `withSpan`
338
+ /// operation closure returning the span will be closed automatically.
339
+ ///
340
+ /// - Parameters:
341
+ /// - operationName: The name of the operation being traced. This may be a handler function, database call, ...
342
+ /// - baggage: The `Baggage` providing information on where to start the new ``Span``.
343
+ /// - kind: The ``SpanKind`` of the new ``Span``.
344
+ /// - function: The function name in which the span was started
345
+ /// - fileID: The `fileID` where the span was started.
346
+ /// - line: The file line where the span was started.
347
+ /// - operation: The operation that this span should be measuring
348
+ /// - Returns: the value returned by `operation`
349
+ /// - Throws: the error the `operation` has thrown (if any)
229
350
public func withAnySpan< T> (
230
351
_ operationName: String ,
231
352
baggage: @autoclosure ( ) -> Baggage = . current ?? . topLevel,
@@ -262,8 +383,7 @@ extension LegacyTracerProtocol {
262
383
extension TracerProtocol {
263
384
/// Start a new span returning an existential ``Span`` reference.
264
385
///
265
- /// This API will be deprecated as soon as Swift 5.9 is released, and the Swift 5.7 requiring `TracerProtocol`
266
- /// is recommended instead.
386
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
267
387
///
268
388
/// The current task-local `Baggage` is picked up and provided to the underlying tracer.
269
389
/// It is also possible to pass a specific `baggage` explicitly, in which case attempting
@@ -312,8 +432,7 @@ extension TracerProtocol {
312
432
/// Start a new ``Span`` and automatically end when the `operation` completes,
313
433
/// including recording the `error` in case the operation throws.
314
434
///
315
- /// This API will be deprecated as soon as Swift 5.9 is released, and the Swift 5.7 requiring `TracerProtocol`
316
- /// is recommended instead.
435
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
317
436
///
318
437
/// The current task-local `Baggage` is picked up and provided to the underlying tracer.
319
438
/// It is also possible to pass a specific `baggage` explicitly, in which case attempting
@@ -368,8 +487,7 @@ extension TracerProtocol {
368
487
/// Start a new ``Span`` and automatically end when the `operation` completes,
369
488
/// including recording the `error` in case the operation throws.
370
489
///
371
- /// This API will be deprecated as soon as Swift 5.9 is released, and the Swift 5.7 requiring `TracerProtocol`
372
- /// is recommended instead.
490
+ /// - Warning: This method will be deprecated in favor of `TracerProtocol/withSpan` as soon as this project is able to require Swift 5.7.
373
491
///
374
492
/// The current task-local `Baggage` is picked up and provided to the underlying tracer.
375
493
/// It is also possible to pass a specific `baggage` explicitly, in which case attempting
0 commit comments