Class Capture
java.lang.Object
io.kubfly.sdk.test.Capture
The telemetry of one test as the types of
reflector: a body runs in a root frame of its own, and its capture
is everything of the trace of that frame — the frames under it, by their parent, in any thread; the frames of other
services of the process it called, by their caller (HTTP, Kafka, RabbitMQ in the same JVM); the events and the ends
of all of them. Tests in parallel do not see one another: each has its own trace.
Capture capture = Capture.run("ship", () -> orders.ship(42));
for (Item item : capture.items()) {
if (item instanceof Event event && event.level() == Level.ERROR) {
fail(event.message());
}
}
The records go through the real collector of a bucket into a bucket in memory and are read by reflector, as
the bucket of a stand is read: a test sees what Navigator would see, the format included. Only the events and the
frames have a trace; metrics, alerts, health, traffic and profiles are of the whole process — process().
An event outside any frame belongs to no capture either: it is in process() only.-
Method Summary
Modifier and TypeMethodDescriptionitems()The items of the capture once one of them matches, read anew every 10 ms.static Queryprocess()The whole process asreflectorreads it: every stream — metrics, alerts, health, traffic, profiles, and the events outside any frame.Runs a body in a new root frame (sdk/test/capture/run, even inside another frame) and captures its trace.Runs a body in a new root frame with the tagtest— the name of the test — and captures its trace.static Standstand()The stand of the recording asreflectorreads it: for what an item refers to beyond its segments — the attachments of events (Stand.attachment(Origin, Attachment)).toString()The text form.trace()The trace of the capture: that of its root frame.
-
Method Details
-
run
Runs a body in a new root frame (sdk/test/capture/run, even inside another frame) and captures its trace.- Type Parameters:
X- the exception the body may throw- Parameters:
body- the body- Returns:
- the capture
- Throws:
X- the body's exception, unchangedIllegalStateException- if the collector ofkubfly-sdk-testwas not found
-
run
Runs a body in a new root frame with the tagtest— the name of the test — and captures its trace.- Type Parameters:
X- the exception the body may throw- Parameters:
name- the name of the testbody- the body- Returns:
- the capture
- Throws:
X- the body's exception, unchangedIllegalStateException- if the collector ofkubfly-sdk-testwas not found
-
trace
-
items
The items of the capture so far, in the order of time:Begin,EndandEventof the frames of its trace, the root framesdk/test/capture/runincluded. Everything the collector received until now is written and read anew; what another thread is still doing — the end of a frame of a server after its response, a consumer of a broker — may come later:items(Predicate, Duration)waits for it.- Returns:
- the items, read once: a list behind the timeline
-
items
The items of the capture once one of them matches, read anew every 10 ms.- Parameters:
until- the item awaitedtimeout- how long to wait for it- Returns:
- the items, that one among them
- Throws:
AssertionError- if none matched in time; the message tells how many items there were
-
process
The whole process asreflectorreads it: every stream — metrics, alerts, health, traffic, profiles, and the events outside any frame. The interval of metrics is taken now (Collectors.flush()— for every collector of the process), then everything received is written.- Returns:
- the requests to the instance of the process
- Throws:
IllegalStateException- if the collector ofkubfly-sdk-testwas not found
-
stand
The stand of the recording asreflectorreads it: for what an item refers to beyond its segments — the attachments of events (Stand.attachment(Origin, Attachment)). Read afteritems()orprocess(): they write what was received.- Returns:
- the stand
- Throws:
IllegalStateException- if the collector ofkubfly-sdk-testwas not found
-
toString
-