Skip to content

Commit b03296c

Browse files
authored
chore: Add warning on Prometheus crate (#2831)
1 parent 969bedf commit b03296c

File tree

3 files changed

+80
-5
lines changed

3 files changed

+80
-5
lines changed

opentelemetry-otlp/src/lib.rs

+55-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,61 @@
103103
//! After running your application configured with the OTLP exporter, view traces at:
104104
//! `http://localhost:16686`
105105
//!
106-
//! ## Using with Prometheus (TODO)
106+
//! ## Using with Prometheus
107+
//!
108+
//! Prometheus natively supports accepting metrics via the OTLP protocol
109+
//! (HTTP/protobuf). You can [run
110+
//! Prometheus](https://prometheus.io/docs/prometheus/latest/installation/) with
111+
//! the following command:
112+
//!
113+
//! ```shell
114+
//! docker run -p 9090:9090 -v ./prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.enable-otlp-receiver
115+
//! ```
116+
//!
117+
//! (An empty prometheus.yml file is sufficient for this example.)
118+
//!
119+
//! Modify your application to export metrics via OTLP:
120+
//!
121+
//! ```no_run
122+
//! # #[cfg(all(feature = "metrics", feature = "http-proto"))]
123+
//! # {
124+
//! use opentelemetry::global;
125+
//! use opentelemetry::metrics::Meter;
126+
//! use opentelemetry::KeyValue;
127+
//! use opentelemetry_otlp::Protocol;
128+
//! use opentelemetry_otlp::WithExportConfig;
129+
//!
130+
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
131+
//! // Initialize OTLP exporter using HTTP binary protocol
132+
//! let exporter = opentelemetry_otlp::MetricExporter::builder()
133+
//! .with_http()
134+
//! .with_protocol(Protocol::HttpBinary)
135+
//! .with_endpoint("http://localhost:9090/api/v1/otlp/v1/metrics")
136+
//! .build()?;
137+
//!
138+
//! // Create a meter provider with the OTLP Metric exporter
139+
//! let meter_provider = opentelemetry_sdk::metrics::SdkMeterProvider::builder()
140+
//! .with_periodic_exporter(exporter)
141+
//! .build();
142+
//! global::set_meter_provider(meter_provider.clone());
143+
//!
144+
//! // Get a meter
145+
//! let meter = global::meter("my_meter");
146+
//!
147+
//! // Create a metric
148+
//! let counter = meter.u64_counter("my_counter").build();
149+
//! counter.add(1, &[KeyValue::new("key", "value")]);
150+
//!
151+
//! // Shutdown the meter provider. This will trigger an export of all metrics.
152+
//! meter_provider.shutdown()?;
153+
//!
154+
//! Ok(())
155+
//! # }
156+
//! }
157+
//! ```
158+
//!
159+
//! After running your application configured with the OTLP exporter, view metrics at:
160+
//! `http://localhost:9090`
107161
//! ## Show Logs, Metrics too (TODO)
108162
//!
109163
//! ## Performance

opentelemetry-prometheus/README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@
66

77
[`Prometheus`] integration for applications instrumented with [`OpenTelemetry`].
88

9-
**The development of prometheus exporter has halt until the Opentelemetry metrics API and SDK reaches 1.0. Current
10-
implementation is based on Opentelemetry API and SDK 0.27**.
9+
**Warning: This crate is no longer recommended for use.**
10+
11+
Development of the Prometheus exporter has been discontinued. See the related
12+
[issue](https://github.com/open-telemetry/opentelemetry-rust/issues/2451). This
13+
crate depends on the unmaintained `protobuf` crate and has unresolved security
14+
vulnerabilities. Version 0.29 will be the final release.
15+
16+
For Prometheus integration, we strongly recommend using the [OTLP] exporter
17+
instead. Prometheus [natively supports
18+
OTLP](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver),
19+
providing a more stable and actively maintained solution.
20+
21+
[OTLP]: https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/
1122

1223
[![Crates.io: opentelemetry-prometheus](https://img.shields.io/crates/v/opentelemetry-prometheus.svg)](https://crates.io/crates/opentelemetry-prometheus)
1324
[![Documentation](https://docs.rs/opentelemetry-prometheus/badge.svg)](https://docs.rs/opentelemetry-prometheus)

opentelemetry-prometheus/src/lib.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
//! An OpenTelemetry exporter for [Prometheus] metrics.
22
//!
3-
//! <div class="warning"> The development of prometheus exporter has halt until the Opentelemetry metrics API and SDK reaches 1.0. Current
4-
//! implementation is based on Opentelemetry API and SDK 0.23.</div>
3+
//! <div class="warning">
4+
//! <strong>Warning: This crate is no longer recommended for use.</strong><br><br>
5+
//! Development of the Prometheus exporter has been discontinued. See the related
6+
//! [issue](https://github.com/open-telemetry/opentelemetry-rust/issues/2451).
7+
//! This crate depends on the unmaintained `protobuf` crate and has unresolved
8+
//! security vulnerabilities. Version 0.29 will be the final release.
9+
//!
10+
//! For Prometheus integration, we strongly recommend using the [OTLP] exporter instead.
11+
//! Prometheus [natively supports OTLP](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver),
12+
//! providing a more stable and actively maintained solution.
13+
//! </div>
514
//!
615
//! [Prometheus]: https://prometheus.io
16+
//! [OTLP]: https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/
717
//!
818
//! ```
919
//! use opentelemetry::{metrics::MeterProvider, KeyValue};

0 commit comments

Comments
 (0)