sps/metrics-opentsdb — pull request #5 by cnbaker (2014-08-27 06:34:14+00:00)
Title: Don't send an empty set of metrics to OpenTSDB. Even though it is perfec...

...tly valid JSON, it fails to parse an empty list. This is a problem with Dropwizard's jvm.threads.deadlocks metric which is empty under normal operating conditions.

It's a tough call on whether this is an actual bug in OpenTSDB but It looks like they are intentionally throwing the BadRequestException when content is empty (parsePutV1 explicitly states it will throw on empty content in the JavaDoc)

$ curl 'http://localhost:4242/api/put' -d '{"metric":"my-app.jvm.threads.deadlocks","timestamp":1409092196,"value":[],"tags":{"type":"app"}}'
{"error":{"code":400,"message":"Unable to parse the given JSON","details":"com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token\n at [Source: java.io.StringReader@4ced1dfe; line: 1, column: 84] (through reference chain: net.opentsdb.core.IncomingDataPoint[\"value\"])","trace":"net.opentsdb.tsd.BadRequestException: Unable to parse the given JSON\n\tat net.opentsdb.tsd.HttpJsonSerializer.parsePutV1(HttpJsonSerializer.java:143)
....
....

I feel like OpenTSDB should handle this situation more gracefully than throwing an exception but I'm not comfortable enough with their codebase or philosophy to start that discussion with them yet and for now, it seems more efficient to not send an empty metric than to send more data on the wire.