Skip to content

Commit 24cd617

Browse files
committed
chore: Add warning on Prometheus crate
1 parent 5be79c7 commit 24cd617

File tree

3 files changed

+79
-5
lines changed

3 files changed

+79
-5
lines changed

opentelemetry-otlp/src/lib.rs

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

opentelemetry-prometheus/README.md

Lines changed: 13 additions & 2 deletions
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 now [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

Lines changed: 12 additions & 2 deletions
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 now [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)