5
5
//! [`API`]: https://opentelemetry.io/docs/specs/otel/overview/#api
6
6
//! [OpenTelemetry]: https://opentelemetry.io/docs/what-is-opentelemetry/
7
7
//!
8
+ //! [Jaeger]: https://www.jaegertracing.io/
9
+ //! [Prometheus]: https://www.prometheus.io/
10
+ //!
11
+ //! # Overview
12
+
13
+ //! OpenTelemetry is an Observability framework and toolkit designed to create and
14
+ //! manage telemetry data such as traces, metrics, and logs. OpenTelemetry is
15
+ //! vendor- and tool-agnostic, meaning that it can be used with a broad variety of
16
+ //! Observability backends, including open source tools like [Jaeger] and
17
+ //! [Prometheus], as well as commercial offerings.
18
+
19
+ //! OpenTelemetry is *not* an observability backend like Jaeger, Prometheus, or other
20
+ //! commercial vendors. OpenTelemetry is focused on the generation, collection,
21
+ //! management, and export of telemetry. A major goal of OpenTelemetry is that you
22
+ //! can easily instrument your applications or systems, no matter their language,
23
+ //! infrastructure, or runtime environment. Crucially, the storage and visualization
24
+ //! of telemetry is intentionally left to other tools.
25
+ //!
26
+ //! ## What does this crate contain?
27
+
28
+ //! This crate is basic foundation for integrating OpenTelemetry into libraries and
29
+ //! applications, encompassing several aspects of OpenTelemetry, such as context
30
+ //! management and propagation, baggage, logging, tracing, and metrics. It follows
31
+ //! the [OpenTelemetry
32
+ //! specification](https://github.com/open-telemetry/opentelemetry-specification).
33
+ //! Here's a breakdown of its components:
34
+ //!
35
+ //! - **[Context
36
+ //! API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/README.md):**
37
+ //! Provides a way to manage and propagate context, which is essential for keeping
38
+ //! track of trace execution across asynchronous tasks.
39
+ //! - **[Propagators
40
+ //! API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md):**
41
+ //! Defines how context can be shared across process boundaries, ensuring
42
+ //! continuity across microservices or distributed systems.
43
+ //! - **[Baggage
44
+ //! API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/baggage/api.md):**
45
+ //! Allows for the attachment of metadata (baggage) to telemetry, which can be
46
+ //! used for sharing application-specific information across service boundaries.
47
+ //! - **[Logs Bridge
48
+ //! API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/api.md):**
49
+ //! Allows to bridge existing logging mechanisms with OpenTelemetry logging. This
50
+ //! is **NOT** meant for end users to call, instead it is meant to enable writing
51
+ //! bridges/appenders for existing logging mechanisms such as
52
+ //! [log](https://crates.io/crates/log) or
53
+ //! [tracing](https://crates.io/crates/tracing).
54
+ //! - **[Tracing
55
+ //! API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md):**
56
+ //! Offers a set of primitives to produce distributed traces to understand the
57
+ //! flow of a request across system boundaries.
58
+ //! - **[Metrics
59
+ //! API](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md):**
60
+ //! Offers a set of primitives to produce measurements of operational metrics like
61
+ //! latency, throughput, or error rates.
62
+ //!
63
+ //! This crate serves as a facade or no-op implementation, meaning it defines the
64
+ //! traits for instrumentation but does not itself implement the processing or
65
+ //! exporting of telemetry data. This separation of concerns allows library authors
66
+ //! to depend on the API crate without tying themselves to a specific
67
+ //! implementation.
68
+ //!
69
+ //! Actual implementation and the heavy lifting of telemetry data collection,
70
+ //! processing, and exporting are delegated to the
71
+ //! [opentelemetry-sdk](https://crates.io/crates/opentelemetry-sdk) crate and
72
+ //! various exporter crates such as
73
+ //! [opentelemetry-otlp](https://crates.io/crates/opentelemetry-otlp). This
74
+ //! architecture ensures that the final application can light up the instrumentation
75
+ //! by integrating an SDK implementation.
76
+ //!
77
+ //! Library authors are recommended to depend on this crate *only*. This approach is
78
+ //! also aligned with the design philosophy of existing telemetry solutions in the
79
+ //! Rust ecosystem, like `tracing` or `log`, where these crates only offer a facade
80
+ //! and the actual functionality is enabled through additional crates.
81
+ //!
82
+ //! ## Related crates
83
+
84
+ //! Unless you are a library author, you will almost always need to use additional
85
+ //! crates along with this. Given this crate has no-op implementation only, an
86
+ //! OpenTelemetry SDK is always required.
87
+ //! [opentelemetry-sdk](https://crates.io/crates/opentelemetry-sdk) is the official
88
+ //! SDK implemented by OpenTelemetry itself, though it is possible to use a
89
+ //! different sdk.
90
+ //!
91
+ //! Additionally one or more exporters are also required to export telemetry to a
92
+ //! destination. OpenTelemetry provides the following exporters:
93
+ //!
94
+ //! - **[opentelemetry-stdout](https://crates.io/crates/opentelemetry-stdout):**
95
+ //! Prints telemetry to stdout, primarily used for learning/debugging purposes.
96
+ //! - **[opentelemetry-otlp](https://crates.io/crates/opentelemetry-otlp):** Exports
97
+ //! telemetry (logs, metrics and traces) in the [OTLP
98
+ //! format](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/protocol)
99
+ //! to an endpoint accepting OTLP. This could be the [OTel
100
+ //! Collector](https://github.com/open-telemetry/opentelemetry-collector),
101
+ //! telemetry backends like [Jaeger](https://www.jaegertracing.io/),
102
+ //! [Prometheus](https://prometheus.io/docs/prometheus/latest/feature_flags/#otlp-receiver)
103
+ //! or [vendor specific endpoints](https://opentelemetry.io/ecosystem/vendors/).
104
+ //! - **[opentelemetry-zipkin](https://crates.io/crates/opentelemetry-zipkin):**
105
+ //! Exports telemetry (traces only) to Zipkin following [OpenTelemetry to Zipkin
106
+ //! specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk_exporters/zipkin.md)
107
+ //! - **[opentelemetry-prometheus](https://crates.io/crates/opentelemetry-prometheus):**
108
+ //! Exports telemetry (metrics only) to Prometheus following [OpenTelemetry to
109
+ //! Prometheus
110
+ //! specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/prometheus.md)
111
+ //!
112
+ //! OpenTelemetry Rust also has a [contrib
113
+ //! repo](https://github.com/open-telemetry/opentelemetry-rust-contrib), where
114
+ //! additional exporters could be found. Check [OpenTelemetry
115
+ //! Registry](https://opentelemetry.io/ecosystem/registry/?language=rust) for
116
+ //! additional exporters and other related components as well.
117
+ //!
8
118
//! # Getting Started
9
119
//!
10
120
//! ```no_run
24
134
//!
25
135
//! [examples]: https://github.com/open-telemetry/opentelemetry-rust/tree/main/examples
26
136
//!
27
- //! # Traces
137
+ //! ## Traces
28
138
//!
29
139
//! The [`trace`] module includes types for tracking the progression of a single
30
140
//! request while it is handled by services that make up an application. A trace
31
141
//! is a tree of [`Span`]s which are objects that represent the work being done
32
142
//! by individual services or components involved in a request as it flows
33
143
//! through a system.
34
144
//!
35
- //! ### Creating and exporting spans
145
+ //! ### Creating spans
36
146
//!
37
147
//! ```
38
148
//! # #[cfg(feature = "trace")]
60
170
//!
61
171
//! [`Span`]: crate::trace::Span
62
172
//!
63
- //! # Metrics
173
+ //! ## Metrics
64
174
//!
65
175
//!
66
176
//! The [`metrics`] module includes types for recording measurements about a
88
198
//! managing instruments.
89
199
//!
90
200
//!
91
- //! # Logs
201
+ //! ## Logs
92
202
//!
93
203
//! The [`logs`] module contains the Logs Bridge API. It is not intended to be
94
204
//! called by application developers directly. It is provided for logging
102
212
//! [`opentelemetry-appender-tracing`](https://crates.io/crates/opentelemetry-appender-tracing)
103
213
//! crates.
104
214
//!
105
- //! ## Crate Feature Flags
215
+ //! ## Feature Flags
106
216
//!
107
217
//! The following core crate feature flags are available:
108
218
//!
109
219
//! * `trace`: Includes the trace API.
110
220
//! * `metrics`: Includes the metrics API.
111
221
//! * `logs`: Includes the logs bridge API.
222
+ //! * `internal-logs`: Enables internal logging via `tracing`.
112
223
//!
113
- //! The default feature flags are ["trace", "metrics", "logs"]
224
+ //! The default feature flags are ["trace", "metrics", "logs", "internal-logs"].
114
225
//!
115
226
//! The following feature flags provides additional configuration for `logs`:
116
227
//! * `spec_unstable_logs_enabled`: Allow users to control the log level
117
228
//!
118
229
//! The following feature flags enable APIs defined in OpenTelemetry specification that is in experimental phase:
119
230
//! * `otel_unstable`: Includes unstable APIs.
120
231
//!
121
- //! ## Related Crates
122
- //!
123
- //! In addition to `opentelemetry`, the [`open-telemetry/opentelemetry-rust`]
124
- //! repository contains several additional crates designed to be used with the
125
- //! `opentelemetry` ecosystem. This includes exporters, samplers, as well as
126
- //! utility and adapter crates to assist in propagating context and
127
- //! instrumenting applications.
128
- //!
129
- //! In particular, the following crates are likely to be of interest:
130
- //!
131
- //! - [`opentelemetry_sdk`] provides the OpenTelemetry SDK used to configure providers.
132
- //! - [`opentelemetry-http`] provides an interface for injecting and extracting
133
- //! trace information from [`http`] headers.
134
- //! - [`opentelemetry-otlp`] exporter for sending telemetry in the
135
- //! OTLP format.
136
- //! - [`opentelemetry-prometheus`] provides a pipeline and exporter for sending
137
- //! metrics information to [`Prometheus`].
138
- //! - [`opentelemetry-zipkin`] provides a pipeline and exporter for sending
139
- //! trace information to [`Zipkin`].
140
- //!
141
- //! In addition, there are several other useful crates in the [OTel Rust
142
- //! Contrib
143
- //! repo](https://github.com/open-telemetry/opentelemetry-rust-contrib). A lot
144
- //! of crates maintained outside OpenTelemetry owned repos can be found in the
145
- //! [OpenTelemetry
146
- //! Registry](https://opentelemetry.io/ecosystem/registry/?language=rust).
147
232
//!
148
233
//! [`http`]: https://crates.io/crates/http
149
234
//! [`open-telemetry/opentelemetry-rust`]: https://github.com/open-telemetry/opentelemetry-rust
161
246
//! supported version is 1.70. The current OpenTelemetry version is not
162
247
//! guaranteed to build on Rust versions earlier than the minimum supported
163
248
//! version.
249
+ //! This crate is built against the latest stable release. The minimum supported
250
+ //! version is 1.70. The current version is not guaranteed to build on Rust
251
+ //! versions earlier than the minimum supported version.
164
252
//!
165
253
//! The current stable Rust compiler and the three most recent minor versions
166
254
//! before it will always be supported. For example, if the current stable
@@ -239,4 +327,4 @@ pub mod time {
239
327
pub fn now ( ) -> SystemTime {
240
328
SystemTime :: UNIX_EPOCH + std:: time:: Duration :: from_millis ( js_sys:: Date :: now ( ) as u64 )
241
329
}
242
- }
330
+ }
0 commit comments