2.1.0
- [NEW] Support for multiple metric value types
- [NEW] Experimental Provider Metrics
Support for different value types in metrics
Version 2.1.0 adds support for different value types in metrics (e.g., strings and numbers).
Example: Define Metrics with Mixed Type:
customBuildMetrics(
"a" to "b",
"c" to 2
)
Resulting Output:
{
"customProperties": {
"buildProperties": {
"a": "b",
"c": 2
},
"taskProperties": {}
}
}
This change also enables defining your own custom metrics extending Metrics, with support for different value types:
class MyMetric : io.github.cdsap.talaiot.metrics.base.GradleMetric<Long>(
provider = { 42L },
assigner = { report, value ->
report.customProperties.buildProperties["mymetric"] = value
}
)
Experimental Provider Metrics
Since version 2.1.0, Talaiot includes an experimental mechanism to define metrics using a provider-based system compatible with Configuration Cache.
This approach allows you to lazily evaluate metric values, ensuring that they are resolved only when needed during the build lifecycle.
Two entry points are available for executing these providers:
- Initialization phase – executed at the start of the execution phase.
- Finalization phase – executed once the build has finished.
These APIs (initialProviderMetrics and finalProviderMetrics) are marked as experimental and may change in future versions.
You can suppress the compiler warning by explicitly opting in with @OptIn(ExperimentalMetricsApi::class).
Example:
metrics {
initialProviderMetrics(
"init_memory_metric" to providers.of(GetMemory::class) {}
)
finalProviderMetrics(
"end_memory_metric" to providers.of(GetMemory::class) {}
)
}