mirror of
https://github.com/mii443/prometheus-android-exporter.git
synced 2025-12-03 02:58:29 +00:00
code formatting
This commit is contained in:
@@ -27,15 +27,19 @@ data class PromConfigFile(
|
||||
fun toPromConfiguration(): PromConfiguration {
|
||||
return PromConfiguration(
|
||||
pushproxProxyUrl = this.pushprox?.proxy_url ?: "",
|
||||
remoteWriteScrapeInterval = (this.remote_write?.scrape_interval ?: defaultRemoteWriteScrapeInterval).toString(),
|
||||
remoteWriteScrapeInterval = (this.remote_write?.scrape_interval
|
||||
?: defaultRemoteWriteScrapeInterval).toString(),
|
||||
pushproxEnabled = this.pushprox?.enabled ?: false,
|
||||
pushproxFqdn = this.pushprox?.fqdn ?: "",
|
||||
remoteWriteEnabled = this.remote_write?.enabled ?: false,
|
||||
remoteWriteEndpoint = this.remote_write?.remote_write_endpoint ?: "",
|
||||
prometheusServerEnabled = this.prometheus_server?.enabled ?: true,
|
||||
prometheusServerPort = (this.prometheus_server?.port ?: defaultPrometheusServerPort).toString(),
|
||||
remoteWriteMaxSamplesPerExport = (this.remote_write?.max_samples_per_export ?: defaultRemoteWriteMaxSamplesPerExport).toString(),
|
||||
remoteWriteExportInterval = (this.remote_write?.export_interval ?: defaultRemoteWriteExportInterval).toString(),
|
||||
prometheusServerPort = (this.prometheus_server?.port
|
||||
?: defaultPrometheusServerPort).toString(),
|
||||
remoteWriteMaxSamplesPerExport = (this.remote_write?.max_samples_per_export
|
||||
?: defaultRemoteWriteMaxSamplesPerExport).toString(),
|
||||
remoteWriteExportInterval = (this.remote_write?.export_interval
|
||||
?: defaultRemoteWriteExportInterval).toString(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,8 @@ import androidx.compose.material.TopAppBar
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
@@ -83,6 +83,7 @@ class PromViewModel : ViewModel() {
|
||||
companion object {
|
||||
private const val PROM_UNIQUE_WORK: String = "prom_unique_job"
|
||||
}
|
||||
|
||||
private fun loadConfigurationFile() {
|
||||
Log.v(TAG, "Checking for configuration file")
|
||||
|
||||
|
||||
@@ -11,8 +11,10 @@ class ExponentialBackoff {
|
||||
private const val initialDelay = 3.0 // seconds
|
||||
private const val maxDelay = 40.0 // seconds
|
||||
|
||||
suspend fun runWithBackoff(function: suspend () -> Unit,
|
||||
onException: () -> Unit, infinite : Boolean = true) {
|
||||
suspend fun runWithBackoff(
|
||||
function: suspend () -> Unit,
|
||||
onException: () -> Unit, infinite: Boolean = true
|
||||
) {
|
||||
|
||||
var successfull: Boolean = false
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ class PromWorker(
|
||||
|
||||
private val collectorRegistry = CollectorRegistry()
|
||||
private val metricsEngine: MetricsEngine = MetricsEngine(context)
|
||||
private val androidCustomExporter : AndroidCustomExporter = AndroidCustomExporter(metricsEngine).register(collectorRegistry)
|
||||
private val androidCustomExporter: AndroidCustomExporter =
|
||||
AndroidCustomExporter(metricsEngine).register(collectorRegistry)
|
||||
private lateinit var pushProxClient: PushProxClient
|
||||
private var remoteWriteSender: RemoteWriteSender? = null
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ private const val TAG: String = "REMOTE_WRITE_SENDER"
|
||||
private class LastTimeRingBuffer(private val scrapeIntervalMs: Int) {
|
||||
private val buffer: Array<Long> = Array(hysteresisThreshold) { 0 }
|
||||
private var firstIndex: Int = 0
|
||||
|
||||
companion object {
|
||||
private const val hysteresisThreshold: Int = 3
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ private data class TimeSeriesLabel(
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
private data class TimeSeriesSample(
|
||||
val timeStampMs: Long,
|
||||
val value: Double,
|
||||
@@ -51,12 +52,15 @@ abstract class RemoteWriteSenderStorage {
|
||||
name = "backfill",
|
||||
value = "true",
|
||||
)
|
||||
|
||||
protected fun encodeWithSnappy(data: ByteArray): ByteArray {
|
||||
return Snappy.compress(data)
|
||||
}
|
||||
|
||||
private fun processLabels(sample : MetricFamilySamples.Sample,
|
||||
sampleName: String) : List<TimeSeriesLabel>{
|
||||
private fun processLabels(
|
||||
sample: MetricFamilySamples.Sample,
|
||||
sampleName: String
|
||||
): List<TimeSeriesLabel> {
|
||||
|
||||
val result: MutableList<TimeSeriesLabel> = mutableListOf()
|
||||
|
||||
@@ -93,7 +97,8 @@ abstract class RemoteWriteSenderStorage {
|
||||
}
|
||||
|
||||
private fun processTimeSeries(
|
||||
hashMap: ConverterHashMap, familySample : MetricFamilySamples){
|
||||
hashMap: ConverterHashMap, familySample: MetricFamilySamples
|
||||
) {
|
||||
|
||||
for (sample in familySample.samples) {
|
||||
val sampleName: String = sample.name
|
||||
@@ -112,7 +117,8 @@ abstract class RemoteWriteSenderStorage {
|
||||
}
|
||||
|
||||
private fun hashMapEntryToProtobufTimeSeries(
|
||||
labels : List<TimeSeriesLabel>, samples : MutableList<TimeSeriesSample>) : TimeSeries {
|
||||
labels: List<TimeSeriesLabel>, samples: MutableList<TimeSeriesSample>
|
||||
): TimeSeries {
|
||||
|
||||
val timeSeriesBuilder: TimeSeries.Builder = TimeSeries.newBuilder()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user