mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-26 01:40:36 +00:00
chore: add manifest related metrics (#3634)
* chore: add two manifest related metrics * Update src/mito2/src/manifest/manager.rs Co-authored-by: Yingwen <realevenyag@gmail.com> * Update src/mito2/src/metrics.rs Co-authored-by: Yingwen <realevenyag@gmail.com> * fix: resolve PR comments * update cargo lock --------- Co-authored-by: Yingwen <realevenyag@gmail.com>
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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)]
|
||||
@@ -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
|
||||
}
|
||||
@@ -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,
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user