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

fixing start metrics #398

Merged
merged 2 commits into from
Sep 25, 2023
Merged
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 @@ -50,15 +50,12 @@
import javax.servlet.FilterRegistration;
import java.util.EnumSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class BaseServer<T extends ServersConfiguration> extends Application<T>
{
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(BaseServer.class);
public static final String SERVER_STOPPED = "server-stopped";

AtomicBoolean ready = new AtomicBoolean(false);

public static final String SERVER_STARTED = "server started";

protected BaseServer()
{
}
Expand Down Expand Up @@ -129,7 +126,7 @@ public void run(T configuration, Environment environment)
@Override
protected Result check()
{
return ready.get() ? Result.healthy() : Result.unhealthy("app not ready");
return Result.healthy();
}
});

Expand All @@ -155,14 +152,13 @@ public void lifeCycleStarting(LifeCycle event)
@Override
public void lifeCycleStarted(LifeCycle event)
{
ready.getAndSet(true);
LOGGER.info("Started {} ready: {}", configuration.getApplicationName(),ready.get());
LOGGER.info("Started {} ", configuration.getApplicationName());
PrometheusMetricsFactory.getInstance().incrementCount(SERVER_STARTED);
}

@Override
public void lifeCycleFailure(LifeCycle event, Throwable cause)
{
ready.getAndSet(false);
LOGGER.error("Application {} failure : {}", configuration.getApplicationName(),cause.getMessage());
}

Expand All @@ -177,7 +173,6 @@ public void lifeCycleStopping(LifeCycle event)
public void lifeCycleStopped(LifeCycle event)
{
LOGGER.info("Stopped {} in {} ", configuration.getApplicationName(), System.currentTimeMillis() - shutDownStartTime);
PrometheusMetricsFactory.getInstance().incrementCount(SERVER_STOPPED);
}
});
}
Expand Down