Search in sources :

Example 1 with ModulesMetric

use of org.terasology.engine.telemetry.metrics.ModulesMetric in project Terasology by MovingBlocks.

the class ModulesJsonProvider method writeTo.

@Override
public void writeTo(JsonGenerator generator, ILoggingEvent iLoggingEvent) throws IOException {
    TelemetryLogstashAppender appender = TelemetryUtils.fetchTelemetryLogstashAppender();
    Context context = appender.getGameContext();
    if (context != null) {
        Metrics metrics = context.get(Metrics.class);
        Optional<Metric> optional = metrics.getMetric(ModulesMetric.class);
        if (optional.isPresent()) {
            Metric modulesMetric = optional.get();
            Map<String, ?> map = modulesMetric.createTelemetryFieldToValue();
            Map<String, String> stringMap = TelemetryUtils.toStringMap(map);
            JsonWritingUtils.writeMapStringFields(generator, getFieldName(), stringMap);
        }
    }
}
Also used : Context(org.terasology.engine.context.Context) Metrics(org.terasology.engine.telemetry.Metrics) ModulesMetric(org.terasology.engine.telemetry.metrics.ModulesMetric) Metric(org.terasology.engine.telemetry.metrics.Metric)

Aggregations

Context (org.terasology.engine.context.Context)1 Metrics (org.terasology.engine.telemetry.Metrics)1 Metric (org.terasology.engine.telemetry.metrics.Metric)1 ModulesMetric (org.terasology.engine.telemetry.metrics.ModulesMetric)1