From 749c486e81279bfadc02091e786d197aa9387d63 Mon Sep 17 00:00:00 2001 From: Sokol Andrey <2789641+SokolAndrey@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:52:43 -0500 Subject: [PATCH 1/4] Add GitHub action to build java project Adding default configuration for Java with Gradle GitHub action --- .github/workflows/gradle.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..393133a --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: build From 7a4cdffc49071060af7f855e45a2a6e90959c1ec Mon Sep 17 00:00:00 2001 From: Andrew Mains Date: Thu, 21 Dec 2023 17:12:54 -0500 Subject: [PATCH 2/4] Upgrade gradle version to 6.9.2 (#107) * Test github actions for CI * Upgrade gradle version to 6.9.2 Notes: cant go to 7.x just yet; we have some deprecated things to fix up. Doing this step wise. Confirmed that it fails the CI --------- Co-authored-by: Sokol Andrey <2789641+SokolAndrey@users.noreply.github.com> --- .github/workflows/gradle.yml | 6 +++--- build.gradle | 11 ++++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 393133a..adb82ec 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -23,12 +23,12 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 8 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '8' distribution: 'temurin' - name: Build with Gradle - uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee with: arguments: build diff --git a/build.gradle b/build.gradle index 0ea9c04..fe8e47d 100644 --- a/build.gradle +++ b/build.gradle @@ -169,9 +169,10 @@ subprojects { ext."signing.secretKeyRingFile" = "ci/${ext.secretKeyRingFileName}" -task wrapper(type: Wrapper) { + +wrapper { // Gradle version 4+ required for JMH benchmarking, otherwise v3.5+ is sufficient - gradleVersion = '4.0' + gradleVersion = '6.9' } // -------------------------------------- @@ -183,9 +184,9 @@ coveralls { task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) { dependsOn = subprojects.test - sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs) - classDirectories = files(subprojects.sourceSets.main.output.classesDirs) - executionData = files(subprojects.jacocoTestReport.executionData) + sourceDirectories.setFrom(files(subprojects.sourceSets.main.allSource.srcDirs)) + classDirectories.setFrom(files(subprojects.sourceSets.main.output.classesDirs)) + executionData.setFrom(files(subprojects.jacocoTestReport.executionData)) reports { xml.enabled = true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index de80b9b..0161e9e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Fri Dec 25 03:30:51 CET 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists From 42a8b8183e8c0bda1dac12599cdaac861d06a899 Mon Sep 17 00:00:00 2001 From: Sokol Andrey <2789641+SokolAndrey@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:21:57 -0500 Subject: [PATCH 3/4] Release v0.14.0 (#121) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fe8e47d..27ab606 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ configurations.archives.artifacts.clear() allprojects { group = 'com.uber.m3' - version = '0.13.0' + version = '0.14.0' apply plugin: 'java' apply plugin: 'maven' From 79ef1541bd8c8268cdcaab2e9bbcd74b6aae7ecd Mon Sep 17 00:00:00 2001 From: Zameer Manji Date: Wed, 3 Jan 2024 20:28:27 -0500 Subject: [PATCH 4/4] Fix Snapshots (#122) https://github.com/uber-java/tally/pull/120 has a bug where the `Snapshot` only includes the subscopes and not the metrics on the current scope. This fixes the `snapshot` method to include metrics on the current scope as well. --- core/src/main/java/com/uber/m3/tally/ScopeImpl.java | 7 ++++++- .../src/test/java/com/uber/m3/tally/TestScopeTest.java | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/uber/m3/tally/ScopeImpl.java b/core/src/main/java/com/uber/m3/tally/ScopeImpl.java index 09e8377..6133957 100644 --- a/core/src/main/java/com/uber/m3/tally/ScopeImpl.java +++ b/core/src/main/java/com/uber/m3/tally/ScopeImpl.java @@ -23,6 +23,7 @@ import com.uber.m3.util.ImmutableMap; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.Collection; import java.util.Map; import java.util.Optional; @@ -172,7 +173,11 @@ String fullyQualifiedName(String name) { public Snapshot snapshot() { Snapshot snap = new SnapshotImpl(); - for (ScopeImpl subscope : registry.subscopes.values()) { + ArrayList scopes = new ArrayList<>(); + scopes.add(this); + scopes.addAll(registry.subscopes.values()); + + for (ScopeImpl subscope : scopes) { ImmutableMap tags = new ImmutableMap.Builder() .putAll(this.tags) .putAll(subscope.tags) diff --git a/core/src/test/java/com/uber/m3/tally/TestScopeTest.java b/core/src/test/java/com/uber/m3/tally/TestScopeTest.java index ccfc3aa..5e84dab 100644 --- a/core/src/test/java/com/uber/m3/tally/TestScopeTest.java +++ b/core/src/test/java/com/uber/m3/tally/TestScopeTest.java @@ -47,12 +47,14 @@ public void testCreate() { testScope.tagged(tags).counter("counter").inc(1); + testScope.counter("untagged_counter").inc(1); + Snapshot snapshot = testScope.snapshot(); assertNotNull(snapshot); Map counters = snapshot.counters(); assertNotNull(counters); - assertEquals(1, counters.size()); + assertEquals(2, counters.size()); CounterSnapshot counterSnapshot = counters.get(new ScopeKey("counter", tags)); assertNotNull(counterSnapshot); @@ -60,6 +62,12 @@ public void testCreate() { assertEquals("counter", counterSnapshot.name()); assertEquals(tags, counterSnapshot.tags()); assertEquals(1, counterSnapshot.value()); + + counterSnapshot = counters.get(new ScopeKey("untagged_counter", ImmutableMap.EMPTY)); + assertNotNull(counterSnapshot); + assertEquals("untagged_counter", counterSnapshot.name()); + assertEquals(ImmutableMap.EMPTY, counterSnapshot.tags()); + assertEquals(1, counterSnapshot.value()); } @Test