Skip to content

[refact][metrics] Move some vfs_legacy metrics to metrics directory #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/client/vfs_legacy/filesystem/dir_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/client/vfs_legacy/filesystem/dir_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -98,7 +98,7 @@ class DirCache {
DirCacheOption option_;
std::shared_ptr<LRUType> lru_;
std::shared_ptr<MessageQueueType> mq_;
std::shared_ptr<DirCacheMetric> metric_;
std::shared_ptr<metrics::client::vfs_legacy::DirCacheMetric> metric_;
};

} // namespace filesystem
Expand Down
68 changes: 0 additions & 68 deletions src/client/vfs_legacy/filesystem/metric.h

This file was deleted.

1 change: 1 addition & 0 deletions src/client/vfs_legacy/filesystem/openfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace dingofs {
namespace client {
namespace filesystem {

using metrics::client::vfs_legacy::OpenfilesMetric;
using utils::ReadLockGuard;
using utils::WriteLockGuard;

Expand Down
4 changes: 2 additions & 2 deletions src/client/vfs_legacy/filesystem/openfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -66,7 +66,7 @@ class OpenFiles {
OpenFilesOption option_;
std::shared_ptr<DeferSync> deferSync_;
std::unordered_map<Ino, std::unique_ptr<OpenFile>> files_;
std::shared_ptr<OpenfilesMetric> metric_;
std::shared_ptr<metrics::client::vfs_legacy::OpenfilesMetric> metric_;
};

} // namespace filesystem
Expand Down
47 changes: 47 additions & 0 deletions src/metrics/client/vfs_legacy/dir_cache.h
Original file line number Diff line number Diff line change
@@ -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 <bvar/bvar.h>

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<int64_t> nentries;
};

Metric metric_;
};

} // namespace vfs_legacy
} // namespace client
} // namespace metrics
} // namespace dingofs

#endif // DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_
47 changes: 47 additions & 0 deletions src/metrics/client/vfs_legacy/open_files.h
Original file line number Diff line number Diff line change
@@ -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 <bvar/bvar.h>

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<int64_t> nfiles;
};

Metric metric_;
};

} // namespace vfs_legacy
} // namespace client
} // namespace metrics
} // namespace dingofs

#endif // DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_