diff --git a/client/Makefile b/client/Makefile index ebc15ac..d7ba652 100644 --- a/client/Makefile +++ b/client/Makefile @@ -6,9 +6,9 @@ .PHONY: protobuf SRC_DIR_PROTO=app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/proto -DST_DIR_PROTO=app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter +DST_DIR_PROTO=app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/ protobuf: mkdir -p $(DST_DIR_PROTO) - protoc -I=$(SRC_DIR_PROTO) --kotlin_out=$(DST_DIR_PROTO) $(SRC_DIR_PROTO)/remote-write.proto + protoc -I=$(SRC_DIR_PROTO) --kotlin_out=$(DST_DIR_PROTO) $(SRC_DIR_PROTO)/remote_write.proto diff --git a/client/app/build.gradle b/client/app/build.gradle index 1b2b310..d72213d 100644 --- a/client/app/build.gradle +++ b/client/app/build.gradle @@ -4,6 +4,8 @@ plugins { id 'kotlinx-serialization' } +apply plugin: 'com.google.protobuf' + android { namespace 'com.birdthedeveloper.prometheus.android.prometheus.android.exporter' compileSdk 33 @@ -47,6 +49,17 @@ android { } } +protobuf { + protoc { artifact = 'com.google.protobuf:protoc:3.11.0' } + generateProtoTasks { + all().each { task -> + task.builtins { + java { option 'lite' } + } + } + } +} + dependencies { implementation 'androidx.work:work-multiprocess:2.8.1' def core_version = "1.10.1" @@ -84,6 +97,10 @@ dependencies { implementation("com.charleskorn.kaml:kaml:0.54.0") implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1' + // custom - protocol buffers + implementation 'com.google.protobuf:protobuf-javalite:3.20.1' + implementation 'com.google.protobuf:protobuf-kotlin-lite:3.20.1' + diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/LabelKt.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/LabelKt.kt deleted file mode 100644 index 52cece6..0000000 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/LabelKt.kt +++ /dev/null @@ -1,62 +0,0 @@ -//Generated by the protocol buffer compiler. DO NOT EDIT! -// source: remote-write.proto - -package protogen; - -@kotlin.jvm.JvmSynthetic -public inline fun label(block: protogen.LabelKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.Label = - protogen.LabelKt.Dsl._create(protogen.RemoteWrite.Label.newBuilder()).apply { block() }._build() -public object LabelKt { - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - @com.google.protobuf.kotlin.ProtoDslMarker - public class Dsl private constructor( - private val _builder: protogen.RemoteWrite.Label.Builder - ) { - public companion object { - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _create(builder: protogen.RemoteWrite.Label.Builder): Dsl = Dsl(builder) - } - - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _build(): protogen.RemoteWrite.Label = _builder.build() - - /** - * string name = 1; - */ - public var name: kotlin.String - @JvmName("getName") - get() = _builder.getName() - @JvmName("setName") - set(value) { - _builder.setName(value) - } - /** - * string name = 1; - */ - public fun clearName() { - _builder.clearName() - } - - /** - * string value = 2; - */ - public var value: kotlin.String - @JvmName("getValue") - get() = _builder.getValue() - @JvmName("setValue") - set(value) { - _builder.setValue(value) - } - /** - * string value = 2; - */ - public fun clearValue() { - _builder.clearValue() - } - } -} -@kotlin.jvm.JvmSynthetic -public inline fun protogen.RemoteWrite.Label.copy(block: protogen.LabelKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.Label = - protogen.LabelKt.Dsl._create(this.toBuilder()).apply { block() }._build() diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/RemoteWriteKt.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/RemoteWriteKt.kt deleted file mode 100644 index e69de29..0000000 diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/SampleKt.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/SampleKt.kt deleted file mode 100644 index 850059d..0000000 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/SampleKt.kt +++ /dev/null @@ -1,70 +0,0 @@ -//Generated by the protocol buffer compiler. DO NOT EDIT! -// source: remote-write.proto - -package protogen; - -@kotlin.jvm.JvmSynthetic -public inline fun sample(block: protogen.SampleKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.Sample = - protogen.SampleKt.Dsl._create(protogen.RemoteWrite.Sample.newBuilder()).apply { block() }._build() -public object SampleKt { - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - @com.google.protobuf.kotlin.ProtoDslMarker - public class Dsl private constructor( - private val _builder: protogen.RemoteWrite.Sample.Builder - ) { - public companion object { - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _create(builder: protogen.RemoteWrite.Sample.Builder): Dsl = Dsl(builder) - } - - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _build(): protogen.RemoteWrite.Sample = _builder.build() - - /** - * double value = 1; - */ - public var value: kotlin.Double - @JvmName("getValue") - get() = _builder.getValue() - @JvmName("setValue") - set(value) { - _builder.setValue(value) - } - /** - * double value = 1; - */ - public fun clearValue() { - _builder.clearValue() - } - - /** - *
-     * in ms
-     * 
- * - * int64 timestamp = 2; - */ - public var timestamp: kotlin.Long - @JvmName("getTimestamp") - get() = _builder.getTimestamp() - @JvmName("setTimestamp") - set(value) { - _builder.setTimestamp(value) - } - /** - *
-     * in ms
-     * 
- * - * int64 timestamp = 2; - */ - public fun clearTimestamp() { - _builder.clearTimestamp() - } - } -} -@kotlin.jvm.JvmSynthetic -public inline fun protogen.RemoteWrite.Sample.copy(block: protogen.SampleKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.Sample = - protogen.SampleKt.Dsl._create(this.toBuilder()).apply { block() }._build() diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/TimeSeriesKt.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/TimeSeriesKt.kt deleted file mode 100644 index 6427f48..0000000 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/TimeSeriesKt.kt +++ /dev/null @@ -1,158 +0,0 @@ -//Generated by the protocol buffer compiler. DO NOT EDIT! -// source: remote-write.proto - -package protogen; - -@kotlin.jvm.JvmSynthetic -public inline fun timeSeries(block: protogen.TimeSeriesKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.TimeSeries = - protogen.TimeSeriesKt.Dsl._create(protogen.RemoteWrite.TimeSeries.newBuilder()).apply { block() }._build() -public object TimeSeriesKt { - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - @com.google.protobuf.kotlin.ProtoDslMarker - public class Dsl private constructor( - private val _builder: protogen.RemoteWrite.TimeSeries.Builder - ) { - public companion object { - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _create(builder: protogen.RemoteWrite.TimeSeries.Builder): Dsl = Dsl(builder) - } - - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _build(): protogen.RemoteWrite.TimeSeries = _builder.build() - - /** - * An uninstantiable, behaviorless type to represent the field in - * generics. - */ - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - public class LabelsProxy private constructor() : com.google.protobuf.kotlin.DslProxy() - /** - * repeated .protogen.Label labels = 1; - */ - public val labels: com.google.protobuf.kotlin.DslList - @kotlin.jvm.JvmSynthetic - get() = com.google.protobuf.kotlin.DslList( - _builder.getLabelsList() - ) - /** - * repeated .protogen.Label labels = 1; - * @param value The labels to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("addLabels") - public fun com.google.protobuf.kotlin.DslList.add(value: protogen.RemoteWrite.Label) { - _builder.addLabels(value) - }/** - * repeated .protogen.Label labels = 1; - * @param value The labels to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("plusAssignLabels") - @Suppress("NOTHING_TO_INLINE") - public inline operator fun com.google.protobuf.kotlin.DslList.plusAssign(value: protogen.RemoteWrite.Label) { - add(value) - }/** - * repeated .protogen.Label labels = 1; - * @param values The labels to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("addAllLabels") - public fun com.google.protobuf.kotlin.DslList.addAll(values: kotlin.collections.Iterable) { - _builder.addAllLabels(values) - }/** - * repeated .protogen.Label labels = 1; - * @param values The labels to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("plusAssignAllLabels") - @Suppress("NOTHING_TO_INLINE") - public inline operator fun com.google.protobuf.kotlin.DslList.plusAssign(values: kotlin.collections.Iterable) { - addAll(values) - }/** - * repeated .protogen.Label labels = 1; - * @param index The index to set the value at. - * @param value The labels to set. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("setLabels") - public operator fun com.google.protobuf.kotlin.DslList.set(index: kotlin.Int, value: protogen.RemoteWrite.Label) { - _builder.setLabels(index, value) - }/** - * repeated .protogen.Label labels = 1; - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("clearLabels") - public fun com.google.protobuf.kotlin.DslList.clear() { - _builder.clearLabels() - } - /** - * An uninstantiable, behaviorless type to represent the field in - * generics. - */ - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - public class SamplesProxy private constructor() : com.google.protobuf.kotlin.DslProxy() - /** - * repeated .protogen.Sample samples = 2; - */ - public val samples: com.google.protobuf.kotlin.DslList - @kotlin.jvm.JvmSynthetic - get() = com.google.protobuf.kotlin.DslList( - _builder.getSamplesList() - ) - /** - * repeated .protogen.Sample samples = 2; - * @param value The samples to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("addSamples") - public fun com.google.protobuf.kotlin.DslList.add(value: protogen.RemoteWrite.Sample) { - _builder.addSamples(value) - }/** - * repeated .protogen.Sample samples = 2; - * @param value The samples to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("plusAssignSamples") - @Suppress("NOTHING_TO_INLINE") - public inline operator fun com.google.protobuf.kotlin.DslList.plusAssign(value: protogen.RemoteWrite.Sample) { - add(value) - }/** - * repeated .protogen.Sample samples = 2; - * @param values The samples to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("addAllSamples") - public fun com.google.protobuf.kotlin.DslList.addAll(values: kotlin.collections.Iterable) { - _builder.addAllSamples(values) - }/** - * repeated .protogen.Sample samples = 2; - * @param values The samples to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("plusAssignAllSamples") - @Suppress("NOTHING_TO_INLINE") - public inline operator fun com.google.protobuf.kotlin.DslList.plusAssign(values: kotlin.collections.Iterable) { - addAll(values) - }/** - * repeated .protogen.Sample samples = 2; - * @param index The index to set the value at. - * @param value The samples to set. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("setSamples") - public operator fun com.google.protobuf.kotlin.DslList.set(index: kotlin.Int, value: protogen.RemoteWrite.Sample) { - _builder.setSamples(index, value) - }/** - * repeated .protogen.Sample samples = 2; - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("clearSamples") - public fun com.google.protobuf.kotlin.DslList.clear() { - _builder.clearSamples() - }} -} -@kotlin.jvm.JvmSynthetic -public inline fun protogen.RemoteWrite.TimeSeries.copy(block: protogen.TimeSeriesKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.TimeSeries = - protogen.TimeSeriesKt.Dsl._create(this.toBuilder()).apply { block() }._build() diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/WriteRequestKt.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/WriteRequestKt.kt deleted file mode 100644 index aefb82e..0000000 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/protogen/WriteRequestKt.kt +++ /dev/null @@ -1,93 +0,0 @@ -//Generated by the protocol buffer compiler. DO NOT EDIT! -// source: remote-write.proto - -package protogen; - -@kotlin.jvm.JvmSynthetic -public inline fun writeRequest(block: protogen.WriteRequestKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.WriteRequest = - protogen.WriteRequestKt.Dsl._create(protogen.RemoteWrite.WriteRequest.newBuilder()).apply { block() }._build() -public object WriteRequestKt { - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - @com.google.protobuf.kotlin.ProtoDslMarker - public class Dsl private constructor( - private val _builder: protogen.RemoteWrite.WriteRequest.Builder - ) { - public companion object { - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _create(builder: protogen.RemoteWrite.WriteRequest.Builder): Dsl = Dsl(builder) - } - - @kotlin.jvm.JvmSynthetic - @kotlin.PublishedApi - internal fun _build(): protogen.RemoteWrite.WriteRequest = _builder.build() - - /** - * An uninstantiable, behaviorless type to represent the field in - * generics. - */ - @kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class) - public class TimeseriesProxy private constructor() : com.google.protobuf.kotlin.DslProxy() - /** - * repeated .protogen.TimeSeries timeseries = 1; - */ - public val timeseries: com.google.protobuf.kotlin.DslList - @kotlin.jvm.JvmSynthetic - get() = com.google.protobuf.kotlin.DslList( - _builder.getTimeseriesList() - ) - /** - * repeated .protogen.TimeSeries timeseries = 1; - * @param value The timeseries to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("addTimeseries") - public fun com.google.protobuf.kotlin.DslList.add(value: protogen.RemoteWrite.TimeSeries) { - _builder.addTimeseries(value) - }/** - * repeated .protogen.TimeSeries timeseries = 1; - * @param value The timeseries to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("plusAssignTimeseries") - @Suppress("NOTHING_TO_INLINE") - public inline operator fun com.google.protobuf.kotlin.DslList.plusAssign(value: protogen.RemoteWrite.TimeSeries) { - add(value) - }/** - * repeated .protogen.TimeSeries timeseries = 1; - * @param values The timeseries to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("addAllTimeseries") - public fun com.google.protobuf.kotlin.DslList.addAll(values: kotlin.collections.Iterable) { - _builder.addAllTimeseries(values) - }/** - * repeated .protogen.TimeSeries timeseries = 1; - * @param values The timeseries to add. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("plusAssignAllTimeseries") - @Suppress("NOTHING_TO_INLINE") - public inline operator fun com.google.protobuf.kotlin.DslList.plusAssign(values: kotlin.collections.Iterable) { - addAll(values) - }/** - * repeated .protogen.TimeSeries timeseries = 1; - * @param index The index to set the value at. - * @param value The timeseries to set. - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("setTimeseries") - public operator fun com.google.protobuf.kotlin.DslList.set(index: kotlin.Int, value: protogen.RemoteWrite.TimeSeries) { - _builder.setTimeseries(index, value) - }/** - * repeated .protogen.TimeSeries timeseries = 1; - */ - @kotlin.jvm.JvmSynthetic - @kotlin.jvm.JvmName("clearTimeseries") - public fun com.google.protobuf.kotlin.DslList.clear() { - _builder.clearTimeseries() - }} -} -@kotlin.jvm.JvmSynthetic -public inline fun protogen.RemoteWrite.WriteRequest.copy(block: protogen.WriteRequestKt.Dsl.() -> kotlin.Unit): protogen.RemoteWrite.WriteRequest = - protogen.WriteRequestKt.Dsl._create(this.toBuilder()).apply { block() }._build() diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/worker/RemoteWrite.kt b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/worker/RemoteWriteSender.kt similarity index 58% rename from client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/worker/RemoteWrite.kt rename to client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/worker/RemoteWriteSender.kt index f9db5c6..17e7c83 100644 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/worker/RemoteWrite.kt +++ b/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/worker/RemoteWriteSender.kt @@ -1,11 +1,18 @@ package com.birdthedeveloper.prometheus.android.prometheus.android.exporter.worker +import remote.write.RemoteWrite.WriteRequest + data class RemoteWriteConfiguration( val scrape_interval : Int, val remote_write_endpoint : String, ) -class RemoteWrite(config : RemoteWriteConfiguration) { +class RemoteWriteSender(config : RemoteWriteConfiguration) { //TODO implement this thing + + fun test(){ + var request : WriteRequest + } } + diff --git a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/proto/remote-write.proto b/client/app/src/main/proto/remote_write.proto similarity index 87% rename from client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/proto/remote-write.proto rename to client/app/src/main/proto/remote_write.proto index f61ab60..91aa89e 100644 --- a/client/app/src/main/java/com/birdthedeveloper/prometheus/android/prometheus/android/exporter/proto/remote-write.proto +++ b/client/app/src/main/proto/remote_write.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package com.birdthedeveloper.prometheus.android.prometheus.android.exporter.protogen; +package remote.write; message WriteRequest { repeated TimeSeries timeseries = 1; diff --git a/client/build.gradle b/client/build.gradle index 952c358..89f18f3 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -1,7 +1,14 @@ buildscript { + repositories { + google() + mavenCentral() + } ext { compose_ui_version = '1.4.2' } + dependencies { + classpath "com.google.protobuf:protobuf-gradle-plugin:0.9.3" + } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '8.0.2' apply false