Code: Select all
@GetMapping("/question")
Mono question(@RequestParam(value = "id", required = true) int id) {
return Mono.just(id)
.map(oneId -> doSomeLenghtyInMemoryNonBlockingOperation(oneId))
;
}
private String doSomeLenghtyInMemoryNonBlockingOperation(int oneId) {
//This is the business code I would like to observe, hope to compute the histogram for this.
//the business logic runs some tasks which takes (variable amount) of time
return ...;
}
< /code>
Der Teil, den ich beobachten möchte, ist die Methode in der Kartenfunktion. Es läuft manchmal schnell und läuft manchmal langsam usw. < /p>
Da dies der wichtige Geschäftslogikteil ist, möchte ich, dass es beobachtet wird. < /P>
Ausgabe 1: In der nicht reaktiven Welt addieren Sie nur das @timed (value = "Einige_Values", Histogram = True
;
}
private String doSomeLenghtyInMemoryNonBlockingOperation(int oneId) {
//This is the business code I would like to observe, hope to compute the histogram for this.
//the business logic runs some tasks which takes a certain (variable amount) of time
return ...;
}
}
< /code>
Und auch: < /p>
@RestController
class QuestionController {
ObservationRegistry observationRegistry;
public QuestionController(ObservationRegistry observationRegistry, MeterRegistry meterRegistry) {
this.observationRegistry = observationRegistry;
}
@GetMapping("/question")
Mono question(@RequestParam(value = "id", required = true) int id) {
return Mono.just(id)
.map(oneId -> doSomeLenghtyInMemoryNonBlockingOperation(oneId))
// is this the correct use of tap? Should it be before or after the previous line?
// how to get the histogram from this?
.name("shouldNameAndTapBeBeforeOrAfterTheThingToObserve")
.tap(Micrometer.observation(observationRegistry))
;
}
private String doSomeLenghtyInMemoryNonBlockingOperation(int oneId) {
//This is the business code I would like to observe hope to compute the histogram for this.
//the business logic runs some tasks which takes a certain (variable amount) of time
return "";
}
}
< /code>
generieren weder Histogramme (oder Perzentile) < /p>
Frage: < /p>
So generieren Sie ein Histogramm für den Frühling WebFlux / reaktive Apps? < / P>