All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.metrics.reporter.file.JsonMetricFormat Maven / Gradle / Ivy

There is a newer version: 2.0.6
Show newest version
package com.alibaba.metrics.reporter.file;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.metrics.common.MetricObject;

public class JsonMetricFormat extends MetricFormat {

    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("metricLevel".equals(name)) {
                return false;
            } else {
                return true;
            }
        }
    };

    @Override
    public String format(MetricObject metric) {
        return JSON.toJSONString(metric, filter, SerializerFeature.DisableCircularReferenceDetect);
    }

    @Override
    public byte[] formatToBytes(MetricObject metric) {
        return JSON.toJSONBytes(metric, SerializerFeature.DisableCircularReferenceDetect);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy