-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Tag configuration InfluxDb publisher (#275)
* adding BuildMetrics tagging filtering * adding enum build propereties * removing in class function * fixing problem toString BuildMetrics * adding tests TagFieldProvider * Update TagFieldProvider.kt removing main function * adding publisher tests * adding doc tags configuration * updating README * change type tags to list
- Loading branch information
Showing
12 changed files
with
292 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
subprojects { | ||
// Address https://github.com/gradle/gradle/issues/4823: Force parent project evaluation before sub-project evaluation for Kotlin build scripts | ||
if (gradle.startParameter.isConfigureOnDemand | ||
&& buildscript.sourceFile?.extension?.toLowerCase() == "kts" | ||
&& parent != rootProject) { | ||
generateSequence(parent) { project -> project.parent.takeIf { it != rootProject } } | ||
.forEach { evaluationDependsOn(it.path) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
library/core/talaiot/src/main/kotlin/com/cdsap/talaiot/metrics/BuildMetrics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.cdsap.talaiot.metrics | ||
|
||
enum class BuildMetrics { | ||
Duration, | ||
Configuration, | ||
Success, | ||
BuildId, | ||
BuildInvocationId, | ||
RequestedTasks, | ||
CacheRatio, | ||
Start, | ||
RootProject, | ||
OsVersion, | ||
MaxWorkers, | ||
JavaRuntime, | ||
JavaVmName, | ||
JavaXmsBytes, | ||
JavaXmxBytes, | ||
JavaMaxPermSize, | ||
TotalRamAvailableBytes, | ||
CpuCount, | ||
Locale, | ||
Username, | ||
DefaultCharset, | ||
IdeVersion, | ||
GradleVersion, | ||
GitBranch, | ||
GitUser, | ||
Hostname, | ||
OsManufacturer, | ||
PublicIp, | ||
CacheUrl, | ||
LocalCacheHit, | ||
LocalCacheMiss, | ||
RemoteCacheHit, | ||
RemoteCacheMiss, | ||
CacheStore, | ||
SwitchCache, | ||
SwitchScan, | ||
SwitchConfigurationOnDemand, | ||
SwitchContinueOnFailure, | ||
SwitchDaemon, | ||
SwitchDryRun, | ||
SwitchOffline, | ||
SwitchParallel, | ||
SwitchRefreshDependencies, | ||
SwitchRerunTasks, | ||
Custom; | ||
|
||
override fun toString(): String { | ||
return if (super.toString().startsWith("Switch")) { | ||
val temp = super.toString().split("Switch") | ||
"switch.${temp[1].decapitalize()}" | ||
} else { | ||
super.toString().decapitalize() | ||
} | ||
} | ||
} |
91 changes: 45 additions & 46 deletions
91
library/core/talaiot/src/main/kotlin/com/cdsap/talaiot/metrics/DefaultBuildDataProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...fluxdb-publisher/src/main/kotlin/com/cdsap/talaiot/publisher/influxdb/TagFieldProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.cdsap.talaiot.publisher.influxdb | ||
|
||
import com.cdsap.talaiot.entities.CustomProperties | ||
import com.cdsap.talaiot.entities.Environment | ||
import com.cdsap.talaiot.entities.ExecutionReport | ||
import com.cdsap.talaiot.metrics.BuildMetrics | ||
import com.cdsap.talaiot.metrics.DefaultBuildMetricsProvider | ||
import java.lang.IllegalArgumentException | ||
|
||
class TagFieldProvider( | ||
private val executionReport: ExecutionReport, | ||
private val tagsConfiguration: List<BuildMetrics> | ||
) { | ||
private val buildMetrics = DefaultBuildMetricsProvider(executionReport).get() | ||
|
||
fun tags(): Map<String, String> = buildMetrics | ||
.filter { | ||
customMetrics(it.key) || defaultMetrics(it.key) | ||
}.mapValues { it.value.toString() } | ||
|
||
|
||
fun fields(): Map<String, Any> { | ||
val tags = tags() | ||
return buildMetrics.filter { !tags.containsKey(it.key) } | ||
} | ||
|
||
private fun customMetrics(key: String) = | ||
tagsConfiguration.contains(BuildMetrics.Custom) && | ||
executionReport.customProperties.buildProperties.contains(key) | ||
|
||
private fun defaultMetrics(key: String) = | ||
try { | ||
tagsConfiguration.contains(BuildMetrics.valueOf(key.capitalize())) | ||
} catch (e: IllegalArgumentException){ | ||
false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.