Skip to content

Commit 85fac72

Browse files
author
Vladimir Kotal
committed
record web app startup latency
1 parent 2987a36 commit 85fac72

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

opengrok-web/src/main/java/org/opengrok/web/WebappListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,17 @@ public final class WebappListener
5656
implements ServletContextListener, ServletRequestListener {
5757

5858
private static final Logger LOGGER = LoggerFactory.getLogger(WebappListener.class);
59+
private Timer startupTimer = Timer.builder("webapp.startup.latency").
60+
description("web application startup latency").
61+
register(Metrics.getRegistry());
5962

6063
/**
6164
* {@inheritDoc}
6265
*/
6366
@Override
6467
public void contextInitialized(final ServletContextEvent servletContextEvent) {
68+
Instant start = Instant.now();
69+
6570
ServletContext context = servletContextEvent.getServletContext();
6671
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
6772

@@ -97,6 +102,7 @@ public void contextInitialized(final ServletContextEvent servletContextEvent) {
97102
}
98103

99104
env.startExpirationTimer();
105+
startupTimer.record(Duration.between(start, Instant.now()));
100106
}
101107

102108
/**

0 commit comments

Comments
 (0)