|
54 | 54 | //! 3. **Record Measurements:** Use the instruments to record measurement values |
55 | 55 | //! along with optional attributes. |
56 | 56 | //! |
57 | | -//! ## How Metrics Work in OpenTelemetry |
| 57 | +//! ## How Metrics work in OpenTelemetry |
58 | 58 | //! In OpenTelemetry, raw measurements recorded using instruments are |
59 | 59 | //! **aggregated in memory** to form metrics. These aggregated metrics are |
60 | 60 | //! periodically exported by the [`opentelemetry_sdk`] at fixed intervals (e.g., |
|
91 | 91 | //! - An **ObservableUpDownCounter** can monitor the size of an in-memory queue |
92 | 92 | //! by reporting the size using queue's len() method within the callback |
93 | 93 | //! function. |
| 94 | +//! - An **ObservableGauge** can monitor the CPU temperature by using |
| 95 | +//! temperature sensor APIs within the callback function. |
94 | 96 | //! |
95 | 97 | //! For detailed guidance, refer to [OpenTelemetry Metrics API - Instrumentation |
96 | 98 | //! Guidance](https://opentelemetry.io/docs/specs/otel/metrics/supplementary-guidelines/#instrument-selection). |
|
109 | 111 | //! let meter = global::meter("my_service"); |
110 | 112 | //! |
111 | 113 | //! // Create an instrument (in this case, a Counter). |
112 | | -//! let counter = meter.u64_counter("my_counter").build(); |
| 114 | +//! let counter = meter.u64_counter("request.count").build(); |
113 | 115 | //! |
114 | 116 | //! // Record a measurement by passing the value and a set of attributes. |
115 | 117 | //! counter.add(1, &[KeyValue::new("http.client_ip", "83.164.160.102")]); |
116 | 118 | //! |
117 | 119 | //! // Create an ObservableCounter and register a callback that reports the measurement. |
118 | 120 | //! let _observable_counter = meter |
119 | | -//! .u64_observable_counter("my_observable_counter") |
| 121 | +//! .u64_observable_counter("bytes_received") |
120 | 122 | //! .with_callback(|observer| { |
121 | 123 | //! observer.observe( |
122 | 124 | //! 100, |
123 | 125 | //! &[ |
124 | | -//! KeyValue::new("mykey1", "myvalue1"), |
| 126 | +//! KeyValue::new("protocol", "udp"), |
125 | 127 | //! ], |
126 | 128 | //! ) |
127 | 129 | //! }) |
|
151 | 153 | //! [`opentelemetry-appender-tracing`](https://crates.io/crates/opentelemetry-appender-tracing) |
152 | 154 | //! crates. |
153 | 155 | //! |
154 | | -//! ## Crate Feature Flags |
| 156 | +//! # Crate Feature Flags |
155 | 157 | //! |
156 | 158 | //! The following core crate feature flags are available: |
157 | 159 | //! |
|
168 | 170 | //! The following feature flags enable APIs defined in OpenTelemetry specification that is in experimental phase: |
169 | 171 | //! * `otel_unstable`: Includes unstable APIs. There are no features behind this flag at the moment. |
170 | 172 | //! |
171 | | -//! ## Related Crates |
| 173 | +//! # Related Crates |
172 | 174 | //! |
173 | 175 | //! In addition to `opentelemetry`, the [`open-telemetry/opentelemetry-rust`] |
174 | 176 | //! repository contains several additional crates designed to be used with the |
|
208 | 210 | //! [`Prometheus`]: https://prometheus.io |
209 | 211 | //! [`Zipkin`]: https://zipkin.io |
210 | 212 | //! |
211 | | -//! ## Supported Rust Versions |
| 213 | +//! # Supported Rust Versions |
212 | 214 | //! |
213 | 215 | //! OpenTelemetry is built against the latest stable release. The minimum |
214 | 216 | //! supported version is 1.70. The current OpenTelemetry version is not |
|
0 commit comments