diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs index 8aee311aa4..748687cfbe 100644 --- a/opentelemetry-otlp/src/lib.rs +++ b/opentelemetry-otlp/src/lib.rs @@ -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> { +//! // 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 diff --git a/opentelemetry-prometheus/README.md b/opentelemetry-prometheus/README.md index d16e3fede0..6b35843814 100644 --- a/opentelemetry-prometheus/README.md +++ b/opentelemetry-prometheus/README.md @@ -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) diff --git a/opentelemetry-prometheus/src/lib.rs b/opentelemetry-prometheus/src/lib.rs index e68243fe2c..a59324bf49 100644 --- a/opentelemetry-prometheus/src/lib.rs +++ b/opentelemetry-prometheus/src/lib.rs @@ -1,9 +1,19 @@ //! An OpenTelemetry exporter for [Prometheus] metrics. //! -//!
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.
+//!
+//! 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. +//!
//! //! [Prometheus]: https://prometheus.io +//! [OTLP]: https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/ //! //! ``` //! use opentelemetry::{metrics::MeterProvider, KeyValue};