Skip to content

Commit

Permalink
MBS-12392 Fix teamcity metrics (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-krivobokov authored Nov 30, 2021
1 parent e033894 commit 5114cf1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 48 deletions.
1 change: 1 addition & 0 deletions subprojects/assemble/build-metrics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
implementation(projects.subprojects.gradle.gradleExtensions)
implementation(projects.subprojects.gradle.statsdConfig)
implementation(projects.subprojects.gradle.teamcity)
implementation(projects.subprojects.gradle.worker)
implementation(libs.kotlinGradle)

testImplementation(libs.mockitoKotlin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.avito.android.plugin.build_metrics

import com.avito.android.graphite.GraphiteConfig
import com.avito.android.plugin.build_metrics.internal.teamcity.CollectTeamcityMetricsWorkerAction
import com.avito.android.graphite.GraphiteSender
import com.avito.android.plugin.build_metrics.internal.teamcity.CollectTeamcityMetricsAction
import com.avito.gradle.worker.inMemoryWork
import com.avito.logger.LoggerFactory
import com.avito.teamcity.TeamcityApi
import com.avito.teamcity.TeamcityCredentials
import org.gradle.api.DefaultTask
import org.gradle.api.provider.Property
Expand Down Expand Up @@ -30,11 +33,27 @@ public abstract class CollectTeamcityMetricsTask @Inject constructor(

@TaskAction
public fun action() {
workerExecutor.noIsolation().submit(CollectTeamcityMetricsWorkerAction::class.java) { parameters ->
parameters.getBuildId().set(buildId)
parameters.getLoggerFactory().set(loggerFactory)
parameters.getGraphiteConfig().set(graphiteConfig)
parameters.getTeamcityCredentials().set(teamcityCredentials)
val buildId: String? = buildId.orNull
require(!buildId.isNullOrBlank()) {
"teamcity buildId property must be set"
}
val graphite = graphiteSender()
val teamcity = TeamcityApi.create(teamcityCredentials.get())
val action = CollectTeamcityMetricsAction(
buildId = buildId,
teamcityApi = teamcity,
graphite = graphite
)

workerExecutor.inMemoryWork {
action.execute()
}
}

private fun graphiteSender(): GraphiteSender {
return GraphiteSender.create(
config = graphiteConfig.get(),
loggerFactory = loggerFactory.get()
)
}
}

This file was deleted.

0 comments on commit 5114cf1

Please sign in to comment.