diff --git a/riff-raff/app/AppComponents.scala b/riff-raff/app/AppComponents.scala index 871be4a4c..5d60f6a09 100644 --- a/riff-raff/app/AppComponents.scala +++ b/riff-raff/app/AppComponents.scala @@ -223,7 +223,7 @@ class AppComponents( deployments, builds, targetResolver, - new GrafanaAnnotationLogger, + new GrafanaAnnotationLogger(config.urls.publicPrefix), hooksClient, new SummariseDeploysHousekeeping(config, datastore), continuousDeployment, diff --git a/riff-raff/app/notification/GrafanaAnnotationLogger.scala b/riff-raff/app/notification/GrafanaAnnotationLogger.scala index 4f2dd32aa..baf4eff88 100644 --- a/riff-raff/app/notification/GrafanaAnnotationLogger.scala +++ b/riff-raff/app/notification/GrafanaAnnotationLogger.scala @@ -10,6 +10,7 @@ import net.logstash.logback.marker.Markers.appendEntries import play.api.MarkerContext import rx.lang.scala.Subscription +import java.util.UUID import scala.jdk.CollectionConverters._ trait LogMarker { @@ -18,27 +19,34 @@ trait LogMarker { def markerContents: Map[String, Any] } -class GrafanaAnnotationLogger extends Lifecycle with Logging { +class GrafanaAnnotationLogger(riffRaffUrl: String) + extends Lifecycle + with Logging { val messageSub: Subscription = DeployReporter.messages.subscribe(message => { + val deployId = message.context.deployId message.stack.top match { case StartContext(Deploy(parameters)) => - log.info("Started deploy")(buildMarker(parameters)) + log.info("Started deploy")(buildMarker(deployId, parameters)) case FailContext(Deploy(parameters)) => - log.info("Failed deploy")(buildMarker(parameters)) + log.info("Failed deploy")(buildMarker(deployId, parameters)) case FinishContext(Deploy(parameters)) => - log.info("Finished deploy")(buildMarker(parameters)) + log.info("Finished deploy")(buildMarker(deployId, parameters)) case _ => } }) - private def buildMarker(parameters: DeployParameters): MarkerContext = { + private def buildMarker( + deployId: UUID, + parameters: DeployParameters + ): MarkerContext = { val params: Map[String, Any] = Map( "projectName" -> parameters.build.projectName, "projectBuild" -> parameters.build.id, "projectStage" -> parameters.stage.name, - "projectDeployer" -> parameters.deployer.name + "projectDeployer" -> parameters.deployer.name, + "projectDeploymentLink" -> s"${parameters.build.id}" ) MarkerContext(appendEntries(params.asJava)) }