Skip to content
Permalink
Browse files
metrics: add library
Reviewed-by: erikj
  • Loading branch information
edvbld committed May 12, 2021
1 parent 3ec0893 commit 537acafcd3cfd453b909edea154fe283d8d5e628
Showing with 1,279 additions and 0 deletions.
  1. +1 −0 bot/build.gradle
  2. 0 bot/src/main/java/org/openjdk/skara/bot/{RestReceiver.java → WebhookHandler.java}
  3. +1 −0 bots/bridgekeeper/build.gradle
  4. +1 −0 bots/censussync/build.gradle
  5. +1 −0 bots/checkout/build.gradle
  6. +1 −0 bots/cli/build.gradle
  7. +1 −0 bots/csr/build.gradle
  8. +1 −0 bots/forward/build.gradle
  9. +1 −0 bots/hgbridge/build.gradle
  10. +1 −0 bots/merge/build.gradle
  11. +1 −0 bots/mirror/build.gradle
  12. +1 −0 bots/mlbridge/build.gradle
  13. +1 −0 bots/notify/build.gradle
  14. +1 −0 bots/pr/build.gradle
  15. +1 −0 bots/submit/build.gradle
  16. +1 −0 bots/synclabel/build.gradle
  17. +1 −0 bots/tester/build.gradle
  18. +1 −0 bots/testinfo/build.gradle
  19. +1 −0 bots/topological/build.gradle
  20. +38 −0 metrics/build.gradle
  21. +26 −0 metrics/src/main/java/module-info.java
  22. +29 −0 metrics/src/main/java/org/openjdk/skara/metrics/Collector.java
  23. +52 −0 metrics/src/main/java/org/openjdk/skara/metrics/CollectorRegistry.java
  24. +291 −0 metrics/src/main/java/org/openjdk/skara/metrics/Counter.java
  25. +325 −0 metrics/src/main/java/org/openjdk/skara/metrics/Gauge.java
  26. +96 −0 metrics/src/main/java/org/openjdk/skara/metrics/Metric.java
  27. +53 −0 metrics/src/test/java/org/openjdk/skara/metrics/CollectorRegistryTests.java
  28. +155 −0 metrics/src/test/java/org/openjdk/skara/metrics/CounterTests.java
  29. +181 −0 metrics/src/test/java/org/openjdk/skara/metrics/GaugeTests.java
  30. +1 −0 network/build.gradle
  31. +1 −0 network/src/main/java/module-info.java
  32. +11 −0 network/src/main/java/org/openjdk/skara/network/RestRequest.java
  33. +1 −0 settings.gradle
  34. +1 −0 test/build.gradle
@@ -38,6 +38,7 @@ dependencies {
implementation project(':vcs')
implementation project(':json')
implementation project(':census')
implementation project(':metrics')
}

publishing {
@@ -40,6 +40,7 @@ dependencies {
implementation project(':census')
implementation project(':json')
implementation project(':vcs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -43,6 +43,7 @@ dependencies {
implementation project(':network')
implementation project(':storage')
implementation project(':xml')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -42,6 +42,7 @@ dependencies {
implementation project(':json')
implementation project(':network')
implementation project(':storage')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -68,6 +68,7 @@ dependencies {
implementation project(':args')
implementation project(':proxy')
implementation project(':version')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -39,6 +39,7 @@ dependencies {
implementation project(':ci')
implementation project(':json')
implementation project(':vcs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -39,6 +39,7 @@ dependencies {
implementation project(':census')
implementation project(':json')
implementation project(':vcs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -41,6 +41,7 @@ dependencies {
implementation project(':process')
implementation project(':json')
implementation project(':network')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -40,6 +40,7 @@ dependencies {
implementation project(':json')
implementation project(':vcs')
implementation project(':jcheck')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -39,6 +39,7 @@ dependencies {
implementation project(':census')
implementation project(':json')
implementation project(':vcs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -45,6 +45,7 @@ dependencies {
implementation project(':email')
implementation project(':webrev')
implementation project(':version')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -50,6 +50,7 @@ dependencies {
implementation project(':storage')
implementation project(':mailinglist')
implementation project(':jbs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -43,6 +43,7 @@ dependencies {
implementation project(':process')
implementation project(':json')
implementation project(':email')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -39,6 +39,7 @@ dependencies {
implementation project(':census')
implementation project(':json')
implementation project(':vcs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -43,6 +43,7 @@ dependencies {
implementation project(':network')
implementation project(':storage')
implementation project(':jbs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -41,6 +41,7 @@ dependencies {
implementation project(':json')
implementation project(':vcs')
implementation project(':jcheck')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -42,6 +42,7 @@ dependencies {
implementation project(':json')
implementation project(':network')
implementation project(':storage')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -40,6 +40,7 @@ dependencies {
implementation project(':census')
implementation project(':json')
implementation project(':vcs')
implementation project(':metrics')

testImplementation project(':test')
}
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

module {
name = 'org.openjdk.skara.metrics'
test {
requires 'org.junit.jupiter.api'
opens 'org.openjdk.skara.metrics' to 'org.junit.platform.commons'
}
}

publishing {
publications {
metrics(MavenPublication) {
from components.java
}
}
}
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
module org.openjdk.skara.metrics {
exports org.openjdk.skara.metrics;
}

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.skara.metrics;

import java.util.List;

public interface Collector {
List<Metric> collect();
}
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.skara.metrics;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;

public final class CollectorRegistry {
private static final CollectorRegistry DEFAULT = new CollectorRegistry();
private final ConcurrentLinkedQueue<Collector> collectors = new ConcurrentLinkedQueue<>();

public void register(Collector c) {
collectors.add(c);
}

public void unregister(Collector c) {
collectors.remove(c);
}

public List<Metric> scrape() {
var result = new ArrayList<Metric>();
for (var collector : collectors) {
result.addAll(collector.collect());
}
return result;
}

public static CollectorRegistry defaultRegistry() {
return DEFAULT;
}
}

1 comment on commit 537acaf

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 537acaf May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.