Challenge - 5 Problems
Custom Actuator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this custom actuator endpoint?
Given the following Spring Boot custom actuator endpoint code, what will be the JSON output when accessing
/actuator/customStatus?Spring Boot
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.stereotype.Component; @Component @Endpoint(id = "customStatus") public class CustomStatusEndpoint { @ReadOperation public Status status() { return new Status("UP", "All systems operational"); } public record Status(String state, String message) {} }
Attempts:
2 left
💡 Hint
Look at the record fields and the returned object structure.
✗ Incorrect
The endpoint returns a Status record with fields 'state' and 'message'. The JSON output matches these field names and values exactly.
📝 Syntax
intermediate2:00remaining
Which option correctly defines a write operation in a custom actuator endpoint?
You want to create a custom actuator endpoint with a write operation that accepts a String parameter. Which code snippet correctly defines the write operation method?
Spring Boot
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; import org.springframework.boot.actuate.endpoint.annotation.Selector; // Method to define:
Attempts:
2 left
💡 Hint
Write operations with parameters require @Selector annotation for each parameter.
✗ Incorrect
In Spring Boot actuator custom endpoints, parameters for write operations must be annotated with @Selector to be bound from the request.
🔧 Debug
advanced2:00remaining
Why does this custom actuator endpoint fail to register?
Consider this custom endpoint class:
@Component
@Endpoint(id = "failEndpoint")
public class FailEndpoint {
public String status() {
return "OK";
}
}
Why does Spring Boot fail to register this endpoint?
Attempts:
2 left
💡 Hint
Check if the method is properly annotated to expose it as an endpoint operation.
✗ Incorrect
Spring Boot actuator requires methods to be annotated with @ReadOperation, @WriteOperation, or @DeleteOperation to expose them as endpoint operations.
❓ state_output
advanced2:00remaining
What is the state of the custom endpoint after calling the write operation twice?
Given this custom endpoint:
@Component
@Endpoint(id = "counter")
public class CounterEndpoint {
private int count = 0;
@ReadOperation
public int getCount() {
return count;
}
@WriteOperation
public void increment() {
count++;
}
}
If you call the write operation
/actuator/counter twice, then call the read operation, what is the returned count?Attempts:
2 left
💡 Hint
Consider the instance variable and how many times increment is called.
✗ Incorrect
The count starts at 0 and increments by 1 each time the write operation is called. After two calls, count is 2.
🧠 Conceptual
expert2:00remaining
Which statement about custom actuator endpoints is true?
Select the correct statement about custom actuator endpoints in Spring Boot.
Attempts:
2 left
💡 Hint
Think about the flexibility of operation types in one endpoint class.
✗ Incorrect
A single custom actuator endpoint class can have multiple methods annotated with different operation annotations to expose various HTTP methods.