Skip to content

Commit 61959d5

Browse files
meilirensheng2020rock-git
authored andcommitted
[refact][metrics] Move some vfs_legacy metrics to metrics directory
1 parent fe92a79 commit 61959d5

File tree

7 files changed

+100
-72
lines changed

7 files changed

+100
-72
lines changed

src/client/vfs_legacy/filesystem/dir_cache.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace dingofs {
3333
namespace client {
3434
namespace filesystem {
3535

36+
using metrics::client::vfs_legacy::DirCacheMetric;
3637
using utils::ReadLockGuard;
3738
using utils::RWLock;
3839
using utils::TimeSpec;

src/client/vfs_legacy/filesystem/dir_cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "absl/container/btree_map.h"
3030
#include "client/vfs_legacy/filesystem/meta.h"
31-
#include "client/vfs_legacy/filesystem/metric.h"
31+
#include "metrics/client/vfs_legacy/dir_cache.h"
3232
#include "options/client/vfs_legacy/vfs_legacy_option.h"
3333
#include "utils/concurrent/concurrent.h"
3434
#include "utils/lru_cache.h"
@@ -98,7 +98,7 @@ class DirCache {
9898
DirCacheOption option_;
9999
std::shared_ptr<LRUType> lru_;
100100
std::shared_ptr<MessageQueueType> mq_;
101-
std::shared_ptr<DirCacheMetric> metric_;
101+
std::shared_ptr<metrics::client::vfs_legacy::DirCacheMetric> metric_;
102102
};
103103

104104
} // namespace filesystem

src/client/vfs_legacy/filesystem/metric.h

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/client/vfs_legacy/filesystem/openfile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace dingofs {
3232
namespace client {
3333
namespace filesystem {
3434

35+
using metrics::client::vfs_legacy::OpenfilesMetric;
3536
using utils::ReadLockGuard;
3637
using utils::WriteLockGuard;
3738

src/client/vfs_legacy/filesystem/openfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
#include "client/vfs_legacy/filesystem/defer_sync.h"
3030
#include "client/vfs_legacy/filesystem/meta.h"
31-
#include "client/vfs_legacy/filesystem/metric.h"
3231
#include "client/vfs_legacy/inode_wrapper.h"
32+
#include "metrics/client/vfs_legacy/open_files.h"
3333
#include "options/client/vfs_legacy/vfs_legacy_option.h"
3434

3535
namespace dingofs {
@@ -66,7 +66,7 @@ class OpenFiles {
6666
OpenFilesOption option_;
6767
std::shared_ptr<DeferSync> deferSync_;
6868
std::unordered_map<Ino, std::unique_ptr<OpenFile>> files_;
69-
std::shared_ptr<OpenfilesMetric> metric_;
69+
std::shared_ptr<metrics::client::vfs_legacy::OpenfilesMetric> metric_;
7070
};
7171

7272
} // namespace filesystem
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2025 dingodb.com, Inc. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_
18+
#define DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_
19+
20+
#include <bvar/bvar.h>
21+
22+
namespace dingofs {
23+
namespace metrics {
24+
namespace client {
25+
namespace vfs_legacy {
26+
27+
class DirCacheMetric {
28+
public:
29+
DirCacheMetric() = default;
30+
31+
void AddEntries(int64_t n) { metric_.nentries << n; }
32+
33+
private:
34+
struct Metric {
35+
Metric() : nentries("filesystem_dircache", "nentries") {}
36+
bvar::Adder<int64_t> nentries;
37+
};
38+
39+
Metric metric_;
40+
};
41+
42+
} // namespace vfs_legacy
43+
} // namespace client
44+
} // namespace metrics
45+
} // namespace dingofs
46+
47+
#endif // DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_DIR_CACHE_H_
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2025 dingodb.com, Inc. All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_
18+
#define DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_
19+
20+
#include <bvar/bvar.h>
21+
22+
namespace dingofs {
23+
namespace metrics {
24+
namespace client {
25+
namespace vfs_legacy {
26+
27+
class OpenfilesMetric {
28+
public:
29+
OpenfilesMetric() = default;
30+
31+
void AddOpenfiles(int64_t n) { metric_.nfiles << n; }
32+
33+
private:
34+
struct Metric {
35+
Metric() : nfiles("filesystem_openfiles", "nfiles") {}
36+
bvar::Adder<int64_t> nfiles;
37+
};
38+
39+
Metric metric_;
40+
};
41+
42+
} // namespace vfs_legacy
43+
} // namespace client
44+
} // namespace metrics
45+
} // namespace dingofs
46+
47+
#endif // DINGOFS_SRC_METRICS_CLIENT_VFS_LEGACY_OPEN_FILES_H_

0 commit comments

Comments
 (0)