Skip to content

Commit

Permalink
feat: add more span on mito engine
Browse files Browse the repository at this point in the history
  • Loading branch information
lyang24 committed Aug 29, 2024
1 parent 5e4bac2 commit f39529f
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/mito2/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::time::Duration;

use api::v1::OpType;
use async_trait::async_trait;
use common_telemetry::tracing;
use common_time::Timestamp;
use datafusion_common::arrow::array::UInt8Array;
use datatypes::arrow;
Expand Down Expand Up @@ -727,6 +728,7 @@ pub type BoxedBatchStream = BoxStream<'static, Result<Batch>>;

#[async_trait::async_trait]
impl<T: BatchReader + ?Sized> BatchReader for Box<T> {
#[tracing::instrument(skip_all)]
async fn next_batch(&mut self) -> Result<Option<Batch>> {
(**self).next_batch().await
}
Expand Down
4 changes: 3 additions & 1 deletion src/mito2/src/read/scan_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::time::{Duration, Instant};

use common_error::ext::BoxedError;
use common_recordbatch::SendableRecordBatchStream;
use common_telemetry::{debug, error, warn};
use common_telemetry::{debug, error, tracing, warn};
use common_time::range::TimestampRange;
use common_time::Timestamp;
use datafusion::physical_plan::DisplayFormatType;
Expand Down Expand Up @@ -62,6 +62,7 @@ pub(crate) enum Scanner {

impl Scanner {
/// Returns a [SendableRecordBatchStream] to retrieve scan results from all partitions.
#[tracing::instrument(skip_all)]
pub(crate) async fn scan(&self) -> Result<SendableRecordBatchStream, BoxedError> {
match self {
Scanner::Seq(seq_scan) => seq_scan.build_stream(),
Expand All @@ -70,6 +71,7 @@ impl Scanner {
}

/// Returns a [RegionScanner] to scan the region.
#[tracing::instrument(skip_all)]
pub(crate) async fn region_scanner(self) -> Result<RegionScannerRef> {
match self {
Scanner::Seq(seq_scan) => Ok(Box::new(seq_scan)),
Expand Down
6 changes: 5 additions & 1 deletion src/mito2/src/read/seq_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use common_error::ext::BoxedError;
use common_recordbatch::error::ExternalSnafu;
use common_recordbatch::util::ChainedRecordBatchStream;
use common_recordbatch::{RecordBatchStreamWrapper, SendableRecordBatchStream};
use common_telemetry::debug;
use common_telemetry::{debug, tracing};
use datafusion::physical_plan::{DisplayAs, DisplayFormatType};
use datatypes::schema::SchemaRef;
use smallvec::smallvec;
Expand Down Expand Up @@ -119,6 +119,7 @@ impl SeqScan {
}

/// Builds sources from a [ScanPart].
#[tracing::instrument(skip(part, sources, row_selector))]
fn build_part_sources(
part: &ScanPart,
sources: &mut Vec<Source>,
Expand Down Expand Up @@ -204,6 +205,7 @@ impl SeqScan {
/// Builds a merge reader that reads data from one [`PartitionRange`].
///
/// If the `range_id` is out of bound, returns None.
#[tracing::instrument(skip_all)]
async fn build_merge_reader(
stream_ctx: &StreamContext,
range_id: usize,
Expand Down Expand Up @@ -244,6 +246,7 @@ impl SeqScan {
maybe_reader
}

#[tracing::instrument(skip_all)]
async fn build_reader_from_sources(
stream_ctx: &StreamContext,
mut sources: Vec<Source>,
Expand Down Expand Up @@ -500,6 +503,7 @@ impl RegionScanner for SeqScan {
self.stream_ctx.input.mapper.output_schema()
}

#[tracing::instrument(skip_all)]
fn scan_partition(&self, partition: usize) -> Result<SendableRecordBatchStream, BoxedError> {
self.uncached_scan_part_impl(partition)
}
Expand Down
3 changes: 3 additions & 0 deletions src/mito2/src/sst/index/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};

use common_telemetry::tracing;
use futures::{AsyncRead, AsyncSeek, AsyncWrite};
use object_store::ObjectStore;
use pin_project::pin_project;
Expand Down Expand Up @@ -54,6 +55,7 @@ impl InstrumentedStore {
/// Returns an [`InstrumentedAsyncRead`] for the given path.
/// Metrics like the number of bytes read, read and seek operations
/// are recorded using the provided `IntCounter`s.
#[tracing::instrument(skip_all)]
pub async fn reader<'a>(
&self,
path: &str,
Expand Down Expand Up @@ -81,6 +83,7 @@ impl InstrumentedStore {
/// Returns an [`InstrumentedAsyncWrite`] for the given path.
/// Metrics like the number of bytes written, write and flush operations
/// are recorded using the provided `IntCounter`s.
#[tracing::instrument(skip_all)]
pub async fn writer<'a>(
&self,
path: &str,
Expand Down
3 changes: 2 additions & 1 deletion src/mito2/src/sst/parquet/file_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::ops::BitAnd;
use std::sync::Arc;

use api::v1::{OpType, SemanticType};
use common_telemetry::error;
use common_telemetry::{error, tracing};
use datatypes::arrow::array::BooleanArray;
use datatypes::arrow::buffer::BooleanBuffer;
use parquet::arrow::arrow_reader::RowSelection;
Expand Down Expand Up @@ -80,6 +80,7 @@ impl FileRange {
}

/// Returns a reader to read the [FileRange].
#[tracing::instrument(skip_all)]
pub(crate) async fn reader(
&self,
selector: Option<TimeSeriesRowSelector>,
Expand Down
6 changes: 5 additions & 1 deletion src/mito2/src/sst/parquet/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::time::{Duration, Instant};
use api::v1::SemanticType;
use async_trait::async_trait;
use common_recordbatch::filter::SimpleFilterEvaluator;
use common_telemetry::{debug, warn};
use common_telemetry::{debug, tracing, warn};
use common_time::range::TimestampRange;
use common_time::timestamp::TimeUnit;
use common_time::Timestamp;
Expand Down Expand Up @@ -173,6 +173,7 @@ impl ParquetReaderBuilder {
/// Builds a [ParquetReader].
///
/// This needs to perform IO operation.
#[tracing::instrument(skip_all)]
pub async fn build(&self) -> Result<ParquetReader> {
let mut metrics = ReaderMetrics::default();

Expand All @@ -183,6 +184,7 @@ impl ParquetReaderBuilder {
/// Builds a [FileRangeContext] and collects row groups to read.
///
/// This needs to perform IO operation.
#[tracing::instrument(skip_all)]
pub(crate) async fn build_reader_input(
&self,
metrics: &mut ReaderMetrics,
Expand Down Expand Up @@ -273,6 +275,7 @@ impl ParquetReaderBuilder {
}

/// Decodes region metadata from key value.
#[tracing::instrument(skip_all)]
fn get_region_metadata(
file_path: &str,
key_value_meta: Option<&Vec<KeyValue>>,
Expand Down Expand Up @@ -300,6 +303,7 @@ impl ParquetReaderBuilder {
}

/// Reads parquet metadata of specific file.
#[tracing::instrument(skip_all)]
async fn read_parquet_metadata(
&self,
file_path: &str,
Expand Down
2 changes: 2 additions & 0 deletions src/mito2/src/sst/parquet/row_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::ops::Range;
use std::sync::Arc;

use bytes::{Buf, Bytes};
use common_telemetry::tracing;
use object_store::ObjectStore;
use parquet::arrow::arrow_reader::{RowGroups, RowSelection};
use parquet::arrow::ProjectionMask;
Expand Down Expand Up @@ -93,6 +94,7 @@ impl<'a> InMemoryRowGroup<'a> {
}

/// Fetches the necessary column data into memory
#[tracing::instrument(skip_all)]
pub async fn fetch(
&mut self,
projection: &ProjectionMask,
Expand Down
3 changes: 3 additions & 0 deletions src/mito2/src/sst/parquet/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::task::{Context, Poll};

use common_telemetry::tracing;
use common_time::Timestamp;
use datatypes::arrow::datatypes::SchemaRef;
use object_store::{FuturesAsyncWriter, ObjectStore};
Expand Down Expand Up @@ -65,6 +66,7 @@ pub struct ObjectStoreWriterFactory {
impl WriterFactory for ObjectStoreWriterFactory {
type Writer = Compat<FuturesAsyncWriter>;

#[tracing::instrument(skip_all)]
async fn create(&mut self) -> Result<Self::Writer> {
self.object_store
.writer_with(&self.path)
Expand Down Expand Up @@ -109,6 +111,7 @@ where
/// Iterates source and writes all rows to Parquet file.
///
/// Returns the [SstInfo] if the SST is written.
#[tracing::instrument(skip_all)]
pub async fn write_all(
&mut self,
mut source: Source,
Expand Down
2 changes: 2 additions & 0 deletions src/mito2/src/worker/handle_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::collections::{hash_map, HashMap};
use std::sync::Arc;

use api::v1::OpType;
use common_telemetry::tracing;
use snafu::ensure;
use store_api::logstore::LogStore;
use store_api::metadata::RegionMetadata;
Expand All @@ -31,6 +32,7 @@ use crate::worker::RegionWorkerLoop;

impl<S: LogStore> RegionWorkerLoop<S> {
/// Takes and handles all write requests.
#[tracing::instrument(skip_all)]
pub(crate) async fn handle_write_requests(
&mut self,
mut write_requests: Vec<SenderWriteRequest>,
Expand Down

0 comments on commit f39529f

Please sign in to comment.