Skip to content

Commit 2070e6c

Browse files
authored
chore: Modify OTLP doc to show jaeger usage instead of a full example (#2805)
1 parent 0ff8c34 commit 2070e6c

File tree

5 files changed

+80
-109
lines changed

5 files changed

+80
-109
lines changed

examples/tracing-jaeger/Cargo.toml

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/tracing-jaeger/README.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/tracing-jaeger/jaeger.png

-165 KB
Binary file not shown.

examples/tracing-jaeger/src/main.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

opentelemetry-otlp/src/lib.rs

Lines changed: 80 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,68 @@
1-
//! The OTLP Exporter supports exporting logs, metrics and traces in the OTLP
2-
//! format to the OpenTelemetry collector or other compatible backend.
1+
//! # OpenTelemetry OTLP Exporter
32
//!
4-
//! The OpenTelemetry Collector offers a vendor-agnostic implementation on how
5-
//! to receive, process, and export telemetry data. In addition, it removes
6-
//! the need to run, operate, and maintain multiple agents/collectors in
7-
//! order to support open-source telemetry data formats (e.g. Jaeger,
8-
//! Prometheus, etc.) sending to multiple open-source or commercial back-ends.
3+
//! The OTLP Exporter enables exporting telemetry data (logs, metrics, and traces) in the
4+
//! OpenTelemetry Protocol (OTLP) format to compatible backends. These backends include:
95
//!
10-
//! Currently, this crate supports sending telemetry in OTLP
11-
//! via gRPC and http (binary and json).
6+
//! - OpenTelemetry Collector
7+
//! - Open-source observability tools (Prometheus, Jaeger, etc.)
8+
//! - Vendor-specific monitoring platforms
129
//!
13-
//! # Quickstart
10+
//! This crate supports sending OTLP data via:
11+
//! - gRPC
12+
//! - HTTP (binary protobuf or JSON)
1413
//!
15-
//! First make sure you have a running version of the opentelemetry collector
16-
//! you want to send data to:
14+
//! ## Quickstart with OpenTelemetry Collector
15+
//!
16+
//! ### HTTP Transport (Port 4318)
17+
//!
18+
//! Run the OpenTelemetry Collector:
1719
//!
1820
//! ```shell
19-
//! $ docker run -p 4317:4317 otel/opentelemetry-collector:latest
21+
//! $ docker run -p 4318:4318 otel/opentelemetry-collector:latest
22+
//! ```
23+
//!
24+
//! Configure your application to export traces via HTTP:
25+
//!
26+
//! ```no_run
27+
//! # #[cfg(all(feature = "trace", feature = "http-proto"))]
28+
//! # {
29+
//! use opentelemetry::global;
30+
//! use opentelemetry::trace::Tracer;
31+
//! use opentelemetry_otlp::Protocol;
32+
//! use opentelemetry_otlp::WithExportConfig;
33+
//!
34+
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
35+
//! // Initialize OTLP exporter using HTTP binary protocol
36+
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
37+
//! .with_http()
38+
//! .with_protocol(Protocol::HttpBinary)
39+
//! .build()?;
40+
//!
41+
//! // Create a tracer provider with the exporter
42+
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
43+
//! .with_simple_exporter(otlp_exporter)
44+
//! .build();
45+
//!
46+
//! // Get a tracer and create spans
47+
//! let tracer = global::tracer("my_tracer");
48+
//! tracer.in_span("doing_work", |_cx| {
49+
//! // Your application logic here...
50+
//! });
51+
//!
52+
//! Ok(())
53+
//! # }
54+
//! }
2055
//! ```
2156
//!
22-
//! Then create a new `Exporter`, and `Provider` with the recommended defaults to start exporting
23-
//! telemetry.
57+
//! ### gRPC Transport (Port 4317)
58+
//!
59+
//! Run the OpenTelemetry Collector:
2460
//!
25-
//! You will have to build a OTLP exporter first. Create the correct exporter based on the signal
26-
//! you are looking to export `SpanExporter::builder()`, `MetricExporter::builder()`,
27-
//! `LogExporter::builder()` respectively for traces, metrics, and logs.
61+
//! ```shell
62+
//! $ docker run -p 4317:4317 otel/opentelemetry-collector:latest
63+
//! ```
2864
//!
29-
//! Once you have the exporter, you can create your `Provider` by starting with `TracerProvider::builder()`,
30-
//! `SdkMeterProvider::builder()`, and `LoggerProvider::builder()` respectively for traces, metrics, and logs.
65+
//! Configure your application to export traces via gRPC:
3166
//!
3267
//! ```no_run
3368
//! # #[cfg(all(feature = "trace", feature = "grpc-tonic"))]
@@ -36,22 +71,41 @@
3671
//! use opentelemetry::trace::Tracer;
3772
//!
3873
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
39-
//! // First, create a OTLP exporter builder. Configure it as you need.
40-
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder().with_tonic().build()?;
41-
//! // Then pass it into provider builder
74+
//! // Initialize OTLP exporter using gRPC (Tonic)
75+
//! let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
76+
//! .with_tonic()
77+
//! .build()?;
78+
//!
79+
//! // Create a tracer provider with the exporter
4280
//! let _ = opentelemetry_sdk::trace::SdkTracerProvider::builder()
4381
//! .with_simple_exporter(otlp_exporter)
4482
//! .build();
83+
//!
84+
//! // Get a tracer and create spans
4585
//! let tracer = global::tracer("my_tracer");
46-
//! tracer.in_span("doing_work", |cx| {
47-
//! // Traced app logic here...
86+
//! tracer.in_span("doing_work", |_cx| {
87+
//! // Your application logic here...
4888
//! });
4989
//!
5090
//! Ok(())
51-
//! # }
91+
//! # }
5292
//! }
5393
//! ```
5494
//!
95+
//! ## Using with Jaeger
96+
//!
97+
//! Jaeger natively supports the OTLP protocol, making it easy to send traces directly:
98+
//!
99+
//! ```shell
100+
//! $ docker run -p 16686:16686 -p 4317:4317 -e COLLECTOR_OTLP_ENABLED=true jaegertracing/all-in-one:latest
101+
//! ```
102+
//!
103+
//! After running your application configured with the OTLP exporter, view traces at:
104+
//! `http://localhost:16686`
105+
//!
106+
//! ## Using with Prometheus (TODO)
107+
//! ## Show Logs, Metrics too (TODO)
108+
//!
55109
//! ## Performance
56110
//!
57111
//! For optimal performance, a batch exporting processor is recommended as the simple

0 commit comments

Comments
 (0)