Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add warning on Prometheus crate #2831

Merged
merged 9 commits into from
Mar 20, 2025
56 changes: 55 additions & 1 deletion opentelemetry-otlp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,61 @@
//! After running your application configured with the OTLP exporter, view traces at:
//! `http://localhost:16686`
//!
//! ## Using with Prometheus (TODO)
//! ## Using with Prometheus
//!
//! Prometheus natively supports accepting metrics via the OTLP protocol
//! (HTTP/protobuf). You can [run
//! Prometheus](https://prometheus.io/docs/prometheus/latest/installation/) with
//! the following command:
//!
//! ```shell
//! docker run -p 9090:9090 -v ./prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.enable-otlp-receiver
//! ```
//!
//! (An empty prometheus.yml file is sufficient for this example.)
//!
//! Modify your application to export metrics via OTLP:
//!
//! ```no_run
//! # #[cfg(all(feature = "metrics", feature = "http-proto"))]
//! # {
//! use opentelemetry::global;
//! use opentelemetry::metrics::Meter;
//! use opentelemetry::KeyValue;
//! use opentelemetry_otlp::Protocol;
//! use opentelemetry_otlp::WithExportConfig;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! // Initialize OTLP exporter using HTTP binary protocol
//! let exporter = opentelemetry_otlp::MetricExporter::builder()
//! .with_http()
//! .with_protocol(Protocol::HttpBinary)
//! .with_endpoint("http://localhost:9090/api/v1/otlp/v1/metrics")
//! .build()?;
//!
//! // Create a meter provider with the OTLP Metric exporter
//! let meter_provider = opentelemetry_sdk::metrics::SdkMeterProvider::builder()
//! .with_periodic_exporter(exporter)
//! .build();
//! global::set_meter_provider(meter_provider.clone());
//!
//! // Get a meter
//! let meter = global::meter("my_meter");
//!
//! // Create a metric
//! let counter = meter.u64_counter("my_counter").build();
//! counter.add(1, &[KeyValue::new("key", "value")]);
//!
//! // Shutdown the meter provider. This will trigger an export of all metrics.
//! meter_provider.shutdown()?;
//!
//! Ok(())
//! # }
//! }
//! ```
//!
//! After running your application configured with the OTLP exporter, view metrics at:
//! `http://localhost:9090`
//! ## Show Logs, Metrics too (TODO)
//!
//! ## Performance
Expand Down
15 changes: 13 additions & 2 deletions opentelemetry-prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@

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

**The development of prometheus exporter has halt until the Opentelemetry metrics API and SDK reaches 1.0. Current
implementation is based on Opentelemetry API and SDK 0.27**.
**Warning: This crate is no longer recommended for use.**

Development of the Prometheus exporter has been discontinued. See the related
[issue](https://github.com/open-telemetry/opentelemetry-rust/issues/2451). This
crate depends on the unmaintained `protobuf` crate and has unresolved security
vulnerabilities. Version 0.29 will be the final release.

For Prometheus integration, we strongly recommend using the [OTLP] exporter
instead. Prometheus [natively supports
OTLP](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver),
providing a more stable and actively maintained solution.

[OTLP]: https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/

[![Crates.io: opentelemetry-prometheus](https://img.shields.io/crates/v/opentelemetry-prometheus.svg)](https://crates.io/crates/opentelemetry-prometheus)
[![Documentation](https://docs.rs/opentelemetry-prometheus/badge.svg)](https://docs.rs/opentelemetry-prometheus)
Expand Down
14 changes: 12 additions & 2 deletions opentelemetry-prometheus/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
//! An OpenTelemetry exporter for [Prometheus] metrics.
//!
//! <div class="warning"> The development of prometheus exporter has halt until the Opentelemetry metrics API and SDK reaches 1.0. Current
//! implementation is based on Opentelemetry API and SDK 0.23.</div>
//! <div class="warning">
//! <strong>Warning: This crate is no longer recommended for use.</strong><br><br>
//! Development of the Prometheus exporter has been discontinued. See the related
//! [issue](https://github.com/open-telemetry/opentelemetry-rust/issues/2451).
//! This crate depends on the unmaintained `protobuf` crate and has unresolved
//! security vulnerabilities. Version 0.29 will be the final release.
//!
//! For Prometheus integration, we strongly recommend using the [OTLP] exporter instead.
//! Prometheus [natively supports OTLP](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver),
//! providing a more stable and actively maintained solution.
//! </div>
//!
//! [Prometheus]: https://prometheus.io
//! [OTLP]: https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/
//!
//! ```
//! use opentelemetry::{metrics::MeterProvider, KeyValue};
Expand Down
Loading