# prometheus-json-encoder Implements a `JsonEncoder` object for [prometheus 0.13.0](https://docs.rs/prometheus/0.13.0/prometheus/index.html). ## Basic example ``` use opentelemetry::{global, KeyValue, sdk::Resource}; use opentelemetry_prometheus::PrometheusExporter; use prometheus_json_encoder::JsonEncoder; fn init_meter() -> PrometheusExporter { opentelemetry_prometheus::exporter() .with_resource(Resource::new(vec![KeyValue::new("R", "V")])) .init() } fn main(){ let exporter = init_meter(); let meter = global::meter("my-app"); // Use two instruments let counter = meter .u64_counter("a.counter") .with_description("Counts things") .init(); let recorder = meter .i64_value_recorder("a.value_recorder") .with_description("Records values") .init(); counter.add(100, &[KeyValue::new("key", "value1")]); counter.add(100, &[KeyValue::new("key", "value2")]); counter.add(100, &[KeyValue::new("key2", "value")]); recorder.record(100, &[KeyValue::new("key", "value")]); // Encode data as text or protobuf let encoder = JsonEncoder::new(); let metric_families = exporter.registry().gather(); let mut result = Vec::new(); encoder.encode(&metric_families, &mut result); println!("format :\n{}", encoder.format_type()); println!("{:?}", result); let test = std::str::from_utf8(&result).unwrap(); println!("{}", test) } ```