Skip to content

Commit 3ec4c18

Browse files
authored
Nit doc update for OTLP Exporter (#2567)
1 parent 6fa9ae2 commit 3ec4c18

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

opentelemetry-otlp/src/lib.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
//! order to support open-source telemetry data formats (e.g. Jaeger,
88
//! Prometheus, etc.) sending to multiple open-source or commercial back-ends.
99
//!
10-
//! Currently, this crate only support sending telemetry in OTLP
11-
//! via grpc and http (in binary format). Supports for other format and protocol
12-
//! will be added in the future. The details of what's currently offering in this
13-
//! crate can be found in this doc.
10+
//! Currently, this crate supports sending telemetry in OTLP
11+
//! via gRPC and http (binary and json).
1412
//!
1513
//! # Quickstart
1614
//!
@@ -56,34 +54,36 @@
5654
//!
5755
//! ## Performance
5856
//!
59-
//! For optimal performance, a batch exporter is recommended as the simple
60-
//! exporter will export each span synchronously on dropping. You can enable the
61-
//! [`rt-tokio`], [`rt-tokio-current-thread`] or [`rt-async-std`] features and
62-
//! specify a runtime on the pipeline builder to have a batch exporter
63-
//! configured for you automatically.
57+
//! For optimal performance, a batch exporting processor is recommended as the simple
58+
//! processor will export each span synchronously on dropping, and is only good
59+
//! for test/debug purposes.
6460
//!
6561
//! ```toml
6662
//! [dependencies]
67-
//! opentelemetry_sdk = { version = "*", features = ["async-std"] }
6863
//! opentelemetry-otlp = { version = "*", features = ["grpc-tonic"] }
6964
//! ```
7065
//!
7166
//! ```no_run
7267
//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))]
7368
//! # {
74-
//! # fn main() -> Result<(), opentelemetry::trace::TraceError> {
75-
//! let tracer = opentelemetry_sdk::trace::TracerProvider::builder()
76-
//! .with_batch_exporter(
77-
//! opentelemetry_otlp::SpanExporter::builder()
78-
//! .with_tonic()
79-
//! .build()?,
80-
//! opentelemetry_sdk::runtime::Tokio,
81-
//! )
82-
//! .build();
69+
//! use opentelemetry::global;
70+
//! use opentelemetry::trace::Tracer;
8371
//!
84-
//! # Ok(())
85-
//! # }
86-
//! # }
72+
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
73+
//! // First, create a OTLP exporter builder. Configure it as you need.
74+
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder().with_tonic().build()?;
75+
//! // Then pass it into provider builder
76+
//! let _ = opentelemetry_sdk::trace::TracerProvider::builder()
77+
//! .with_batch_exporter(otlp_exporter)
78+
//! .build();
79+
//! let tracer = global::tracer("my_tracer");
80+
//! tracer.in_span("doing_work", |cx| {
81+
//! // Traced app logic here...
82+
//! });
83+
//!
84+
//! Ok(())
85+
//! # }
86+
//! }
8787
//! ```
8888
//!
8989
//! [`tokio`]: https://tokio.rs
@@ -92,7 +92,7 @@
9292
//! # Feature Flags
9393
//! The following feature flags can enable exporters for different telemetry signals:
9494
//!
95-
//! * `trace`: Includes the trace exporters (enabled by default).
95+
//! * `trace`: Includes the trace exporters.
9696
//! * `metrics`: Includes the metrics exporters.
9797
//! * `logs`: Includes the logs exporters.
9898
//!
@@ -101,17 +101,17 @@
101101
//!
102102
//! The following feature flags offer additional configurations on gRPC:
103103
//!
104-
//! For users uses `tonic` as grpc layer:
105-
//! * `grpc-tonic`: Use `tonic` as grpc layer. This is enabled by default.
104+
//! For users using `tonic` as grpc layer:
105+
//! * `grpc-tonic`: Use `tonic` as grpc layer.
106106
//! * `gzip-tonic`: Use gzip compression for `tonic` grpc layer.
107107
//! * `zstd-tonic`: Use zstd compression for `tonic` grpc layer.
108108
//! * `tls-roots`: Adds system trust roots to rustls-based gRPC clients using the rustls-native-certs crate
109109
//! * `tls-webpki-roots`: Embeds Mozilla's trust roots to rustls-based gRPC clients using the webpki-roots crate
110110
//!
111111
//! The following feature flags offer additional configurations on http:
112112
//!
113-
//! * `http-proto`: Use http as transport layer, protobuf as body format.
114-
//! * `reqwest-blocking-client`: Use reqwest blocking http client.
113+
//! * `http-proto`: Use http as transport layer, protobuf as body format. This feature is enabled by default.
114+
//! * `reqwest-blocking-client`: Use reqwest blocking http client. This feature is enabled by default.
115115
//! * `reqwest-client`: Use reqwest http client.
116116
//! * `reqwest-rustls`: Use reqwest with TLS with system trust roots via `rustls-native-certs` crate.
117117
//! * `reqwest-rustls-webpki-roots`: Use reqwest with TLS with Mozilla's trust roots via `webpki-roots` crate.
@@ -152,7 +152,7 @@
152152
//! .build()?;
153153
//!
154154
//! let tracer_provider = opentelemetry_sdk::trace::TracerProvider::builder()
155-
//! .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio)
155+
//! .with_batch_exporter(exporter)
156156
//! .with_config(
157157
//! trace::Config::default()
158158
//! .with_sampler(Sampler::AlwaysOn)
@@ -162,7 +162,7 @@
162162
//! .with_max_events_per_span(16)
163163
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build()),
164164
//! ).build();
165-
//! global::set_tracer_provider(tracer_provider);
165+
//! global::set_tracer_provider(tracer_provider.clone());
166166
//! let tracer = global::tracer("tracer-name");
167167
//! # tracer
168168
//! # };
@@ -179,7 +179,7 @@
179179
//!
180180
//! let reader = opentelemetry_sdk::metrics::PeriodicReader::builder(exporter)
181181
//! .with_interval(std::time::Duration::from_secs(3))
182-
//! .with_timeout(Duration::from_secs(10))
182+
//! .with_timeout(Duration::from_secs(10))
183183
//! .build();
184184
//!
185185
//! let provider = opentelemetry_sdk::metrics::SdkMeterProvider::builder()

0 commit comments

Comments
 (0)