Skip to content

Commit

Permalink
chore: add manifest related metrics (#3634)
Browse files Browse the repository at this point in the history
* chore: add two manifest related metrics

* Update src/mito2/src/manifest/manager.rs

Co-authored-by: Yingwen <[email protected]>

* Update src/mito2/src/metrics.rs

Co-authored-by: Yingwen <[email protected]>

* fix: resolve PR comments

* update cargo lock

---------

Co-authored-by: Yingwen <[email protected]>
  • Loading branch information
MichaelScofield and evenyag authored Apr 8, 2024
1 parent 87e0189 commit aa0af61
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
19 changes: 6 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/mito2/src/manifest/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ use snafu::{OptionExt, ResultExt};
use store_api::manifest::ManifestVersion;
use store_api::metadata::RegionMetadataRef;
use store_api::storage::{RegionId, SequenceNumber};
use strum::Display;

use crate::error::{RegionMetadataNotFoundSnafu, Result, SerdeJsonSnafu, Utf8Snafu};
use crate::sst::file::{FileId, FileMeta};
use crate::wal::EntryId;

/// Actions that can be applied to region manifest.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Display)]
pub enum RegionMetaAction {
/// Change region's metadata for request like ALTER
Change(RegionChange),
Expand Down
13 changes: 13 additions & 0 deletions src/mito2/src/manifest/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::manifest::action::{
RegionMetaActionList,
};
use crate::manifest::storage::{file_version, is_delta_file, ManifestObjectStore};
use crate::metrics::MANIFEST_OP_ELAPSED;

/// Options for [RegionManifestManager].
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -141,6 +142,10 @@ impl RegionManifestManager {

/// Update the manifest. Return the current manifest version number.
pub async fn update(&self, action_list: RegionMetaActionList) -> Result<ManifestVersion> {
let _t = MANIFEST_OP_ELAPSED
.with_label_values(&["update"])
.start_timer();

let mut inner = self.inner.write().await;
inner.update(action_list).await
}
Expand Down Expand Up @@ -245,6 +250,10 @@ impl RegionManifestManagerInner {
///
/// Returns `Ok(None)` if no such manifest.
async fn open(options: RegionManifestOptions) -> Result<Option<Self>> {
let _t = MANIFEST_OP_ELAPSED
.with_label_values(&["open"])
.start_timer();

// construct storage
let mut store = ManifestObjectStore::new(
&options.manifest_dir,
Expand Down Expand Up @@ -395,6 +404,10 @@ impl RegionManifestManagerInner {

/// Makes a new checkpoint. Return the fresh one if there are some actions to compact.
async fn do_checkpoint(&mut self) -> Result<Option<RegionCheckpoint>> {
let _t = MANIFEST_OP_ELAPSED
.with_label_values(&["checkpoint"])
.start_timer();

let last_checkpoint = Self::last_checkpoint(&mut self.store).await?;
let current_version = self.last_version;

Expand Down
10 changes: 10 additions & 0 deletions src/mito2/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,14 @@ lazy_static! {
.unwrap();

// ------- End of partition tree memtable metrics.


// Manifest related metrics:

/// Elapsed time of manifest operation. Labeled with "op".
pub static ref MANIFEST_OP_ELAPSED: HistogramVec = register_histogram_vec!(
"greptime_manifest_op_elapsed",
"mito manifest operation elapsed",
&["op"]
).unwrap();
}

0 comments on commit aa0af61

Please sign in to comment.