Add MeterRegistry monitoring

- update and cleanup in README.md
- extract webclient call from registerDevice and add metrics in DeviceRegistryService
- add WebClientCalls.kt
- update kotlin logging dependency
- add MeterRegistry dependency
This commit is contained in:
2024-12-20 17:09:22 +01:00
parent 10f6486e37
commit 93680e50d5
9 changed files with 138 additions and 52 deletions

View File

@@ -0,0 +1,17 @@
package ltd.hlaeja.util
import ltd.hlaeja.library.deviceRegistry.Device
import ltd.hlaeja.property.DeviceRegistryProperty
import org.springframework.http.HttpStatus.REQUEST_TIMEOUT
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.awaitBodyOrNull
import org.springframework.web.server.ResponseStatusException
suspend fun WebClient.deviceRegistryCreateDevice(
request: Device.Request,
property: DeviceRegistryProperty,
): Device.Response = post()
.uri("${property.url}/device".also(::logCall))
.bodyValue(request)
.retrieve()
.awaitBodyOrNull<Device.Response>() ?: throw ResponseStatusException(REQUEST_TIMEOUT)