summaryrefslogtreecommitdiff
path: root/opendc-telemetry
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-telemetry')
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/build.gradle.kts36
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricAggregator.kt517
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricExporter.kt59
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricReader.kt424
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMonitor.kt47
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/Helpers.kt45
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/HostAttributes.kt51
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostInfo.kt28
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostTableReader.kt125
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerInfo.kt37
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerTableReader.kt90
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceData.kt46
-rw-r--r--opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceTableReader.kt70
13 files changed, 0 insertions, 1575 deletions
diff --git a/opendc-telemetry/opendc-telemetry-compute/build.gradle.kts b/opendc-telemetry/opendc-telemetry-compute/build.gradle.kts
deleted file mode 100644
index b476a669..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/build.gradle.kts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-description = "Telemetry for OpenDC Compute"
-
-/* Build configuration */
-plugins {
- `kotlin-library-conventions`
-}
-
-dependencies {
- api(projects.opendcTelemetry.opendcTelemetrySdk)
-
- implementation(projects.opendcCompute.opendcComputeService)
- implementation(libs.opentelemetry.semconv)
- implementation(libs.kotlin.logging)
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricAggregator.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricAggregator.kt
deleted file mode 100644
index 9557f680..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricAggregator.kt
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-@file:Suppress("PropertyName")
-
-package org.opendc.telemetry.compute
-
-import io.opentelemetry.api.common.AttributeKey
-import io.opentelemetry.api.common.Attributes
-import io.opentelemetry.sdk.metrics.data.MetricData
-import io.opentelemetry.sdk.metrics.data.PointData
-import io.opentelemetry.sdk.resources.Resource
-import io.opentelemetry.semconv.resource.attributes.ResourceAttributes
-import org.opendc.telemetry.compute.table.*
-import java.time.Instant
-
-/**
- * Helper class responsible for aggregating [MetricData] into [ServiceTableReader], [HostTableReader] and [ServerTableReader].
- */
-public class ComputeMetricAggregator {
- private val _service = ServiceAggregator()
- private val _hosts = mutableMapOf<String, HostAggregator>()
- private val _servers = mutableMapOf<String, ServerAggregator>()
-
- /**
- * Process the specified [metrics] for this cycle.
- */
- public fun process(metrics: Collection<MetricData>) {
- val service = _service
- val hosts = _hosts
- val servers = _servers
-
- for (metric in metrics) {
- val resource = metric.resource
-
- when (metric.name) {
- // ComputeService
- "scheduler.hosts" -> {
- for (point in metric.longSumData.points) {
- // Record the timestamp for the service
- service.recordTimestamp(point)
-
- when (point.attributes[STATE_KEY]) {
- "up" -> service._hostsUp = point.value.toInt()
- "down" -> service._hostsDown = point.value.toInt()
- }
- }
- }
- "scheduler.servers" -> {
- for (point in metric.longSumData.points) {
- when (point.attributes[STATE_KEY]) {
- "pending" -> service._serversPending = point.value.toInt()
- "active" -> service._serversActive = point.value.toInt()
- }
- }
- }
- "scheduler.attempts" -> {
- for (point in metric.longSumData.points) {
- when (point.attributes[RESULT_KEY]) {
- "success" -> service._attemptsSuccess = point.value.toInt()
- "failure" -> service._attemptsFailure = point.value.toInt()
- "error" -> service._attemptsError = point.value.toInt()
- }
- }
- }
-
- // SimHost
- "system.guests" -> {
- val agg = getHost(hosts, resource) ?: continue
-
- for (point in metric.longSumData.points) {
- when (point.attributes[STATE_KEY]) {
- "terminated" -> agg._guestsTerminated = point.value.toInt()
- "running" -> agg._guestsRunning = point.value.toInt()
- "error" -> agg._guestsRunning = point.value.toInt()
- "invalid" -> agg._guestsInvalid = point.value.toInt()
- }
- }
- }
- "system.cpu.limit" -> {
- val agg = getHost(hosts, resource) ?: continue
-
- for (point in metric.doubleGaugeData.points) {
- val server = getServer(servers, point)
-
- if (server != null) {
- server._cpuLimit = point.value
- server._host = agg.host
- } else {
- agg._cpuLimit = point.value
- }
- }
- }
- "system.cpu.usage" -> {
- val agg = getHost(hosts, resource) ?: continue
- agg._cpuUsage = metric.doubleGaugeData.points.first().value
- }
- "system.cpu.demand" -> {
- val agg = getHost(hosts, resource) ?: continue
- agg._cpuDemand = metric.doubleGaugeData.points.first().value
- }
- "system.cpu.utilization" -> {
- val agg = getHost(hosts, resource) ?: continue
- agg._cpuUtilization = metric.doubleGaugeData.points.first().value
- }
- "system.cpu.time" -> {
- val agg = getHost(hosts, resource) ?: continue
-
- for (point in metric.longSumData.points) {
- val server = getServer(servers, point)
- val state = point.attributes[STATE_KEY]
- if (server != null) {
- when (state) {
- "active" -> server._cpuActiveTime = point.value
- "idle" -> server._cpuIdleTime = point.value
- "steal" -> server._cpuStealTime = point.value
- "lost" -> server._cpuLostTime = point.value
- }
- server._host = agg.host
- } else {
- when (state) {
- "active" -> agg._cpuActiveTime = point.value
- "idle" -> agg._cpuIdleTime = point.value
- "steal" -> agg._cpuStealTime = point.value
- "lost" -> agg._cpuLostTime = point.value
- }
- }
- }
- }
- "system.power.usage" -> {
- val agg = getHost(hosts, resource) ?: continue
- agg._powerUsage = metric.doubleGaugeData.points.first().value
- }
- "system.power.total" -> {
- val agg = getHost(hosts, resource) ?: continue
- agg._powerTotal = metric.doubleSumData.points.first().value
- }
- "system.time" -> {
- val agg = getHost(hosts, resource) ?: continue
-
- for (point in metric.longSumData.points) {
- val server = getServer(servers, point)
-
- if (server != null) {
- server.recordTimestamp(point)
-
- when (point.attributes[STATE_KEY]) {
- "up" -> server._uptime = point.value
- "down" -> server._downtime = point.value
- }
- server._host = agg.host
- } else {
- agg.recordTimestamp(point)
-
- when (point.attributes[STATE_KEY]) {
- "up" -> agg._uptime = point.value
- "down" -> agg._downtime = point.value
- }
- }
- }
- }
- "system.time.boot" -> {
- val agg = getHost(hosts, resource) ?: continue
-
- for (point in metric.longGaugeData.points) {
- val server = getServer(servers, point)
-
- if (server != null) {
- server._bootTime = Instant.ofEpochMilli(point.value)
- server._host = agg.host
- } else {
- agg._bootTime = Instant.ofEpochMilli(point.value)
- }
- }
- }
- "system.time.provision" -> {
- for (point in metric.longGaugeData.points) {
- val server = getServer(servers, point) ?: continue
- server.recordTimestamp(point)
- server._provisionTime = Instant.ofEpochMilli(point.value)
- }
- }
- }
- }
- }
-
- /**
- * Collect the data via the [monitor].
- */
- public fun collect(monitor: ComputeMonitor) {
- monitor.record(_service)
-
- for (host in _hosts.values) {
- monitor.record(host)
- host.reset()
- }
-
- for (server in _servers.values) {
- monitor.record(server)
- server.reset()
- }
- }
-
- /**
- * Obtain the [HostAggregator] for the specified [resource].
- */
- private fun getHost(hosts: MutableMap<String, HostAggregator>, resource: Resource): HostAggregator? {
- val id = resource.attributes[HOST_ID]
- return if (id != null) {
- hosts.getOrPut(id) { HostAggregator(resource) }
- } else {
- null
- }
- }
-
- /**
- * Obtain the [ServerAggregator] for the specified [point].
- */
- private fun getServer(servers: MutableMap<String, ServerAggregator>, point: PointData): ServerAggregator? {
- val id = point.attributes[ResourceAttributes.HOST_ID]
- return if (id != null) {
- servers.getOrPut(id) { ServerAggregator(point.attributes) }
- } else {
- null
- }
- }
-
- /**
- * An aggregator for service metrics before they are reported.
- */
- internal class ServiceAggregator : ServiceTableReader {
- private var _timestamp: Instant = Instant.MIN
- override val timestamp: Instant
- get() = _timestamp
-
- override val hostsUp: Int
- get() = _hostsUp
- @JvmField var _hostsUp = 0
-
- override val hostsDown: Int
- get() = _hostsDown
- @JvmField var _hostsDown = 0
-
- override val serversPending: Int
- get() = _serversPending
- @JvmField var _serversPending = 0
-
- override val serversActive: Int
- get() = _serversActive
- @JvmField var _serversActive = 0
-
- override val attemptsSuccess: Int
- get() = _attemptsSuccess
- @JvmField var _attemptsSuccess = 0
-
- override val attemptsFailure: Int
- get() = _attemptsFailure
- @JvmField var _attemptsFailure = 0
-
- override val attemptsError: Int
- get() = _attemptsError
- @JvmField var _attemptsError = 0
-
- /**
- * Record the timestamp of a [point] for this aggregator.
- */
- fun recordTimestamp(point: PointData) {
- _timestamp = Instant.ofEpochMilli(point.epochNanos / 1_000_000L) // ns to ms
- }
- }
-
- /**
- * An aggregator for host metrics before they are reported.
- */
- internal class HostAggregator(resource: Resource) : HostTableReader {
- /**
- * The static information about this host.
- */
- override val host = HostInfo(
- resource.attributes[HOST_ID]!!,
- resource.attributes[HOST_NAME] ?: "",
- resource.attributes[HOST_ARCH] ?: "",
- resource.attributes[HOST_NCPUS]?.toInt() ?: 0,
- resource.attributes[HOST_MEM_CAPACITY] ?: 0,
- )
-
- override val timestamp: Instant
- get() = _timestamp
- private var _timestamp = Instant.MIN
-
- override val guestsTerminated: Int
- get() = _guestsTerminated
- @JvmField var _guestsTerminated = 0
-
- override val guestsRunning: Int
- get() = _guestsRunning
- @JvmField var _guestsRunning = 0
-
- override val guestsError: Int
- get() = _guestsError
- @JvmField var _guestsError = 0
-
- override val guestsInvalid: Int
- get() = _guestsInvalid
- @JvmField var _guestsInvalid = 0
-
- override val cpuLimit: Double
- get() = _cpuLimit
- @JvmField var _cpuLimit = 0.0
-
- override val cpuUsage: Double
- get() = _cpuUsage
- @JvmField var _cpuUsage = 0.0
-
- override val cpuDemand: Double
- get() = _cpuDemand
- @JvmField var _cpuDemand = 0.0
-
- override val cpuUtilization: Double
- get() = _cpuUtilization
- @JvmField var _cpuUtilization = 0.0
-
- override val cpuActiveTime: Long
- get() = _cpuActiveTime - previousCpuActiveTime
- @JvmField var _cpuActiveTime = 0L
- private var previousCpuActiveTime = 0L
-
- override val cpuIdleTime: Long
- get() = _cpuIdleTime - previousCpuIdleTime
- @JvmField var _cpuIdleTime = 0L
- private var previousCpuIdleTime = 0L
-
- override val cpuStealTime: Long
- get() = _cpuStealTime - previousCpuStealTime
- @JvmField var _cpuStealTime = 0L
- private var previousCpuStealTime = 0L
-
- override val cpuLostTime: Long
- get() = _cpuLostTime - previousCpuLostTime
- @JvmField var _cpuLostTime = 0L
- private var previousCpuLostTime = 0L
-
- override val powerUsage: Double
- get() = _powerUsage
- @JvmField var _powerUsage = 0.0
-
- override val powerTotal: Double
- get() = _powerTotal - previousPowerTotal
- @JvmField var _powerTotal = 0.0
- private var previousPowerTotal = 0.0
-
- override val uptime: Long
- get() = _uptime - previousUptime
- @JvmField var _uptime = 0L
- private var previousUptime = 0L
-
- override val downtime: Long
- get() = _downtime - previousDowntime
- @JvmField var _downtime = 0L
- private var previousDowntime = 0L
-
- override val bootTime: Instant?
- get() = _bootTime
- @JvmField var _bootTime: Instant? = null
-
- /**
- * Finish the aggregation for this cycle.
- */
- fun reset() {
- // Reset intermediate state for next aggregation
- previousCpuActiveTime = _cpuActiveTime
- previousCpuIdleTime = _cpuIdleTime
- previousCpuStealTime = _cpuStealTime
- previousCpuLostTime = _cpuLostTime
- previousPowerTotal = _powerTotal
- previousUptime = _uptime
- previousDowntime = _downtime
-
- _guestsTerminated = 0
- _guestsRunning = 0
- _guestsError = 0
- _guestsInvalid = 0
-
- _cpuLimit = 0.0
- _cpuUsage = 0.0
- _cpuDemand = 0.0
- _cpuUtilization = 0.0
-
- _powerUsage = 0.0
- }
-
- /**
- * Record the timestamp of a [point] for this aggregator.
- */
- fun recordTimestamp(point: PointData) {
- _timestamp = Instant.ofEpochMilli(point.epochNanos / 1_000_000L) // ns to ms
- }
- }
-
- /**
- * An aggregator for server metrics before they are reported.
- */
- internal class ServerAggregator(attributes: Attributes) : ServerTableReader {
- /**
- * The static information about this server.
- */
- override val server = ServerInfo(
- attributes[ResourceAttributes.HOST_ID]!!,
- attributes[ResourceAttributes.HOST_NAME]!!,
- attributes[ResourceAttributes.HOST_TYPE]!!,
- attributes[ResourceAttributes.HOST_ARCH]!!,
- attributes[ResourceAttributes.HOST_IMAGE_ID]!!,
- attributes[ResourceAttributes.HOST_IMAGE_NAME]!!,
- attributes[AttributeKey.longKey("host.num_cpus")]!!.toInt(),
- attributes[AttributeKey.longKey("host.mem_capacity")]!!,
- )
-
- /**
- * The [HostInfo] of the host on which the server is hosted.
- */
- override val host: HostInfo?
- get() = _host
- @JvmField var _host: HostInfo? = null
-
- private var _timestamp = Instant.MIN
- override val timestamp: Instant
- get() = _timestamp
-
- override val uptime: Long
- get() = _uptime - previousUptime
- @JvmField var _uptime: Long = 0
- private var previousUptime = 0L
-
- override val downtime: Long
- get() = _downtime - previousDowntime
- @JvmField var _downtime: Long = 0
- private var previousDowntime = 0L
-
- override val provisionTime: Instant?
- get() = _provisionTime
- @JvmField var _provisionTime: Instant? = null
-
- override val bootTime: Instant?
- get() = _bootTime
- @JvmField var _bootTime: Instant? = null
-
- override val cpuLimit: Double
- get() = _cpuLimit
- @JvmField var _cpuLimit = 0.0
-
- override val cpuActiveTime: Long
- get() = _cpuActiveTime - previousCpuActiveTime
- @JvmField var _cpuActiveTime = 0L
- private var previousCpuActiveTime = 0L
-
- override val cpuIdleTime: Long
- get() = _cpuIdleTime - previousCpuIdleTime
- @JvmField var _cpuIdleTime = 0L
- private var previousCpuIdleTime = 0L
-
- override val cpuStealTime: Long
- get() = _cpuStealTime - previousCpuStealTime
- @JvmField var _cpuStealTime = 0L
- private var previousCpuStealTime = 0L
-
- override val cpuLostTime: Long
- get() = _cpuLostTime - previousCpuLostTime
- @JvmField var _cpuLostTime = 0L
- private var previousCpuLostTime = 0L
-
- /**
- * Finish the aggregation for this cycle.
- */
- fun reset() {
- previousUptime = _uptime
- previousDowntime = _downtime
- previousCpuActiveTime = _cpuActiveTime
- previousCpuIdleTime = _cpuIdleTime
- previousCpuStealTime = _cpuStealTime
- previousCpuLostTime = _cpuLostTime
-
- _host = null
- _cpuLimit = 0.0
- }
-
- /**
- * Record the timestamp of a [point] for this aggregator.
- */
- fun recordTimestamp(point: PointData) {
- _timestamp = Instant.ofEpochMilli(point.epochNanos / 1_000_000L) // ns to ms
- }
- }
-
- private companion object {
- private val STATE_KEY = AttributeKey.stringKey("state")
- private val RESULT_KEY = AttributeKey.stringKey("result")
- }
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricExporter.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricExporter.kt
deleted file mode 100644
index 3ab6c7b2..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricExporter.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute
-
-import io.opentelemetry.sdk.common.CompletableResultCode
-import io.opentelemetry.sdk.metrics.data.*
-import io.opentelemetry.sdk.metrics.export.MetricExporter
-import mu.KotlinLogging
-
-/**
- * A [MetricExporter] that redirects data to a [ComputeMonitor] implementation.
- */
-public abstract class ComputeMetricExporter : MetricExporter, ComputeMonitor {
- /**
- * The logging instance for this exporter.
- */
- private val logger = KotlinLogging.logger {}
-
- /**
- * A [ComputeMetricAggregator] that actually performs the aggregation.
- */
- private val agg = ComputeMetricAggregator()
-
- override fun export(metrics: Collection<MetricData>): CompletableResultCode {
- return try {
- agg.process(metrics)
- agg.collect(this)
-
- CompletableResultCode.ofSuccess()
- } catch (e: Throwable) {
- logger.warn(e) { "Failed to export results" }
- CompletableResultCode.ofFailure()
- }
- }
-
- override fun flush(): CompletableResultCode = CompletableResultCode.ofSuccess()
-
- override fun shutdown(): CompletableResultCode = CompletableResultCode.ofSuccess()
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricReader.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricReader.kt
deleted file mode 100644
index 593203fc..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMetricReader.kt
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Copyright (c) 2022 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute
-
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.isActive
-import kotlinx.coroutines.launch
-import mu.KotlinLogging
-import org.opendc.compute.api.Server
-import org.opendc.compute.service.ComputeService
-import org.opendc.compute.service.driver.Host
-import org.opendc.telemetry.compute.table.*
-import java.time.Clock
-import java.time.Duration
-import java.time.Instant
-
-/**
- * A helper class to collect metrics from a [ComputeService] instance and automatically export the metrics every
- * export interval.
- *
- * @param scope The [CoroutineScope] to run the reader in.
- * @param clock The virtual clock.
- * @param service The [ComputeService] to monitor.
- * @param servers The [Server]s to monitor.
- * @param monitor The monitor to export the metrics to.
- * @param exportInterval The export interval.
- */
-public class ComputeMetricReader(
- scope: CoroutineScope,
- clock: Clock,
- private val service: ComputeService,
- private val servers: List<Server>,
- private val monitor: ComputeMonitor,
- private val exportInterval: Duration = Duration.ofMinutes(5)
-) : AutoCloseable {
- private val logger = KotlinLogging.logger {}
-
- /**
- * Aggregator for service metrics.
- */
- private val serviceTableReader = ServiceTableReaderImpl(service)
-
- /**
- * Mapping from [Host] instances to [HostTableReaderImpl]
- */
- private val hostTableReaders = mutableMapOf<Host, HostTableReaderImpl>()
-
- /**
- * Mapping from [Server] instances to [ServerTableReaderImpl]
- */
- private val serverTableReaders = mutableMapOf<Server, ServerTableReaderImpl>()
-
- /**
- * The background job that is responsible for collecting the metrics every cycle.
- */
- private val job = scope.launch {
- val intervalMs = exportInterval.toMillis()
-
- try {
- while (isActive) {
- delay(intervalMs)
-
- try {
- val now = clock.instant()
-
- for (host in service.hosts) {
- val reader = hostTableReaders.computeIfAbsent(host) { HostTableReaderImpl(it) }
- reader.record(now)
- monitor.record(reader)
- reader.reset()
- }
-
- for (server in servers) {
- val reader = serverTableReaders.computeIfAbsent(server) { ServerTableReaderImpl(service, it) }
- reader.record(now)
- monitor.record(reader)
- reader.reset()
- }
-
- serviceTableReader.record(now)
- monitor.record(serviceTableReader)
- } catch (cause: Throwable) {
- logger.warn(cause) { "Exporter threw an Exception" }
- }
- }
- } finally {
- if (monitor is AutoCloseable) {
- monitor.close()
- }
- }
- }
-
- override fun close() {
- job.cancel()
- }
-
- /**
- * An aggregator for service metrics before they are reported.
- */
- private class ServiceTableReaderImpl(private val service: ComputeService) : ServiceTableReader {
- private var _timestamp: Instant = Instant.MIN
- override val timestamp: Instant
- get() = _timestamp
-
- override val hostsUp: Int
- get() = _hostsUp
- private var _hostsUp = 0
-
- override val hostsDown: Int
- get() = _hostsDown
- private var _hostsDown = 0
-
- override val serversPending: Int
- get() = _serversPending
- private var _serversPending = 0
-
- override val serversActive: Int
- get() = _serversActive
- private var _serversActive = 0
-
- override val attemptsSuccess: Int
- get() = _attemptsSuccess
- private var _attemptsSuccess = 0
-
- override val attemptsFailure: Int
- get() = _attemptsFailure
- private var _attemptsFailure = 0
-
- override val attemptsError: Int
- get() = _attemptsError
- private var _attemptsError = 0
-
- /**
- * Record the next cycle.
- */
- fun record(now: Instant) {
- _timestamp = now
-
- val stats = service.getSchedulerStats()
- _hostsUp = stats.hostsAvailable
- _hostsDown = stats.hostsUnavailable
- _serversPending = stats.serversPending
- _serversActive = stats.serversActive
- _attemptsSuccess = stats.attemptsSuccess.toInt()
- _attemptsFailure = stats.attemptsFailure.toInt()
- _attemptsError = stats.attemptsError.toInt()
- }
- }
-
- /**
- * An aggregator for host metrics before they are reported.
- */
- private class HostTableReaderImpl(host: Host) : HostTableReader {
- private val _host = host
-
- override val host: HostInfo = HostInfo(host.uid.toString(), host.name, "x86", host.model.cpuCount, host.model.memoryCapacity)
-
- override val timestamp: Instant
- get() = _timestamp
- private var _timestamp = Instant.MIN
-
- override val guestsTerminated: Int
- get() = _guestsTerminated
- private var _guestsTerminated = 0
-
- override val guestsRunning: Int
- get() = _guestsRunning
- private var _guestsRunning = 0
-
- override val guestsError: Int
- get() = _guestsError
- private var _guestsError = 0
-
- override val guestsInvalid: Int
- get() = _guestsInvalid
- private var _guestsInvalid = 0
-
- override val cpuLimit: Double
- get() = _cpuLimit
- private var _cpuLimit = 0.0
-
- override val cpuUsage: Double
- get() = _cpuUsage
- private var _cpuUsage = 0.0
-
- override val cpuDemand: Double
- get() = _cpuDemand
- private var _cpuDemand = 0.0
-
- override val cpuUtilization: Double
- get() = _cpuUtilization
- private var _cpuUtilization = 0.0
-
- override val cpuActiveTime: Long
- get() = _cpuActiveTime - previousCpuActiveTime
- private var _cpuActiveTime = 0L
- private var previousCpuActiveTime = 0L
-
- override val cpuIdleTime: Long
- get() = _cpuIdleTime - previousCpuIdleTime
- private var _cpuIdleTime = 0L
- private var previousCpuIdleTime = 0L
-
- override val cpuStealTime: Long
- get() = _cpuStealTime - previousCpuStealTime
- private var _cpuStealTime = 0L
- private var previousCpuStealTime = 0L
-
- override val cpuLostTime: Long
- get() = _cpuLostTime - previousCpuLostTime
- private var _cpuLostTime = 0L
- private var previousCpuLostTime = 0L
-
- override val powerUsage: Double
- get() = _powerUsage
- private var _powerUsage = 0.0
-
- override val powerTotal: Double
- get() = _powerTotal - previousPowerTotal
- private var _powerTotal = 0.0
- private var previousPowerTotal = 0.0
-
- override val uptime: Long
- get() = _uptime - previousUptime
- private var _uptime = 0L
- private var previousUptime = 0L
-
- override val downtime: Long
- get() = _downtime - previousDowntime
- private var _downtime = 0L
- private var previousDowntime = 0L
-
- override val bootTime: Instant?
- get() = _bootTime
- private var _bootTime: Instant? = null
-
- /**
- * Record the next cycle.
- */
- fun record(now: Instant) {
- val hostCpuStats = _host.getCpuStats()
- val hostSysStats = _host.getSystemStats()
-
- _timestamp = now
- _guestsTerminated = hostSysStats.guestsTerminated
- _guestsRunning = hostSysStats.guestsRunning
- _guestsError = hostSysStats.guestsError
- _guestsInvalid = hostSysStats.guestsInvalid
- _cpuLimit = hostCpuStats.capacity
- _cpuDemand = hostCpuStats.demand
- _cpuUsage = hostCpuStats.usage
- _cpuUtilization = hostCpuStats.utilization
- _cpuActiveTime = hostCpuStats.activeTime
- _cpuIdleTime = hostCpuStats.idleTime
- _cpuStealTime = hostCpuStats.stealTime
- _cpuLostTime = hostCpuStats.lostTime
- _powerUsage = hostSysStats.powerUsage
- _powerTotal = hostSysStats.energyUsage
- _uptime = hostSysStats.uptime.toMillis()
- _downtime = hostSysStats.downtime.toMillis()
- _bootTime = hostSysStats.bootTime
- }
-
- /**
- * Finish the aggregation for this cycle.
- */
- fun reset() {
- // Reset intermediate state for next aggregation
- previousCpuActiveTime = _cpuActiveTime
- previousCpuIdleTime = _cpuIdleTime
- previousCpuStealTime = _cpuStealTime
- previousCpuLostTime = _cpuLostTime
- previousPowerTotal = _powerTotal
- previousUptime = _uptime
- previousDowntime = _downtime
-
- _guestsTerminated = 0
- _guestsRunning = 0
- _guestsError = 0
- _guestsInvalid = 0
-
- _cpuLimit = 0.0
- _cpuUsage = 0.0
- _cpuDemand = 0.0
- _cpuUtilization = 0.0
-
- _powerUsage = 0.0
- }
- }
-
- /**
- * An aggregator for server metrics before they are reported.
- */
- private class ServerTableReaderImpl(private val service: ComputeService, server: Server) : ServerTableReader {
- private val _server = server
-
- /**
- * The static information about this server.
- */
- override val server = ServerInfo(
- server.uid.toString(),
- server.name,
- "vm",
- "x86",
- server.image.uid.toString(),
- server.image.name,
- server.flavor.cpuCount,
- server.flavor.memorySize
- )
-
- /**
- * The [HostInfo] of the host on which the server is hosted.
- */
- override var host: HostInfo? = null
- private var _host: Host? = null
-
- private var _timestamp = Instant.MIN
- override val timestamp: Instant
- get() = _timestamp
-
- override val uptime: Long
- get() = _uptime - previousUptime
- private var _uptime: Long = 0
- private var previousUptime = 0L
-
- override val downtime: Long
- get() = _downtime - previousDowntime
- private var _downtime: Long = 0
- private var previousDowntime = 0L
-
- override val provisionTime: Instant?
- get() = _provisionTime
- private var _provisionTime: Instant? = null
-
- override val bootTime: Instant?
- get() = _bootTime
- private var _bootTime: Instant? = null
-
- override val cpuLimit: Double
- get() = _cpuLimit
- private var _cpuLimit = 0.0
-
- override val cpuActiveTime: Long
- get() = _cpuActiveTime - previousCpuActiveTime
- private var _cpuActiveTime = 0L
- private var previousCpuActiveTime = 0L
-
- override val cpuIdleTime: Long
- get() = _cpuIdleTime - previousCpuIdleTime
- private var _cpuIdleTime = 0L
- private var previousCpuIdleTime = 0L
-
- override val cpuStealTime: Long
- get() = _cpuStealTime - previousCpuStealTime
- private var _cpuStealTime = 0L
- private var previousCpuStealTime = 0L
-
- override val cpuLostTime: Long
- get() = _cpuLostTime - previousCpuLostTime
- private var _cpuLostTime = 0L
- private var previousCpuLostTime = 0L
-
- /**
- * Record the next cycle.
- */
- fun record(now: Instant) {
- val newHost = service.lookupHost(_server)
- if (newHost != null && newHost.uid != _host?.uid) {
- _host = newHost
- host = HostInfo(newHost.uid.toString(), newHost.name, "x86", newHost.model.cpuCount, newHost.model.memoryCapacity)
- }
-
- val cpuStats = _host?.getCpuStats(_server)
- val sysStats = _host?.getSystemStats(_server)
-
- _timestamp = now
- _cpuLimit = cpuStats?.capacity ?: 0.0
- _cpuActiveTime = cpuStats?.activeTime ?: 0
- _cpuIdleTime = cpuStats?.idleTime ?: 0
- _cpuStealTime = cpuStats?.stealTime ?: 0
- _cpuLostTime = cpuStats?.lostTime ?: 0
- _uptime = sysStats?.uptime?.toMillis() ?: 0
- _downtime = sysStats?.downtime?.toMillis() ?: 0
- _provisionTime = _server.launchedAt
- _bootTime = sysStats?.bootTime
- }
-
- /**
- * Finish the aggregation for this cycle.
- */
- fun reset() {
- previousUptime = _uptime
- previousDowntime = _downtime
- previousCpuActiveTime = _cpuActiveTime
- previousCpuIdleTime = _cpuIdleTime
- previousCpuStealTime = _cpuStealTime
- previousCpuLostTime = _cpuLostTime
-
- _host = null
- _cpuLimit = 0.0
- }
- }
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMonitor.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMonitor.kt
deleted file mode 100644
index 64b5f337..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/ComputeMonitor.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute
-
-import org.opendc.telemetry.compute.table.HostTableReader
-import org.opendc.telemetry.compute.table.ServerTableReader
-import org.opendc.telemetry.compute.table.ServiceTableReader
-
-/**
- * A monitor that tracks the metrics and events of the OpenDC Compute service.
- */
-public interface ComputeMonitor {
- /**
- * Record an entry with the specified [reader].
- */
- public fun record(reader: ServerTableReader) {}
-
- /**
- * Record an entry with the specified [reader].
- */
- public fun record(reader: HostTableReader) {}
-
- /**
- * Record an entry with the specified [reader].
- */
- public fun record(reader: ServiceTableReader) {}
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/Helpers.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/Helpers.kt
deleted file mode 100644
index 41315b15..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/Helpers.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute
-
-import io.opentelemetry.sdk.metrics.export.MetricProducer
-import org.opendc.telemetry.compute.table.ServiceData
-import org.opendc.telemetry.compute.table.ServiceTableReader
-import org.opendc.telemetry.compute.table.toServiceData
-
-/**
- * Collect the metrics of the compute service.
- */
-public fun collectServiceMetrics(metricProducer: MetricProducer): ServiceData {
- lateinit var serviceData: ServiceData
- val agg = ComputeMetricAggregator()
- val monitor = object : ComputeMonitor {
- override fun record(reader: ServiceTableReader) {
- serviceData = reader.toServiceData()
- }
- }
-
- agg.process(metricProducer.collectAllMetrics())
- agg.collect(monitor)
- return serviceData
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/HostAttributes.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/HostAttributes.kt
deleted file mode 100644
index 7dca6186..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/HostAttributes.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-@file:JvmName("HostAttributes")
-package org.opendc.telemetry.compute
-
-import io.opentelemetry.api.common.AttributeKey
-
-/**
- * The identifier of the node hosting virtual machines.
- */
-public val HOST_ID: AttributeKey<String> = AttributeKey.stringKey("node.id")
-
-/**
- * The name of the node hosting virtual machines.
- */
-public val HOST_NAME: AttributeKey<String> = AttributeKey.stringKey("node.name")
-
-/**
- * The CPU architecture of the host node.
- */
-public val HOST_ARCH: AttributeKey<String> = AttributeKey.stringKey("node.arch")
-
-/**
- * The number of CPUs in the host node.
- */
-public val HOST_NCPUS: AttributeKey<Long> = AttributeKey.longKey("node.num_cpus")
-
-/**
- * The amount of memory installed in the host node in MiB.
- */
-public val HOST_MEM_CAPACITY: AttributeKey<Long> = AttributeKey.longKey("node.mem_capacity")
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostInfo.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostInfo.kt
deleted file mode 100644
index d9a5906b..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostInfo.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute.table
-
-/**
- * Information about a host exposed to the telemetry service.
- */
-public data class HostInfo(val id: String, val name: String, val arch: String, val cpuCount: Int, val memCapacity: Long)
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostTableReader.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostTableReader.kt
deleted file mode 100644
index 1e1ad94e..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/HostTableReader.kt
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute.table
-
-import java.time.Instant
-
-/**
- * An interface that is used to read a row of a host trace entry.
- */
-public interface HostTableReader {
- /**
- * The timestamp of the current entry of the reader.
- */
- public val timestamp: Instant
-
- /**
- * The [HostInfo] of the host to which the row belongs to.
- */
- public val host: HostInfo
-
- /**
- * The number of guests that are in a terminated state.
- */
- public val guestsTerminated: Int
-
- /**
- * The number of guests that are in a running state.
- */
- public val guestsRunning: Int
-
- /**
- * The number of guests that are in an error state.
- */
- public val guestsError: Int
-
- /**
- * The number of guests that are in an unknown state.
- */
- public val guestsInvalid: Int
-
- /**
- * The capacity of the CPUs in the host (in MHz).
- */
- public val cpuLimit: Double
-
- /**
- * The usage of all CPUs in the host (in MHz).
- */
- public val cpuUsage: Double
-
- /**
- * The demand of all vCPUs of the guests (in MHz)
- */
- public val cpuDemand: Double
-
- /**
- * The CPU utilization of the host.
- */
- public val cpuUtilization: Double
-
- /**
- * The duration (in seconds) that a CPU was active in the host.
- */
- public val cpuActiveTime: Long
-
- /**
- * The duration (in seconds) that a CPU was idle in the host.
- */
- public val cpuIdleTime: Long
-
- /**
- * The duration (in seconds) that a vCPU wanted to run, but no capacity was available.
- */
- public val cpuStealTime: Long
-
- /**
- * The duration (in seconds) of CPU time that was lost due to interference.
- */
- public val cpuLostTime: Long
-
- /**
- * The current power usage of the host in W.
- */
- public val powerUsage: Double
-
- /**
- * The total power consumption of the host since last time in J.
- */
- public val powerTotal: Double
-
- /**
- * The uptime of the host since last time in ms.
- */
- public val uptime: Long
-
- /**
- * The downtime of the host since last time in ms.
- */
- public val downtime: Long
-
- /**
- * The [Instant] at which the host booted.
- */
- public val bootTime: Instant?
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerInfo.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerInfo.kt
deleted file mode 100644
index b16e5f3d..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerInfo.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute.table
-
-/**
- * Static information about a server exposed to the telemetry service.
- */
-public data class ServerInfo(
- val id: String,
- val name: String,
- val type: String,
- val arch: String,
- val imageId: String,
- val imageName: String,
- val cpuCount: Int,
- val memCapacity: Long
-)
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerTableReader.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerTableReader.kt
deleted file mode 100644
index c23d1467..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServerTableReader.kt
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute.table
-
-import java.time.Instant
-
-/**
- * An interface that is used to read a row of a server trace entry.
- */
-public interface ServerTableReader {
- /**
- * The timestamp of the current entry of the reader.
- */
- public val timestamp: Instant
-
- /**
- * The [ServerInfo] of the server to which the row belongs to.
- */
- public val server: ServerInfo
-
- /**
- * The [HostInfo] of the host on which the server is hosted or `null` if it has no host.
- */
- public val host: HostInfo?
-
- /**
- * The uptime of the host since last time in ms.
- */
- public val uptime: Long
-
- /**
- * The downtime of the host since last time in ms.
- */
- public val downtime: Long
-
- /**
- * The [Instant] at which the server was enqueued for the scheduler.
- */
- public val provisionTime: Instant?
-
- /**
- * The [Instant] at which the server booted.
- */
- public val bootTime: Instant?
-
- /**
- * The capacity of the CPUs of the servers (in MHz).
- */
- public val cpuLimit: Double
-
- /**
- * The duration (in seconds) that a CPU was active in the server.
- */
- public val cpuActiveTime: Long
-
- /**
- * The duration (in seconds) that a CPU was idle in the server.
- */
- public val cpuIdleTime: Long
-
- /**
- * The duration (in seconds) that a vCPU wanted to run, but no capacity was available.
- */
- public val cpuStealTime: Long
-
- /**
- * The duration (in seconds) of CPU time that was lost due to interference.
- */
- public val cpuLostTime: Long
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceData.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceData.kt
deleted file mode 100644
index 39bf96f4..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceData.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute.table
-
-import java.time.Instant
-
-/**
- * A trace entry for the compute service.
- */
-public data class ServiceData(
- val timestamp: Instant,
- val hostsUp: Int,
- val hostsDown: Int,
- val serversPending: Int,
- val serversActive: Int,
- val attemptsSuccess: Int,
- val attemptsFailure: Int,
- val attemptsError: Int
-)
-
-/**
- * Convert a [ServiceTableReader] into a persistent object.
- */
-public fun ServiceTableReader.toServiceData(): ServiceData {
- return ServiceData(timestamp, hostsUp, hostsDown, serversPending, serversActive, attemptsSuccess, attemptsFailure, attemptsError)
-}
diff --git a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceTableReader.kt b/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceTableReader.kt
deleted file mode 100644
index 908f6748..00000000
--- a/opendc-telemetry/opendc-telemetry-compute/src/main/kotlin/org/opendc/telemetry/compute/table/ServiceTableReader.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2021 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.telemetry.compute.table
-
-import java.time.Instant
-
-/**
- * An interface that is used to read a row of a service trace entry.
- */
-public interface ServiceTableReader {
- /**
- * The timestamp of the current entry of the reader.
- */
- public val timestamp: Instant
-
- /**
- * The number of hosts that are up at this instant.
- */
- public val hostsUp: Int
-
- /**
- * The number of hosts that are down at this instant.
- */
- public val hostsDown: Int
-
- /**
- * The number of servers that are pending to be scheduled.
- */
- public val serversPending: Int
-
- /**
- * The number of servers that are currently active.
- */
- public val serversActive: Int
-
- /**
- * The scheduling attempts that were successful.
- */
- public val attemptsSuccess: Int
-
- /**
- * The scheduling attempts that were unsuccessful due to client error.
- */
- public val attemptsFailure: Int
-
- /**
- * The scheduling attempts that were unsuccessful due to scheduler error.
- */
- public val attemptsError: Int
-}