summaryrefslogtreecommitdiff
path: root/opendc-faas/opendc-faas-service/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-08-25 14:06:39 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-08-25 18:04:36 +0200
commitf111081627280d4e7e1d7147c56cdce708e32433 (patch)
tree509c005e0b94c89eeb61cc8df0aee360c1540943 /opendc-faas/opendc-faas-service/src
parentac48fa12f36180de31154a7c828b4dc281dac94b (diff)
build: Upgrade to OpenTelemetry 1.5
This change upgrades the OpenTelemetry dependency to version 1.5, which contains various breaking changes in the metrics API.
Diffstat (limited to 'opendc-faas/opendc-faas-service/src')
-rw-r--r--opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/FunctionObject.kt44
-rw-r--r--opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/internal/FaaSServiceImpl.kt6
2 files changed, 29 insertions, 21 deletions
diff --git a/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/FunctionObject.kt b/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/FunctionObject.kt
index 7c7621b8..a1cb1dbf 100644
--- a/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/FunctionObject.kt
+++ b/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/FunctionObject.kt
@@ -22,11 +22,12 @@
package org.opendc.faas.service
+import io.opentelemetry.api.common.AttributeKey
+import io.opentelemetry.api.common.Attributes
import io.opentelemetry.api.metrics.BoundLongCounter
+import io.opentelemetry.api.metrics.BoundLongHistogram
import io.opentelemetry.api.metrics.BoundLongUpDownCounter
-import io.opentelemetry.api.metrics.BoundLongValueRecorder
import io.opentelemetry.api.metrics.Meter
-import io.opentelemetry.api.metrics.common.Labels
import org.opendc.faas.service.deployer.FunctionInstance
import java.util.*
@@ -42,76 +43,83 @@ public class FunctionObject(
meta: Map<String, Any>
) : AutoCloseable {
/**
+ * The function identifier attached to the metrics.
+ */
+ private val functionId = AttributeKey.stringKey("function")
+
+ /**
* The total amount of function invocations received by the function.
*/
- public val invocations: BoundLongCounter = meter.longCounterBuilder("function.invocations.total")
+ public val invocations: BoundLongCounter = meter.counterBuilder("function.invocations.total")
.setDescription("Number of function invocations")
.setUnit("1")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The amount of function invocations that could be handled directly.
*/
- public val timelyInvocations: BoundLongCounter = meter.longCounterBuilder("function.invocations.warm")
+ public val timelyInvocations: BoundLongCounter = meter.counterBuilder("function.invocations.warm")
.setDescription("Number of function invocations handled directly")
.setUnit("1")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The amount of function invocations that were delayed due to function deployment.
*/
- public val delayedInvocations: BoundLongCounter = meter.longCounterBuilder("function.invocations.cold")
+ public val delayedInvocations: BoundLongCounter = meter.counterBuilder("function.invocations.cold")
.setDescription("Number of function invocations that are delayed")
.setUnit("1")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The amount of function invocations that failed.
*/
- public val failedInvocations: BoundLongCounter = meter.longCounterBuilder("function.invocations.failed")
+ public val failedInvocations: BoundLongCounter = meter.counterBuilder("function.invocations.failed")
.setDescription("Number of function invocations that failed")
.setUnit("1")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The amount of instances for this function.
*/
- public val activeInstances: BoundLongUpDownCounter = meter.longUpDownCounterBuilder("function.instances.active")
+ public val activeInstances: BoundLongUpDownCounter = meter.upDownCounterBuilder("function.instances.active")
.setDescription("Number of active function instances")
.setUnit("1")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The amount of idle instances for this function.
*/
- public val idleInstances: BoundLongUpDownCounter = meter.longUpDownCounterBuilder("function.instances.idle")
+ public val idleInstances: BoundLongUpDownCounter = meter.upDownCounterBuilder("function.instances.idle")
.setDescription("Number of idle function instances")
.setUnit("1")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The time that the function waited.
*/
- public val waitTime: BoundLongValueRecorder = meter.longValueRecorderBuilder("function.time.wait")
+ public val waitTime: BoundLongHistogram = meter.histogramBuilder("function.time.wait")
+ .ofLongs()
.setDescription("Time the function has to wait before being started")
.setUnit("ms")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The time that the function was running.
*/
- public val activeTime: BoundLongValueRecorder = meter.longValueRecorderBuilder("function.time.active")
+ public val activeTime: BoundLongHistogram = meter.histogramBuilder("function.time.active")
+ .ofLongs()
.setDescription("Time the function was running")
.setUnit("ms")
.build()
- .bind(Labels.of("function", uid.toString()))
+ .bind(Attributes.of(functionId, uid.toString()))
/**
* The instances associated with this function.
diff --git a/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/internal/FaaSServiceImpl.kt b/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/internal/FaaSServiceImpl.kt
index b169436f..ccf9a5d9 100644
--- a/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/internal/FaaSServiceImpl.kt
+++ b/opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/internal/FaaSServiceImpl.kt
@@ -93,7 +93,7 @@ internal class FaaSServiceImpl(
/**
* The total amount of function invocations received by the service.
*/
- private val _invocations = meter.longCounterBuilder("service.invocations.total")
+ private val _invocations = meter.counterBuilder("service.invocations.total")
.setDescription("Number of function invocations")
.setUnit("1")
.build()
@@ -101,7 +101,7 @@ internal class FaaSServiceImpl(
/**
* The amount of function invocations that could be handled directly.
*/
- private val _timelyInvocations = meter.longCounterBuilder("service.invocations.warm")
+ private val _timelyInvocations = meter.counterBuilder("service.invocations.warm")
.setDescription("Number of function invocations handled directly")
.setUnit("1")
.build()
@@ -109,7 +109,7 @@ internal class FaaSServiceImpl(
/**
* The amount of function invocations that were delayed due to function deployment.
*/
- private val _delayedInvocations = meter.longCounterBuilder("service.invocations.cold")
+ private val _delayedInvocations = meter.counterBuilder("service.invocations.cold")
.setDescription("Number of function invocations that are delayed")
.setUnit("1")
.build()