Skip to content

Commit 17d4378

Browse files
authored
Pipeline metrics - Follow up of open-telemetry#1606 (open-telemetry#1632)
So far, we had hot-path support for **Counter**, **UpDownCounter**, and **Gauge** metrics. These metrics are defined using macros that specify the name, description, and unit, which lets us automatically generate a semantic convention registry for our engine and for all pipeline components (receiver, processor, exporter). Some of these metrics are fundamentally **cumulative counters** or **cumulative up-down counters** (for example, memory usage). In this PR, I therefore split our `Counter` and `UpDownCounter` types into: * **DeltaCounter / DeltaUpDownCounter** * **ObserveCounter / ObserveUpDownCounter** With the following API: * delta counters and delta up-down counters expose an `add` method * observe counters and observe up-down counters expose an `observe` method * gauges expose a `set` method This, I believe, aligns with the OTel intrumentation API model. Now I'm hitting a problem: I haven't found a way to automatically represent these **cumulative** metrics without going through an SDK exporter configuration file. I put a temporary workaround in `dispatcher.rs`, but I’d like a better and more accurate solution to connect the Rust Client SDK with these internal metrics.
1 parent ac99143 commit 17d4378

25 files changed

Lines changed: 685 additions & 450 deletions

File tree

rust/otap-dataflow/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ thiserror.workspace = true
3737
quiver = { workspace = true, optional = true }
3838
serde_json.workspace = true
3939
clap.workspace = true
40-
mimalloc.workspace = true
41-
tikv-jemallocator.workspace = true
40+
mimalloc = { workspace = true, optional = true }
4241
rustls = { workspace = true, optional = true }
4342

43+
[target.'cfg(not(windows))'.dependencies]
44+
tikv-jemallocator = { workspace = true, optional = true }
45+
4446
[workspace.dependencies]
4547
otap-df-pdata-otlp-macros = { path = "./crates/pdata/src/otlp/macros"}
4648
otap-df-pdata-otlp-model = { path = "./crates/pdata/src/otlp/model"}
@@ -176,7 +178,10 @@ time = "0.3.44"
176178
wiremock = "0.6.5"
177179

178180
[features]
179-
default = []
181+
# ToDo When jemalloc is enabled, we could use jemalloc_pprof to profile where memory is allocated. See https://crates.io/crates/jemalloc_pprof
182+
default = ["jemalloc"]
183+
jemalloc = ["dep:tikv-jemallocator"]
184+
mimalloc = ["dep:mimalloc"]
180185
azure = ["otap-df-otap/azure"]
181186
unsafe-optimizations = ["unchecked-index", "unchecked-arithmetic"]
182187
unchecked-index = []

rust/otap-dataflow/benchmarks/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ criterion = { workspace = true, features = ["html_reports", "async_tokio"] }
1919
tonic = { workspace = true }
2020
tonic-prost = { workspace = true }
2121
prost = { workspace = true }
22-
tikv-jemallocator.workspace = true
2322

2423
otap-df-config = { path = "../crates/config" }
2524
otap-df-channel = { path = "../crates/channel" }
@@ -39,6 +38,9 @@ unsync.workspace = true
3938
portpicker.workspace = true
4039
tokio-stream.workspace = true
4140

41+
[target.'cfg(not(windows))'.dev-dependencies]
42+
tikv-jemallocator.workspace = true
43+
4244
[lints]
4345
workspace = true
4446

rust/otap-dataflow/benchmarks/benches/attribute_transform/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ use otap_df_pdata::otap::transform::{
1414
AttributesTransform, DeleteTransform, RenameTransform, transform_attributes,
1515
};
1616
use otap_df_pdata::schema::consts;
17+
18+
#[cfg(not(windows))]
1719
use tikv_jemallocator::Jemalloc;
1820

21+
#[cfg(not(windows))]
1922
#[global_allocator]
2023
static GLOBAL: Jemalloc = Jemalloc;
2124

