summaryrefslogtreecommitdiff
path: root/opendc-faas
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-faas')
-rw-r--r--opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/FunctionObject.kt30
-rw-r--r--opendc-faas/opendc-faas-service/src/main/kotlin/org/opendc/faas/service/internal/FaaSServiceImpl.kt22
2 files changed, 22 insertions, 30 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 54df2b59..836231c8 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
@@ -24,9 +24,9 @@ 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.LongCounter
+import io.opentelemetry.api.metrics.LongHistogram
+import io.opentelemetry.api.metrics.LongUpDownCounter
import io.opentelemetry.api.metrics.Meter
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes
import org.opendc.faas.service.deployer.FunctionInstance
@@ -56,76 +56,68 @@ public class FunctionObject(
/**
* The total amount of function invocations received by the function.
*/
- public val invocations: BoundLongCounter = meter.counterBuilder("function.invocations.total")
+ public val invocations: LongCounter = meter.counterBuilder("function.invocations.total")
.setDescription("Number of function invocations")
.setUnit("1")
.build()
- .bind(attributes)
/**
* The amount of function invocations that could be handled directly.
*/
- public val timelyInvocations: BoundLongCounter = meter.counterBuilder("function.invocations.warm")
+ public val timelyInvocations: LongCounter = meter.counterBuilder("function.invocations.warm")
.setDescription("Number of function invocations handled directly")
.setUnit("1")
.build()
- .bind(attributes)
/**
* The amount of function invocations that were delayed due to function deployment.
*/
- public val delayedInvocations: BoundLongCounter = meter.counterBuilder("function.invocations.cold")
+ public val delayedInvocations: LongCounter = meter.counterBuilder("function.invocations.cold")
.setDescription("Number of function invocations that are delayed")
.setUnit("1")
.build()
- .bind(attributes)
/**
* The amount of function invocations that failed.
*/
- public val failedInvocations: BoundLongCounter = meter.counterBuilder("function.invocations.failed")
+ public val failedInvocations: LongCounter = meter.counterBuilder("function.invocations.failed")
.setDescription("Number of function invocations that failed")
.setUnit("1")
.build()
- .bind(attributes)
/**
* The amount of instances for this function.
*/
- public val activeInstances: BoundLongUpDownCounter = meter.upDownCounterBuilder("function.instances.active")
+ public val activeInstances: LongUpDownCounter = meter.upDownCounterBuilder("function.instances.active")
.setDescription("Number of active function instances")
.setUnit("1")
.build()
- .bind(attributes)
/**
* The amount of idle instances for this function.
*/
- public val idleInstances: BoundLongUpDownCounter = meter.upDownCounterBuilder("function.instances.idle")
+ public val idleInstances: LongUpDownCounter = meter.upDownCounterBuilder("function.instances.idle")
.setDescription("Number of idle function instances")
.setUnit("1")
.build()
- .bind(attributes)
/**
* The time that the function waited.
*/
- public val waitTime: BoundLongHistogram = meter.histogramBuilder("function.time.wait")
+ public val waitTime: LongHistogram = meter.histogramBuilder("function.time.wait")
.ofLongs()
.setDescription("Time the function has to wait before being started")
.setUnit("ms")
.build()
- .bind(attributes)
/**
* The time that the function was running.
*/
- public val activeTime: BoundLongHistogram = meter.histogramBuilder("function.time.active")
+ public val activeTime: LongHistogram = meter.histogramBuilder("function.time.active")
.ofLongs()
.setDescription("Time the function was running")
.setUnit("ms")
.build()
- .bind(attributes)
/**
* 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 3b560cd3..c285585a 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
@@ -226,7 +226,7 @@ internal class FaaSServiceImpl(
val instance = if (activeInstance != null) {
_timelyInvocations.add(1)
- function.timelyInvocations.add(1)
+ function.timelyInvocations.add(1, function.attributes)
activeInstance
} else {
@@ -234,29 +234,29 @@ internal class FaaSServiceImpl(
instances.add(instance)
terminationPolicy.enqueue(instance)
- function.idleInstances.add(1)
+ function.idleInstances.add(1, function.attributes)
_delayedInvocations.add(1)
- function.delayedInvocations.add(1)
+ function.delayedInvocations.add(1, function.attributes)
instance
}
suspend {
val start = clock.millis()
- function.waitTime.record(start - submitTime)
- function.idleInstances.add(-1)
- function.activeInstances.add(1)
+ function.waitTime.record(start - submitTime, function.attributes)
+ function.idleInstances.add(-1, function.attributes)
+ function.activeInstances.add(1, function.attributes)
try {
instance.invoke()
} catch (e: Throwable) {
logger.debug(e) { "Function invocation failed" }
- function.failedInvocations.add(1)
+ function.failedInvocations.add(1, function.attributes)
} finally {
val end = clock.millis()
- function.activeTime.record(end - start)
- function.idleInstances.add(1)
- function.activeInstances.add(-1)
+ function.activeTime.record(end - start, function.attributes)
+ function.idleInstances.add(1, function.attributes)
+ function.activeInstances.add(-1, function.attributes)
}
}.startCoroutineCancellable(cont)
}
@@ -269,7 +269,7 @@ internal class FaaSServiceImpl(
check(function.uid in functions) { "Function does not exist (anymore)" }
_invocations.add(1)
- function.invocations.add(1)
+ function.invocations.add(1, function.attributes)
return suspendCancellableCoroutine { cont ->
if (!queue.add(InvocationRequest(clock.millis(), function, cont))) {