File tree Expand file tree Collapse file tree 4 files changed +58
-0
lines changed
Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 3838 </providers >
3939 </activity >
4040
41+ <openmetrics >
42+ <exporter >OCA\Comments\OpenMetrics\Comments</exporter >
43+ </openmetrics >
44+
4145 <collaboration >
4246 <plugins >
4347 <plugin type =" autocomplete-sort" >OCA\Comments\Collaboration\CommentersSorter</plugin >
Original file line number Diff line number Diff line change 2222 'OCA \\Comments \\MaxAutoCompleteResultsInitialState ' => $ baseDir . '/../lib/MaxAutoCompleteResultsInitialState.php ' ,
2323 'OCA \\Comments \\Notification \\Listener ' => $ baseDir . '/../lib/Notification/Listener.php ' ,
2424 'OCA \\Comments \\Notification \\Notifier ' => $ baseDir . '/../lib/Notification/Notifier.php ' ,
25+ 'OCA \\Comments \\OpenMetrics \\Comments ' => $ baseDir . '/../lib/OpenMetrics/Comments.php ' ,
2526 'OCA \\Comments \\Search \\CommentsSearchProvider ' => $ baseDir . '/../lib/Search/CommentsSearchProvider.php ' ,
2627);
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ class ComposerStaticInitComments
3737 'OCA \\Comments \\MaxAutoCompleteResultsInitialState ' => __DIR__ . '/.. ' . '/../lib/MaxAutoCompleteResultsInitialState.php ' ,
3838 'OCA \\Comments \\Notification \\Listener ' => __DIR__ . '/.. ' . '/../lib/Notification/Listener.php ' ,
3939 'OCA \\Comments \\Notification \\Notifier ' => __DIR__ . '/.. ' . '/../lib/Notification/Notifier.php ' ,
40+ 'OCA \\Comments \\OpenMetrics \\Comments ' => __DIR__ . '/.. ' . '/../lib/OpenMetrics/Comments.php ' ,
4041 'OCA \\Comments \\Search \\CommentsSearchProvider ' => __DIR__ . '/.. ' . '/../lib/Search/CommentsSearchProvider.php ' ,
4142 );
4243
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
5+ * SPDX-License-Identifier: AGPL-3.0-or-later
6+ */
7+ namespace OCA \Comments \OpenMetrics ;
8+
9+ use Generator ;
10+ use OC \DB \Connection ;
11+ use OCP \OpenMetrics \IMetricFamily ;
12+ use OCP \OpenMetrics \Metric ;
13+ use OCP \OpenMetrics \MetricTypes ;
14+ use Override ;
15+
16+ class Comments implements IMetricFamily {
17+ public function __construct (
18+ private Connection $ connection ,
19+ ) {
20+ }
21+
22+ #[Override]
23+ public function name (): string {
24+ return 'comments ' ;
25+ }
26+
27+ #[Override]
28+ public function type (): MetricTypes {
29+ return MetricTypes::gauge;
30+ }
31+
32+ #[Override]
33+ public function unit (): string {
34+ return 'comments ' ;
35+ }
36+
37+ #[Override]
38+ public function help (): string {
39+ return 'Comments counts ' ;
40+ }
41+
42+ #[Override]
43+ public function metrics (): Generator {
44+ $ qb = $ this ->connection ->getQueryBuilder ();
45+ $ result = $ qb ->select ($ qb ->func ()->count ())
46+ ->from ('comments ' )
47+ ->where ($ qb ->expr ()->eq ('verb ' , $ qb ->expr ()->literal ('comment ' )))
48+ ->executeQuery ();
49+
50+ yield new Metric ($ result ->fetchOne (), [], time ());
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments