Skip to content

Commit abf7432

Browse files
committed
added hotpath as a feature flag
1 parent c6f1355 commit abf7432

11 files changed

Lines changed: 27 additions & 24 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ tokio-stream = { version = "0.1.17", features = ["fs"] }
9191
tokio-util = { version = "0.7" }
9292

9393
# perf
94-
hotpath = { version = "0.16.0", features = [
94+
hotpath = { version = "0.16.0", optional = true, features = [
9595
"hotpath",
9696
"hotpath-cpu",
9797
"hotpath-alloc",
@@ -219,6 +219,7 @@ assets-sha1 = "a7523ef819d38678275ae165c443564b2f9a3fc1"
219219

220220
[features]
221221
debug = []
222+
hotpath = ["dep:hotpath"]
222223
kafka = [
223224
"rdkafka",
224225
"rdkafka/ssl-vendored",

src/event/format/json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl EventFormat for Event {
6060

6161
// convert the incoming json to a vector of json values
6262
// also extract the arrow schema, tags and metadata from the incoming json
63-
#[hotpath::measure]
63+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
6464
fn to_data(
6565
self,
6666
schema: &HashMap<String, Arc<Field>>,

src/event/format/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub trait EventFormat: Sized {
162162
/// Returns the UTC time at ingestion
163163
fn get_p_timestamp(&self) -> DateTime<Utc>;
164164

165-
#[hotpath::measure]
165+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
166166
fn into_recordbatch(
167167
self,
168168
storage_schema: &HashMap<String, Arc<Field>>,

src/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Event {
7272
is_first_event = self.is_first_event
7373
)
7474
)]
75-
#[hotpath::measure]
75+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
7676
pub fn process(self) -> Result<(), EventError> {
7777
let mut key = get_schema_key(&self.rb.schema().fields);
7878
if self.time_partition.is_some() {

src/handlers/http/modal/utils/ingest_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub async fn flatten_and_push_logs(
156156
skip(json, log_source, p_custom_fields, time_partition, telemetry_type, tenant_id),
157157
fields(stream_name, record_count = tracing::field::Empty)
158158
)]
159-
#[hotpath::measure]
159+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
160160
pub fn push_logs(
161161
stream_name: &str,
162162
json: Value,

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ pub use datafusion;
6262
pub use handlers::http::modal::{
6363
ParseableServer, ingest_server::IngestServer, query_server::QueryServer, server::Server,
6464
};
65+
#[cfg(feature = "hotpath")]
66+
pub use hotpath;
6567
use once_cell::sync::Lazy;
6668
pub use openid;
6769
use parseable::PARSEABLE;
6870
use reqwest::{Client, ClientBuilder};
69-
pub use {hotpath, tracing_actix_web, tracing_opentelemetry, tracing_subscriber};
7071
pub use {opentelemetry, opentelemetry_otlp, opentelemetry_proto, opentelemetry_sdk};
72+
pub use {tracing_actix_web, tracing_opentelemetry, tracing_subscriber};
7173

7274
// It is very unlikely that panic will occur when dealing with locks.
7375
pub const LOCK_EXPECT: &str = "Thread shouldn't panic while holding a lock";

src/otel/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fn process_resource_metrics<T, S, M>(
608608

609609
/// this function performs the custom flattening of the otel metrics
610610
/// and returns a `Vec` of `Value::Object` of the flattened json
611-
#[hotpath::measure]
611+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
612612
pub fn flatten_otel_metrics(message: MetricsData, tenant_id: &str) -> Vec<Value> {
613613
process_resource_metrics(
614614
&message.resource_metrics,

src/parseable/staging/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Writer {
5151
}
5252

5353
impl Writer {
54-
#[hotpath::measure]
54+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
5555
pub fn push_disk(
5656
&mut self,
5757
filename: String,
@@ -204,7 +204,7 @@ impl DiskWriter {
204204
}
205205

206206
/// Write a single recordbatch into file
207-
#[hotpath::measure]
207+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
208208
pub fn write(&mut self, rb: &RecordBatch) -> Result<(), StagingError> {
209209
self.inner.write(rb).map_err(StagingError::Arrow)
210210
}

src/parseable/streams.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl Stream {
139139
}
140140

141141
// Concatenates record batches and puts them in memory store for each event.
142-
#[hotpath::measure]
142+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
143143
pub fn push(
144144
&self,
145145
schema_key: &str,
@@ -409,7 +409,7 @@ impl Stream {
409409
base.join(format!("{INPROCESS_DIR_PREFIX}{minute}"))
410410
}
411411

412-
#[hotpath::measure]
412+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
413413
pub fn parquet_files(&self) -> Vec<PathBuf> {
414414
let Ok(dir) = self.data_path.read_dir() else {
415415
return vec![];
@@ -470,7 +470,7 @@ impl Stream {
470470
skip(self, tenant_id),
471471
fields(stream_name = %self.stream_name)
472472
)]
473-
#[hotpath::measure]
473+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
474474
pub fn prepare_parquet(
475475
&self,
476476
init_signal: bool,
@@ -550,7 +550,7 @@ impl Stream {
550550
Ok(())
551551
}
552552

553-
#[hotpath::measure]
553+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
554554
pub fn flush(&self, forced: bool) -> Result<(), StagingError> {
555555
let _span = info_span!("flush", stream_name = %self.stream_name, forced).entered();
556556
// Swap out stale writers under the lock, drop them after releasing it.
@@ -652,7 +652,7 @@ impl Stream {
652652
/// Bails out without sorting when either source column is missing
653653
/// (non-metric stream, schema drift) so the caller can write the
654654
/// batch unchanged.
655-
#[hotpath::measure]
655+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
656656
fn sort_batch_for_metric_pruning(
657657
batch: &RecordBatch,
658658
time_partition_field: &str,
@@ -694,7 +694,7 @@ impl Stream {
694694
Ok(RecordBatch::try_new(schema, columns)?)
695695
}
696696

697-
#[hotpath::measure]
697+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
698698
fn prepare_metric_row_group(
699699
schema: Arc<Schema>,
700700
buffer: Vec<RecordBatch>,
@@ -772,7 +772,7 @@ impl Stream {
772772
/// This function reads arrow files, groups their schemas
773773
///
774774
/// converts them into parquet files and returns a merged schema
775-
#[hotpath::measure]
775+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
776776
pub fn convert_disk_files_to_parquet(
777777
&self,
778778
time_partition: Option<&String>,
@@ -836,7 +836,7 @@ impl Stream {
836836
Ok(Some(Schema::try_merge(schemas)?))
837837
}
838838

839-
#[hotpath::measure]
839+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
840840
fn write_parquet_part_file(
841841
&self,
842842
part_path: &Path,
@@ -941,7 +941,7 @@ impl Stream {
941941
}
942942

943943
/// function to validate parquet files
944-
#[hotpath::measure]
944+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
945945
fn is_valid_parquet_file(path: &Path, stream_name: &str) -> bool {
946946
// First check file size as a quick validation
947947
match path.metadata() {
@@ -984,7 +984,7 @@ impl Stream {
984984
}
985985
}
986986

987-
#[hotpath::measure]
987+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
988988
fn cleanup_arrow_files_and_dir(&self, arrow_files: &[PathBuf], tenant_id: &Option<String>) {
989989
let tenant_str = tenant_id.as_deref().unwrap_or(DEFAULT_TENANT);
990990
for (i, file) in arrow_files.iter().enumerate() {
@@ -1368,7 +1368,7 @@ impl Stream {
13681368
skip(self, tenant_id),
13691369
fields(stream_name = %self.stream_name)
13701370
)]
1371-
#[hotpath::measure]
1371+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
13721372
pub fn flush_and_convert(
13731373
&self,
13741374
init_signal: bool,

src/utils/json/flatten.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub enum JsonFlattenError {
6363

6464
// Recursively flattens JSON objects and arrays, e.g. with the separator `.`, starting from the TOP
6565
// `{"key": "value", "nested_key": {"key":"value"}}` becomes `{"key": "value", "nested_key.key": "value"}`
66-
#[hotpath::measure]
66+
#[cfg_attr(feature = "hotpath", hotpath::measure)]
6767
pub fn flatten(
6868
nested_value: &mut Value,
6969
separator: &str,

0 commit comments

Comments
 (0)