Skip to content

Commit 58f8880

Browse files
committed
add some live prometheus test data
1 parent 3125c7d commit 58f8880

File tree

12 files changed

+18
-2
lines changed

12 files changed

+18
-2
lines changed

src/main/docker/mad/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM openjdk:8u302-jre-slim
15+
FROM openjdk:8u302-jre
1616

1717
MAINTAINER arpnetworking
1818

src/main/java/com/arpnetworking/metrics/mad/parsers/PrometheusToRecordParser.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@
4040
import org.xerial.snappy.Snappy;
4141

4242
import java.io.IOException;
43+
import java.nio.file.Files;
44+
import java.nio.file.Paths;
4345
import java.time.Instant;
4446
import java.time.ZoneOffset;
4547
import java.time.ZonedDateTime;
4648
import java.util.List;
4749
import java.util.Objects;
4850
import java.util.Optional;
4951
import java.util.UUID;
52+
import java.util.concurrent.atomic.AtomicInteger;
5053

5154
/**
5255
* Parses the Prometheus protobuf binary protocol into records.
@@ -111,7 +114,12 @@ public List<Record> parse(final HttpRequest data) throws ParsingException {
111114
final List<Record> records = Lists.newArrayList();
112115
final byte[] uncompressed;
113116
try {
114-
uncompressed = Snappy.uncompress(data.getBody().toArray());
117+
final byte[] input = data.getBody().toArray();
118+
int outputFile = _outputFileNumber.incrementAndGet();
119+
if (outputFile < 10) {
120+
Files.write(Paths.get("prometheus_debug_" + outputFile), input);
121+
}
122+
uncompressed = Snappy.uncompress(input);
115123
} catch (final IOException e) {
116124
throw new ParsingException("Failed to decompress snappy stream", data.getBody().toArray(), e);
117125
}
@@ -185,6 +193,7 @@ private static String createUnitMapKey(final String name) {
185193
}
186194

187195
private final boolean _interpretUnits;
196+
private final AtomicInteger _outputFileNumber = new AtomicInteger(0);
188197

189198
private static final ImmutableMap<String, Unit> UNIT_MAP = ImmutableMap.of(
190199
createUnitMapKey("seconds"), Unit.SECOND,

src/test/java/com/arpnetworking/metrics/mad/parsers/PrometheusToRecordParserTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ public void testUnitParserBits() {
156156
testUnitParsing("bits", Unit.BIT);
157157
}
158158

159+
@Test
160+
public void testLive1() throws ParsingException, IOException {
161+
final List<Record> records = parseRecords("PrometheusParserTest/testLivePrometheus1");
162+
163+
Assert.assertEquals(0, records.size());
164+
}
165+
159166
private static void testUnitParsing(final String prometheusUnit, final Unit expected) {
160167
assertUnitNewName(prometheusUnit, prometheusUnit, expected);
161168
assertUnitNewName("foo_" + prometheusUnit, prometheusUnit, expected);
50.9 KB
Binary file not shown.
56.9 KB
Binary file not shown.
48.2 KB
Binary file not shown.
22.1 KB
Binary file not shown.
16.6 KB
Binary file not shown.
17.9 KB
Binary file not shown.
17.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)