Skip to content

Commit

Permalink
fix: Disable batch query metrics by default (#15993)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Fu <[email protected]>
  • Loading branch information
liurenjie1024 and fuyufjh authored Mar 28, 2024
1 parent af11697 commit 2de20e2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
47 changes: 28 additions & 19 deletions src/batch/src/task/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;

use risingwave_common::catalog::SysCatalogReaderRef;
use risingwave_common::config::BatchConfig;
use risingwave_common::config::{BatchConfig, MetricLevel};
use risingwave_common::memory::MemoryContext;
use risingwave_common::util::addr::{is_local_address, HostAddr};
use risingwave_connector::source::monitor::SourceMetrics;
Expand Down Expand Up @@ -164,24 +164,33 @@ impl ComputeNodeContext {
}

pub fn new(env: BatchEnvironment, task_id: TaskId) -> Self {
let batch_mem_context = env.task_manager().memory_context_ref();

let batch_metrics = Arc::new(BatchMetricsWithTaskLabelsInner::new(
env.task_manager().metrics(),
env.task_metrics(),
env.executor_metrics(),
task_id,
));
let mem_context = MemoryContext::new(
Some(batch_mem_context),
batch_metrics.task_mem_usage.clone(),
);
Self {
env,
batch_metrics: Some(batch_metrics),
cur_mem_val: Arc::new(0.into()),
last_mem_val: Arc::new(0.into()),
mem_context,
if env.metric_level() >= MetricLevel::Debug {
let batch_mem_context = env.task_manager().memory_context_ref();
let batch_metrics = Arc::new(BatchMetricsWithTaskLabelsInner::new(
env.task_manager().metrics(),
env.task_metrics(),
env.executor_metrics(),
task_id,
));
let mem_context = MemoryContext::new(
Some(batch_mem_context),
batch_metrics.task_mem_usage.clone(),
);
Self {
env,
batch_metrics: Some(batch_metrics),
cur_mem_val: Arc::new(0.into()),
last_mem_val: Arc::new(0.into()),
mem_context,
}
} else {
Self {
env,
batch_metrics: None,
cur_mem_val: Arc::new(0.into()),
last_mem_val: Arc::new(0.into()),
mem_context: MemoryContext::none(),
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/batch/src/task/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use std::sync::Arc;

use risingwave_common::config::BatchConfig;
use risingwave_common::config::{BatchConfig, MetricLevel};
use risingwave_common::util::addr::HostAddr;
use risingwave_common::util::worker_util::WorkerNodeId;
use risingwave_connector::source::monitor::SourceMetrics;
Expand Down Expand Up @@ -58,6 +58,8 @@ pub struct BatchEnvironment {

/// Metrics for source.
source_metrics: Arc<SourceMetrics>,

metric_level: MetricLevel,
}

impl BatchEnvironment {
Expand All @@ -73,6 +75,7 @@ impl BatchEnvironment {
client_pool: ComputeClientPoolRef,
dml_manager: DmlManagerRef,
source_metrics: Arc<SourceMetrics>,
metric_level: MetricLevel,
) -> Self {
BatchEnvironment {
server_addr,
Expand All @@ -85,6 +88,7 @@ impl BatchEnvironment {
client_pool,
dml_manager,
source_metrics,
metric_level,
}
}

Expand All @@ -111,6 +115,7 @@ impl BatchEnvironment {
dml_manager: Arc::new(DmlManager::for_test()),
source_metrics: Arc::new(SourceMetrics::default()),
executor_metrics: Arc::new(BatchExecutorMetrics::for_test()),
metric_level: MetricLevel::Debug,
}
}

Expand Down Expand Up @@ -157,4 +162,8 @@ impl BatchEnvironment {
pub fn source_metrics(&self) -> Arc<SourceMetrics> {
self.source_metrics.clone()
}

pub fn metric_level(&self) -> MetricLevel {
self.metric_level
}
}
1 change: 1 addition & 0 deletions src/compute/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ pub async fn compute_node_serve(
client_pool,
dml_mgr.clone(),
source_metrics.clone(),
config.server.metrics_level,
);

info!(
Expand Down

0 comments on commit 2de20e2

Please sign in to comment.