0
0
Spring Bootframework~20 mins

Custom actuator endpoints in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Custom Actuator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2: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) {}
}
A{"status":"UP","info":"All systems operational"}
B{"state":"UP","message":"All systems operational"}
C{"state":"DOWN","message":"All systems operational"}
D{"state":"UP"}
Attempts:
2 left
💡 Hint
Look at the record fields and the returned object structure.
📝 Syntax
intermediate
2: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:
A
@WriteOperation
public String updateStatus(@Selector String newStatus) { return "Updated to " + newStatus; }
B
@WriteOperation
public String updateStatus(String newStatus) { return "Updated to " + newStatus; }
C
@WriteOperation
public String updateStatus() { return "Updated"; }
D
@WriteOperation
public void updateStatus(String newStatus) { System.out.println(newStatus); }
Attempts:
2 left
💡 Hint
Write operations with parameters require @Selector annotation for each parameter.
🔧 Debug
advanced
2: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?
AThe class must extend AbstractEndpoint to be recognized.
BThe endpoint id 'failEndpoint' is invalid because it contains uppercase letters.
CThe method 'status' lacks a @ReadOperation annotation.
DThe class is missing @RestController annotation.
Attempts:
2 left
💡 Hint
Check if the method is properly annotated to expose it as an endpoint operation.
state_output
advanced
2: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?
A2
B1
C0
DCannot determine because endpoints are stateless
Attempts:
2 left
💡 Hint
Consider the instance variable and how many times increment is called.
🧠 Conceptual
expert
2:00remaining
Which statement about custom actuator endpoints is true?
Select the correct statement about custom actuator endpoints in Spring Boot.
ACustom actuator endpoints require extending AbstractEndpoint class to function.
BCustom actuator endpoints must be registered manually in application.properties to be exposed.
CCustom actuator endpoints cannot accept parameters in their operations.
DCustom actuator endpoints can expose multiple operations annotated with @ReadOperation, @WriteOperation, and @DeleteOperation within the same class.
Attempts:
2 left
💡 Hint
Think about the flexibility of operation types in one endpoint class.