Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: init metrics only if monitoring enabled #5165

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@
import org.joml.Vector3i;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.context.Context;
import org.terasology.engine.core.Time;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.integrationenvironment.jupiter.IntegrationEnvironment;
import org.terasology.engine.logic.players.LocalPlayer;
import org.terasology.engine.logic.players.event.ResetCameraEvent;
import org.terasology.engine.network.ClientComponent;
import org.terasology.engine.network.NetworkMode;
import org.terasology.engine.registry.In;
import org.terasology.engine.world.WorldProvider;
import org.terasology.engine.world.block.BlockManager;
import org.terasology.unittest.stubs.DummyEvent;

import java.io.IOException;

@IntegrationEnvironment(networkMode = NetworkMode.LISTEN_SERVER)
public class ExampleTest {
private static final Logger logger = LoggerFactory.getLogger(ExampleTest.class);

@In
private WorldProvider worldProvider;
Expand All @@ -34,6 +37,13 @@ public class ExampleTest {
@In
private ModuleTestingHelper helper;

@Test
public void testClientCreation() {
logger.info("Starting test 'testClientCreation'");
Assertions.assertDoesNotThrow(helper::createClient);
logger.info("Done with test 'testClientCreation'");
}

@Test
public void testClientConnection() throws IOException {
int currentClients = Lists.newArrayList(entityManager.getEntitiesWith(ClientComponent.class)).size();
Expand Down Expand Up @@ -65,7 +75,7 @@ public void testSendEvent() throws IOException {
Context clientContext = helper.createClient();

// send an event to a client's local player just for fun
clientContext.get(LocalPlayer.class).getClientEntity().send(new ResetCameraEvent());
clientContext.get(LocalPlayer.class).getClientEntity().send(new DummyEvent());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public void initialise(GameEngine engine, Context rootContext) {
if (rootContext.get(SystemConfig.class).monitoringEnabled.get()) {
advancedMonitor = new AdvancedMonitor();
advancedMonitor.setVisible(true);
initMicrometerMetrics(rootContext.get(Time.class));
}

initMicrometerMetrics(rootContext.get(Time.class));
}

/**
Expand Down
Loading