use of org.terasology.telemetry.Metrics 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);
}
}
}
use of org.terasology.telemetry.Metrics in project Terasology by MovingBlocks.
the class SystemContextJsonProvider method writeTo.
public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException {
TelemetryLogstashAppender appender = TelemetryUtils.fetchTelemetryLogstashAppender();
Context context = appender.getGameContext();
if (context != null) {
Metrics metrics = context.get(Metrics.class);
Optional<Metric> optional = metrics.getMetric(SystemContextMetric.class);
if (optional.isPresent()) {
Metric systemContextMetric = optional.get();
Map<String, ?> map = systemContextMetric.createTelemetryFieldToValue();
Map<String, String> stringMap = TelemetryUtils.toStringMap(map);
JsonWritingUtils.writeMapStringFields(generator, getFieldName(), stringMap);
}
}
}
use of org.terasology.telemetry.Metrics in project Terasology by MovingBlocks.
the class TelemetrySubSystem method preInitialise.
@Override
public void preInitialise(Context rootContext) {
// Add metrics to context, this helps show metric values in ui
metrics = new Metrics();
rootContext.put(Metrics.class, metrics);
// Add snowplow emitter to context, contributors can use this emitter to emit other event
emitter = TelemetryEmitter.builder().build();
rootContext.put(Emitter.class, emitter);
}
Aggregations