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) {