|
40 | 40 | //! |
41 | 41 | //! // Create a tracer provider with the exporter |
42 | 42 | //! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder() |
43 | | -//! .with_simple_exporter(otlp_exporter) |
| 43 | +//! .with_batch_exporter(otlp_exporter) |
44 | 44 | //! .build(); |
45 | 45 | //! |
46 | 46 | //! // Set it as the global provider |
|
83 | 83 | //! |
84 | 84 | //! // Create a tracer provider with the exporter |
85 | 85 | //! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder() |
86 | | -//! .with_simple_exporter(otlp_exporter) |
| 86 | +//! .with_batch_exporter(otlp_exporter) |
87 | 87 | //! .build(); |
88 | 88 | //! |
89 | 89 | //! // Set it as the global provider |
|
116 | 116 | //! .build() |
117 | 117 | //! .expect("Failed to create span exporter"); |
118 | 118 | //! opentelemetry_sdk::trace::SdkTracerProvider::builder() |
119 | | -//! .with_simple_exporter(exporter) |
| 119 | +//! .with_batch_exporter(exporter) |
120 | 120 | //! .build() |
121 | 121 | //! }); |
122 | 122 | //! |
|
203 | 203 | //! `http://localhost:9090` |
204 | 204 | //! ## Show Logs, Metrics too (TODO) |
205 | 205 | //! |
206 | | -//! ## Performance |
207 | | -//! |
208 | | -//! For optimal performance, a batch exporting processor is recommended as the simple |
209 | | -//! processor will export each span synchronously on dropping, and is only good |
210 | | -//! for test/debug purposes. |
211 | | -//! |
212 | | -//! ```toml |
213 | | -//! [dependencies] |
214 | | -//! opentelemetry-otlp = { version = "*", features = ["grpc-tonic"] } |
215 | | -//! ``` |
216 | | -//! |
217 | | -//! ```no_run |
218 | | -//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))] |
219 | | -//! # { |
220 | | -//! use opentelemetry::global; |
221 | | -//! use opentelemetry::trace::Tracer; |
222 | | -//! |
223 | | -//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> { |
224 | | -//! // First, create a OTLP exporter builder. Configure it as you need. |
225 | | -//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder().with_tonic().build()?; |
226 | | -//! // Then pass it into provider builder |
227 | | -//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder() |
228 | | -//! .with_batch_exporter(otlp_exporter) |
229 | | -//! .build(); |
230 | | -//! let tracer = global::tracer("my_tracer"); |
231 | | -//! tracer.in_span("doing_work", |cx| { |
232 | | -//! // Traced app logic here... |
233 | | -//! }); |
234 | | -//! |
235 | | -//! Ok(()) |
236 | | -//! # } |
237 | | -//! } |
238 | | -//! ``` |
239 | | -//! |
240 | 206 | //! [`tokio`]: https://tokio.rs |
241 | 207 | //! |
242 | 208 | //! # Feature Flags |
|
0 commit comments