@@ -44,20 +44,6 @@ use std::time::SystemTime;
44
44
/// // child has ended, parent now the active span again
45
45
/// });
46
46
/// // parent has ended, no active spans
47
- ///
48
- /// // -- OR --
49
- ///
50
- /// // create complex spans with span builder and `with_span`
51
- /// let parent_span = tracer.span_builder("foo").with_kind(SpanKind::Server).start(&tracer);
52
- /// tracer.with_span(parent_span, |_foo_cx| {
53
- /// // parent span is active
54
- /// let child_span = tracer.span_builder("bar").with_kind(SpanKind::Client).start(&tracer);
55
- /// tracer.with_span(child_span, |_bar_cx| {
56
- /// // child span is now the active span and associated with the parent span
57
- /// });
58
- /// // child has ended, parent now the active span again
59
- /// });
60
- /// // parent has ended, no active spans
61
47
/// ```
62
48
///
63
49
/// Spans can also be marked as active, and the resulting guard allows for
@@ -228,46 +214,6 @@ pub trait Tracer {
228
214
let _guard = cx. clone ( ) . attach ( ) ;
229
215
f ( cx)
230
216
}
231
-
232
- /// Execute the given closure with reference to a context in which the span is
233
- /// active.
234
- ///
235
- /// This sets the given span as active for the duration of the given function.
236
- /// It then executes the body. It closes the span before returning the execution
237
- /// result.
238
- ///
239
- /// # Examples
240
- ///
241
- /// ```
242
- /// use opentelemetry_api::{global, trace::{Span, SpanKind, Tracer, get_active_span}, KeyValue};
243
- ///
244
- /// fn my_function() {
245
- /// let tracer = global::tracer("my-component");
246
- /// // start a span with custom attributes via span builder
247
- /// let span = tracer.span_builder("span-name").with_kind(SpanKind::Server).start(&tracer);
248
- /// // Mark the span as active for the duration of the closure
249
- /// global::tracer("my-component").with_span(span, |_cx| {
250
- /// // anything happening in functions we call can still access the active span...
251
- /// my_other_function();
252
- /// })
253
- /// }
254
- ///
255
- /// fn my_other_function() {
256
- /// // call methods on the current span from
257
- /// get_active_span(|span| {
258
- /// span.add_event("An event!".to_string(), vec![KeyValue::new("happened", true)]);
259
- /// })
260
- /// }
261
- /// ```
262
- fn with_span < T , F > ( & self , span : Self :: Span , f : F ) -> T
263
- where
264
- F : FnOnce ( Context ) -> T ,
265
- Self :: Span : Send + Sync + ' static ,
266
- {
267
- let cx = Context :: current_with_span ( span) ;
268
- let _guard = cx. clone ( ) . attach ( ) ;
269
- f ( cx)
270
- }
271
217
}
272
218
273
219
/// `SpanBuilder` allows span attributes to be configured before the span
0 commit comments