...
/Reading Operation Data: Persistent
Reading Operation Data: Persistent
Learn how to add HTTP calls with /actuator/httptrace by adding a wrapper class.
We'll cover the following...
We'll cover the following...
Adding wrapper class
Spring Boot Actuator’s HttpTraceRepository stores’ instances of the HttpTrace
class. Unfortunately, that record doesn’t have a proper key.  This means we can’t save it directly into MongoDB. To handle this, and considering the fact that HttpTrace is final and not extendable, we must define a wrapper.
public class HttpTraceWrapper {private @Id String id; //1private HttpTrace httpTrace; //2public HttpTraceWrapper(HttpTrace httpTrace) { //3this.httpTrace = httpTrace;}public HttpTrace getHttpTrace() { //4return httpTrace;}}
 Wrapper class used to store HttpTrace objects in MongoDB
- In line 2, the wrapper contains a string-based 
idwith Spring Data Commons’@Idannotation applied. This allows each instance to be uniquely identified. - In line 3, an actual 
HttpTraceinstance is contained in the wrapper. - In line 4, we need a constructor call that accepts an existing 
HttpTraceobject. Theidis null so that Spring Data MongoDB creates a new, unique key. - In line 7, a getter is needed to extract the 
HttpTraceobject when retrieving. 
We know that we must also define a corresponding Spring Data repository to store and retrieve HttpTraceWrapper objects from our MongoDB server.
Should this repository use the same Reactive Streams tactics we’ve used so far?
The answer to this is no, because HttpTraceRepository ...