use of org.terasology.engine.config.facade.TelemetryConfiguration in project Terasology by MovingBlocks.
the class TelemetryUtils method fetchMetricAndSend.
/**
* Fetch metric in {@link org.terasology.engine.context.Context} and send to the server.
* This method could be used in the modules.
* @param context The game context
* @param metricClass The class of the metric which we want to track
* @param nameSpace The name the class tracking this metric.
*/
public static void fetchMetricAndSend(Context context, Class metricClass, String nameSpace) {
Emitter emitter = context.get(Emitter.class);
Metrics metrics = context.get(Metrics.class);
TelemetryConfiguration telemetryConfiguration = context.get(TelemetryConfiguration.class);
if (emitter != null && metrics != null && telemetryConfiguration != null) {
Optional<Metric> metricOptional = metrics.getMetric(metricClass);
if (metricOptional.isPresent()) {
Metric metric = metricOptional.get();
Optional<Unstructured> unstructuredOptional = metric.getUnstructuredMetric();
if (unstructuredOptional.isPresent()) {
Unstructured unstructured = unstructuredOptional.get();
trackMetric(emitter, nameSpace, unstructured, metric, telemetryConfiguration);
}
}
} else {
logger.error("Emitter or metrics or telemetryConfiguration is not in context");
}
}
use of org.terasology.engine.config.facade.TelemetryConfiguration in project Terasology by MovingBlocks.
the class TelemetrySubSystem method postInitialise.
@Override
public void postInitialise(Context rootContext) {
metrics.initialise(rootContext);
// Add the telemetryConfig adapter to context. It could be used in modules.
Config config = rootContext.get(Config.class);
TelemetryConfig telemetryConfig = config.getTelemetryConfig();
TelemetryConfiguration telemetryConfiguration = new TelemetryConfigurationImpl(telemetryConfig);
rootContext.put(TelemetryConfiguration.class, telemetryConfiguration);
addTelemetryLogstashAppender(rootContext);
setTelemetryDestination(rootContext);
}
Aggregations