@Override
        public void serialize(final Metrics metrics, final JsonGenerator jsonGenerator,
                              final SerializerProvider serializerProvider) throws IOException {
            final Map<String, Object> m = new HashMap<>();
            m.put(GraphSONTokens.ID, metrics.getId());
            m.put(GraphSONTokens.NAME, metrics.getName());
            m.put(GraphSONTokens.COUNTS, metrics.getCounts());
            m.put(GraphSONTokens.DURATION, metrics.getDuration(TimeUnit.NANOSECONDS) / 1000000d);

            if (!metrics.getAnnotations().isEmpty()) {
                m.put(GraphSONTokens.ANNOTATIONS, metrics.getAnnotations());
            }
            if (!metrics.getNested().isEmpty()) {
                final List<Metrics> nested = new ArrayList<>();
                metrics.getNested().forEach(it -> nested.add(it));
                m.put(GraphSONTokens.METRICS, nested);
            }
            jsonGenerator.writeObject(m);
        }
GraphSON serializers for graph-based objects such as vertices, edges, properties, and paths. These serializers
present a generalized way to serialize the implementations of core interfaces.

@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2.java