diff --git a/src/client/vfs_legacy/filesystem/dir_cache.cpp b/src/client/vfs_legacy/filesystem/dir_cache.cpp index 3b844cfc5..b879fe48a 100644 --- a/src/client/vfs_legacy/filesystem/dir_cache.cpp +++ b/src/client/vfs_legacy/filesystem/dir_cache.cpp @@ -33,6 +33,7 @@ namespace dingofs { namespace client { namespace filesystem { +using metrics::client::vfs_legacy::DirCacheMetric; using utils::ReadLockGuard; using utils::RWLock; using utils::TimeSpec; diff --git a/src/client/vfs_legacy/filesystem/dir_cache.h b/src/client/vfs_legacy/filesystem/dir_cache.h index a0b87b5c2..ba20e19ce 100644 --- a/src/client/vfs_legacy/filesystem/dir_cache.h +++ b/src/client/vfs_legacy/filesystem/dir_cache.h @@ -28,7 +28,7 @@ #include "absl/container/btree_map.h" #include "client/vfs_legacy/filesystem/meta.h" -#include "client/vfs_legacy/filesystem/metric.h" +#include "metrics/client/vfs_legacy/dir_cache.h" #include "options/client/vfs_legacy/vfs_legacy_option.h" #include "utils/concurrent/concurrent.h" #include "utils/lru_cache.h" @@ -98,7 +98,7 @@ class DirCache { DirCacheOption option_; std::shared_ptr lru_; std::shared_ptr mq_; - std::shared_ptr metric_; + std::shared_ptr metric_; }; } // namespace filesystem diff --git a/src/client/vfs_legacy/filesystem/metric.h b/src/client/vfs_legacy/filesystem/metric.h deleted file mode 100644 index d086dffd1..000000000 --- a/src/client/vfs_legacy/filesystem/metric.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: Dingofs - * Created Date: 2023-07-13 - * Author: Jingli Chen (Wine93) - */ - -#ifndef DINGOFS_SRC_CLIENT_FILESYSTEM_METRIC_H_ -#define DINGOFS_SRC_CLIENT_FILESYSTEM_METRIC_H_ - -#include - -#include - -namespace dingofs { -namespace client { -namespace filesystem { - -class DirCacheMetric { - public: - DirCacheMetric() = default; - - void AddEntries(int64_t n) { metric_.nentries << n; } - - private: - struct Metric { - Metric() : nentries("filesystem_dircache", "nentries") {} - bvar::Adder nentries; - }; - - Metric metric_; -}; - -class OpenfilesMetric { - public: - OpenfilesMetric() = default; - - void AddOpenfiles(int64_t n) { metric_.nfiles << n; } - - private: - struct Metric { - Metric() : nfiles("filesystem_openfiles", "nfiles") {} - bvar::Adder nfiles; - }; - - Metric metric_; -}; - -} // namespace filesystem -} // namespace client -} // namespace dingofs - -#endif // DINGOFS_SRC_CLIENT_FILESYSTEM_METRIC_H_ diff --git a/src/client/vfs_legacy/filesystem/openfile.cpp b/src/client/vfs_legacy/filesystem/openfile.cpp index 1c2c5b3a4..3fe37bd77 100644 --- a/src/client/vfs_legacy/filesystem/openfile.cpp +++ b/src/client/vfs_legacy/filesystem/openfile.cpp @@ -32,6 +32,7 @@ namespace dingofs { namespace client { namespace filesystem { +using metrics::client::vfs_legacy::OpenfilesMetric; using utils::ReadLockGuard; using utils::WriteLockGuard; diff --git a/src/client/vfs_legacy/filesystem/openfile.h b/src/client/vfs_legacy/filesystem/openfile.h index e031719de..dbee5b459 100644 --- a/src/client/vfs_legacy/filesystem/openfile.h +++ b/src/client/vfs_legacy/filesystem/openfile.h @@ -28,8 +28,8 @@ #include "client/vfs_legacy/filesystem/defer_sync.h" #include "client/vfs_legacy/filesystem/meta.h" -#include "client/vfs_legacy/filesystem/metric.h" #include "client/vfs_legacy/inode_wrapper.h" +#include "metrics/client/vfs_legacy/open_files.h" #include "options/client/vfs_legacy/vfs_legacy_option.h" namespace dingofs { @@ -66,7 +66,7 @@ class OpenFiles { OpenFilesOption option_; std::shared_ptr deferSync_; std::unordered_map> files_; - std::shared_ptr metric_; + std::shared_ptr metric_; }; } // namespace filesystem diff --git a/src/metrics/client/vfs_legacy/dir_cache.h b/src/metrics/client/vfs_legacy/dir_cache.h new file mode 100644 index 000000000..fc38fa673 --- /dev/null +++ b/src/metrics/client/vfs_legacy/dir_cache.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 dingodb.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_ +#define DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_ + +#include + +namespace dingofs { +namespace metrics { +namespace client { +namespace vfs_legacy { + +class DirCacheMetric { + public: + DirCacheMetric() = default; + + void AddEntries(int64_t n) { metric_.nentries << n; } + + private: + struct Metric { + Metric() : nentries("filesystem_dircache", "nentries") {} + bvar::Adder nentries; + }; + + Metric metric_; +}; + +} // namespace vfs_legacy +} // namespace client +} // namespace metrics +} // namespace dingofs + +#endif // DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_ diff --git a/src/metrics/client/vfs_legacy/open_files.h b/src/metrics/client/vfs_legacy/open_files.h new file mode 100644 index 000000000..da778af51 --- /dev/null +++ b/src/metrics/client/vfs_legacy/open_files.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 dingodb.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_ +#define DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_ + +#include + +namespace dingofs { +namespace metrics { +namespace client { +namespace vfs_legacy { + +class OpenfilesMetric { + public: + OpenfilesMetric() = default; + + void AddOpenfiles(int64_t n) { metric_.nfiles << n; } + + private: + struct Metric { + Metric() : nfiles("filesystem_openfiles", "nfiles") {} + bvar::Adder nfiles; + }; + + Metric metric_; +}; + +} // namespace vfs_legacy +} // namespace client +} // namespace metrics +} // namespace dingofs + +#endif // DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_