Skip to content

Conversation

@onobc
Copy link
Contributor

@onobc onobc commented Sep 5, 2021

Fixes gh-26729

@wilkinsona I picked your draft changes up and added the Actuator side of things.


TODO

  • Add docs

Here is what the metric looks like in Wavefront.

Screen Shot 2021-09-05 at 9 25 44 PM

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 5, 2021
return;
}
TimeGauge
.builder("spring.boot.application.started", () -> event.getStartupTime().toMillis(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbazos I know you had mentioned the following possible metric candidates for a StartupTimeMetrics.

  • jvm start time
  • application start time
  • spring context start time

spring context start time

Just to clarify that the StartupInfoLogger is actually logging "spring context start time" which corresponds to the ApplicationStartedEvent (the app is live but not ready for requests yet - it still has to invoke any runners). This pull request logs this startup time.

application start time

The "application start time" I am guessing would correspond to the ApplicationReadyEvent (the app is live and the app is ready for requests - all runners have been invoked). This pull request does not log this startup time. It could easily be added though and it would allow users to get an idea how much their runners are adding to startup time.

jvm start time

The StartupInfoLogger is logging "jvm uptime" which corresponds to how many ms the JVM has been up. This could also give an idea of the contribution the JVM has on the startup time. This pull request does not log this startup time either but it could easily be added.

@wilkinsona @mbazos
Wdyt about me adding in the 2 above metrics?

@onobc
Copy link
Contributor Author

onobc commented Sep 6, 2021

I added the startup time to the ApplicationReadyEvent as well. You can tell by the graph below which portion of the startup time is due to the runners (I think its helpful). I am waiting to push that 2nd commit though until I get a nod on adding the metric.

Screen Shot 2021-09-06 at 5 57 21 PM

@onobc
Copy link
Contributor Author

onobc commented Sep 8, 2021

I went ahead and pushes the subsequent commits that add the times for application.running and the jvm uptime as the point that the application is in ready state.

Looks like this in WF...

Screen Shot 2021-09-06 at 10 26 31 PM

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Sep 8, 2021
refreshContext(context);
afterRefresh(context, applicationArguments);
stopWatch.stop();
stopWatch.start("applicationReady");
Copy link
Member

@philwebb philwebb Sep 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be moved to past the listeners.started call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the application.ready.time is the total time from the app run() to the end of the runners and not just the portion of time that the runners took. I will give an example to make sure we are on the same page:

hh:mm:ss step
00:00:00 jvm is started
00:00:04 run is invoked
00:00:08 context has been refreshed
00:00:12 runners done executing

The "base T0" time from the app perspective is 00:00:04. Which gives the following:

  • application.started.time: 4s (00:00:04 -> 00:00:08)
  • application.ready.time: 8s (00:00:04 -> 00:00:12)
  • application.ready.jvm.time: 12s (00:00:00 -> 00:00:12)

Is that what you were thinking as well?

@philwebb
Copy link
Member

Thanks very much for the PR @Bono007.

We discussed some aspects of this today on our call and we think that the timer names should be changed from:

spring.boot.application.started
spring.boot.application.running

to:

application.started.time
application.ready.time

We're also wondering if there should be configuration options to change them.

Do you have any time to update the PR in that direction? If not, we can handle it when we merge.

@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Sep 10, 2021
@philwebb philwebb added this to the 2.6.x milestone Sep 10, 2021
@onobc
Copy link
Contributor Author

onobc commented Sep 11, 2021

Thanks very much for the PR @Bono007.

My pleasure @philwebb

We discussed some aspects of this today on our call and we think that the timer names should be changed from:

spring.boot.application.started
spring.boot.application.running

to:

application.started.time
application.ready.time

I ❤️ these new names - they were too verbose and in lockstep w/ the application event names. I went back and forth and just submitted these in hopes that I would get some feedback from team (I meant to call this out in comment). Ugghh naming... :)

One follow up question though, spring.boot.application.running.jvm change to default name of jvm.read.time or application.ready.jvm.time, or something else?

We're also wondering if there should be configuration options to change them.

I have went back/forth on the ability to change metric names (in general, not just here) and one hand its great because it allows consumers to name the metrics what they want for their custom requirements. On the other hand, it allows consumers to name the metrics what they want. This can lead to a somewhat standard metric name such as "mongodb.driver.commands" now being called "acme.company.mongodb.driver.or.whatever". I know the instrumentation in Micrometer tends to stay on the hardcoded side. I notice that SpringBoot has started to allow customization of most of the meters. I am ok w/ either approach but just wanted to bring this up.

Do you have any time to update the PR in that direction? If not, we can handle it when we merge.

Absolutely. On it now.

@onobc onobc requested a review from philwebb September 11, 2021 04:39
@wilkinsona
Copy link
Member

One follow up question though, spring.boot.application.running.jvm change to default name of jvm.read.time or application.ready.jvm.time, or something else?

Ah, that reminds me of the other thing we discussed. We don't think this should be part of Spring Boot. Instead, it feels like a general JVM metric that could be provided my Micrometer.

@onobc
Copy link
Contributor Author

onobc commented Sep 11, 2021

One follow up question though, spring.boot.application.running.jvm change to default name of jvm.read.time or application.ready.jvm.time, or something else?

Ah, that reminds me of the other thing we discussed. We don't think this should be part of Spring Boot. Instead, it feels like a general JVM metric that could be provided my Micrometer.

Yep, I agree w/ that. It was really added here as a convenience to see how much of the Spring Boot startup attributed to the overall JVM uptime (or vice-versa). The thing that Micrometer will not have is knowing that the application is ready (aka Spring event listener).

There is already the UptimeMetrics which gives the JVM start time and uptime so that may be able to be used and correlated w/ these metrics. Or consumers could easily add a custom metric that listens for the app ready (like the JVM metric in this proposal).

Either way, I will push another commit that removes the JVM metric.

@snicoll snicoll self-assigned this Sep 16, 2021
@snicoll snicoll removed this from the 2.6.x milestone Sep 16, 2021
@snicoll snicoll added this to the 2.6.0-M3 milestone Sep 16, 2021
snicoll pushed a commit to snicoll/spring-boot that referenced this pull request Sep 16, 2021
snicoll added a commit to snicoll/spring-boot that referenced this pull request Sep 16, 2021
snicoll pushed a commit that referenced this pull request Sep 16, 2021
snicoll added a commit that referenced this pull request Sep 16, 2021
@snicoll snicoll closed this in ce95e09 Sep 16, 2021
@snicoll
Copy link
Member

snicoll commented Sep 16, 2021

Thanks again, Chris.

sdeleuze added a commit to sdeleuze/spring-native that referenced this pull request Sep 20, 2021
philwebb added a commit that referenced this pull request Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish a metric for the application's startup time

5 participants