rust/otap-dataflow/benchmarks/benches/channel/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_m
1212
use futures::{SinkExt, StreamExt};
1313
use futures_channel::mpsc as futures_mpsc;
1414
use std::rc::Rc;
15-
use tikv_jemallocator::Jemalloc;
1615
use tokio::task::LocalSet;
1716

17+
#[cfg(not(windows))]
18+
use tikv_jemallocator::Jemalloc;
19+
20+
#[cfg(not(windows))]
1821
#[global_allocator]
1922
static GLOBAL: Jemalloc = Jemalloc;
2023

rust/otap-dataflow/benchmarks/benches/exporter/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ use otap_df_telemetry::MetricsSystem;
6767
use serde_json::json;
6868
use std::pin::Pin;
6969
use std::sync::Arc;
70-
use tikv_jemallocator::Jemalloc;
7170
use tokio_stream::Stream;
7271
use tokio_stream::wrappers::ReceiverStream;
7372

73+
#[cfg(not(windows))]
74+
use tikv_jemallocator::Jemalloc;
75+
76+
#[cfg(not(windows))]
7477
#[global_allocator]
7578
static GLOBAL: Jemalloc = Jemalloc;
7679

rust/otap-dataflow/benchmarks/benches/item_count/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ use std::hint::black_box;
1111
use otap_df_pdata::proto::opentelemetry::common::v1::*;
1212
use otap_df_pdata::proto::opentelemetry::logs::v1::*;
1313
use otap_df_pdata::proto::opentelemetry::resource::v1::*;
14+
15+
#[cfg(not(windows))]
1416
use tikv_jemallocator::Jemalloc;
1517

18+
#[cfg(not(windows))]
1619
#[global_allocator]
1720
static GLOBAL: Jemalloc = Jemalloc;
1821

rust/otap-dataflow/benchmarks/benches/materialize_parent_id/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
1414
use otap_df_pdata::otap::transform::materialize_parent_id_for_attributes;
1515
use otap_df_pdata::otlp::attributes::AttributeValueType;
1616
use otap_df_pdata::schema::consts;
17+
18+
#[cfg(not(windows))]
1719
use tikv_jemallocator::Jemalloc;
1820

21+
#[cfg(not(windows))]
1922
#[global_allocator]
2023
static GLOBAL: Jemalloc = Jemalloc;
2124

rust/otap-dataflow/benchmarks/benches/otap_encoder/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ use otap_df_pdata::proto::opentelemetry::resource::v1::Resource;
1919
use otap_df_pdata::views::bench_helpers::visit_logs_data;
2020
use otap_df_pdata::views::otlp::bytes::logs::RawLogsData;
2121
use prost::Message;
22+
23+
#[cfg(not(windows))]
2224
use tikv_jemallocator::Jemalloc;
2325

26+
#[cfg(not(windows))]
2427
#[global_allocator]
2528
static GLOBAL: Jemalloc = Jemalloc;
2629

rust/otap-dataflow/benchmarks/benches/otap_logs_view/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ use arrow::datatypes::UInt8Type;
3232
use arrow::error::ArrowError;
3333
use otap_df_pdata::encode::record::attributes::StrKeysAttributesRecordBatchBuilder;
3434
use otap_df_pdata::encode::record::logs::LogsRecordBatchBuilder;
35+
36+
#[cfg(not(windows))]
3537
use tikv_jemallocator::Jemalloc;
3638

39+
#[cfg(not(windows))]
3740
#[global_allocator]
3841
static GLOBAL: Jemalloc = Jemalloc;
3942

rust/otap-dataflow/benchmarks/benches/otlp_bytes/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ use prost::Message;
1111
use otap_df_pdata::proto::opentelemetry::common::v1::*;
1212
use otap_df_pdata::proto::opentelemetry::logs::v1::*;
1313
use otap_df_pdata::proto::opentelemetry::resource::v1::*;
14+
15+
#[cfg(not(windows))]
1416
use tikv_jemallocator::Jemalloc;
1517

18+
#[cfg(not(windows))]
1619
#[global_allocator]
1720
static GLOBAL: Jemalloc = Jemalloc;
1821

0 commit comments

Comments
 (0)