# 02 — Turning instrumentation on ← prev [01 — The number Boot logs](01-the-number-boot-logs.md) · next → [03 — The four phases](03-the-four-phases.md) --- ## There is no property for this The single most common wasted hour: looking for `spring.application.startup=buffering` in `application.yaml`. It does not exist. `ApplicationStartup` has to be set on the `SpringApplication` **before** `run()`, because the steps you care about are recorded before any configuration file has been read. ```java public static void main(String[] args) { SpringApplication app = new SpringApplication(StartupDiagnosisApplication.class); int capacity = Integer.getInteger("startup.buffer", 16384); switch (System.getProperty("startup.tracking", "buffering")) { case "buffering" -> app.setApplicationStartup(new BufferingApplicationStartup(capacity)); case "jfr" -> app.setApplicationStartup(new FlightRecorderApplicationStartup()); default -> { } } app.run(args); } ``` That means changing which tracker you use is a **redeploy**, not a config change — worth knowing before an incident, not during one. See [`StartupDiagnosisApplication.java`](../src/main/java/com/ankurm/startup/StartupDiagnosisApplication.java). ## Exposing the endpoint `startup` is not web-exposed by default: ```yaml management: endpoints: web: exposure: include: health,info,startup,beans,conditions ``` Exposing it without installing a tracker gives you an endpoint that returns an empty timeline rather than an error, which is a confusing way to lose twenty minutes. ## GET peeks, POST drains This is the trap that costs people their only recording. From [`docs/output/02-startup-tree.txt`](output/02-startup-tree.txt): ``` GET /actuator/startup -> events in response: 400 POST /actuator/startup -> events in response: 400 POST /actuator/startup -> events in response: 0 GET /actuator/startup -> events in response: 0 ``` `POST` calls `drainBufferedTimeline()`, which empties the buffer so the memory can be reclaimed. Every guide shows the `POST`. If you pipe it to a file and the file is wrong, the data is gone — the application has to be restarted to record it again. Use `GET` while you are still working out what you want. ## You do not need a `@Bean` for it Boot registers the instance as a singleton named `applicationStartup` before the context refreshes, so it can simply be injected. Declaring your own `@Bean` produces: ``` Parameter 0 of constructor in ...StartupDiagnosticsEndpoint required a single bean, but 2 were found: - bufferingApplicationStartup: defined by method 'bufferingApplicationStartup' ... - applicationStartup: a programmatically registered singleton ``` Inject the `ApplicationStartup` interface and narrow with `instanceof`, not the concrete `BufferingApplicationStartup` — otherwise the application refuses to start whenever somebody runs it without tracking. Full transcript in [`docs/output/01-api-corrections.txt`](output/01-api-corrections.txt). --- ← prev [01 — The number Boot logs](01-the-number-boot-logs.md) · next → [03 — The four phases](03-the-four-phases.md)