Skip to content

Commit b6c1a3e

Browse files
pstibranybrian-brazil
authored andcommitted
Changed visibility of Summary.Child.Value back to public. (prometheus#143)
This gives clients access to current values of summary, if they need it. Also added simple tests to avoid breaking this API in the future.
1 parent aadb20d commit b6c1a3e

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

simpleclient/src/main/java/io/prometheus/client/Summary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public double observeDuration() {
166166
* {@link SimpleCollector#remove} or {@link SimpleCollector#clear}.
167167
*/
168168
public static class Child {
169-
private static class Value {
169+
public static class Value {
170170
public final double count;
171171
public final double sum;
172172
public final SortedMap<Double, Double> quantiles;

simpleclient/src/test/java/io/prometheus/client/HistogramTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import static org.junit.Assert.assertArrayEquals;
44
import static org.junit.Assert.assertEquals;
5+
import static org.junit.Assert.assertTrue;
56

7+
import java.lang.reflect.Method;
8+
import java.lang.reflect.Modifier;
69
import java.util.ArrayList;
710
import java.util.List;
811
import org.junit.After;
@@ -180,4 +183,17 @@ public void testCollect() {
180183
assertEquals(mfsFixture, mfs.get(0));
181184
}
182185

186+
@Test
187+
public void testChildAndValuePublicApi() throws Exception {
188+
assertTrue(Modifier.isPublic(Histogram.Child.class.getModifiers()));
189+
190+
final Method getMethod = Histogram.Child.class.getMethod("get");
191+
assertTrue(Modifier.isPublic(getMethod.getModifiers()));
192+
assertEquals(Histogram.Child.Value.class, getMethod.getReturnType());
193+
194+
assertTrue(Modifier.isPublic(Histogram.Child.Value.class.getModifiers()));
195+
assertTrue(Modifier.isPublic(Histogram.Child.Value.class.getField("sum").getModifiers()));
196+
assertTrue(Modifier.isPublic(Histogram.Child.Value.class.getField("buckets").getModifiers()));
197+
}
198+
183199
}

simpleclient/src/test/java/io/prometheus/client/SummaryTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import org.junit.Before;
55
import org.junit.Test;
66

7+
import java.lang.reflect.Method;
8+
import java.lang.reflect.Modifier;
79
import java.util.ArrayList;
810
import java.util.List;
911

1012
import static java.util.Arrays.asList;
1113
import static org.junit.Assert.assertEquals;
14+
import static org.junit.Assert.assertTrue;
1215

1316

1417
public class SummaryTest {
@@ -180,4 +183,18 @@ public void testCollectWithQuantiles() {
180183
assertEquals(1, mfs.size());
181184
assertEquals(mfsFixture, mfs.get(0));
182185
}
186+
187+
@Test
188+
public void testChildAndValuePublicApi() throws Exception {
189+
assertTrue(Modifier.isPublic(Summary.Child.class.getModifiers()));
190+
191+
final Method getMethod = Summary.Child.class.getMethod("get");
192+
assertTrue(Modifier.isPublic(getMethod.getModifiers()));
193+
assertEquals(Summary.Child.Value.class, getMethod.getReturnType());
194+
195+
assertTrue(Modifier.isPublic(Summary.Child.Value.class.getModifiers()));
196+
assertTrue(Modifier.isPublic(Summary.Child.Value.class.getField("count").getModifiers()));
197+
assertTrue(Modifier.isPublic(Summary.Child.Value.class.getField("sum").getModifiers()));
198+
assertTrue(Modifier.isPublic(Summary.Child.Value.class.getField("quantiles").getModifiers()));
199+
}
183200
}

0 commit comments

Comments
 (0)