code: public void serialize(@Nonnull Iterable<QueryResult> results, @Nonnull OutputStream out) throws IOException {
  		JsonGenerator g = jsonFactory.createGenerator(out, JsonEncoding.UTF8);
  		g.writeStartObject();
  		g.writeNumberField("timestamp", System.currentTimeMillis() / 1000);
  		g.writeNumberField("proto_version", STACKDRIVER_PROTOCOL_VERSION);
  		g.writeArrayFieldStart("data");
  
  		for (QueryResult metric : results) {
  			g.writeStartObject();
  			g.writeStringField("name", metric.getName());
  			if (instanceId != null && !instanceId.isEmpty()) {
  				g.writeStringField("instance", instanceId);
  			}
  			g.writeNumberField("collected_at", metric.getEpoch(TimeUnit.SECONDS));
  			if (metric.getValue() instanceof Integer) {
  				g.writeNumberField("value", (Integer) metric.getValue());
  			} else if (metric.getValue() instanceof Long) {
  				g.writeNumberField("value", (Long) metric.getValue());
  			} else if (metric.getValue() instanceof Float) {
  				g.writeNumberField("value", (Float) metric.getValue());
  			} else if (metric.getValue() instanceof Double) {
  				g.writeNumberField("value", (Double) metric.getValue());
  			}
  			g.writeEndObject();
  		}
  
  		g.writeEndArray();
  		g.writeEndObject();
  		g.flush();
  		g.close();
  	}
docs: Put the values into the JSON format expected by the Stackdriver custom metrics gateway
  
  @param results
  Iterable collection of data points (gauges and counters)
  @param out
  OutputStream to write JSON to
  @throws IOException