Skip to content

Publishers

Iñaki Villar edited this page Jan 13, 2020 · 5 revisions

Publishers

In terms of publishing, Talaiot includes some default Publishers, but at the same time you can extend it and create your own publisher for your requirements

Predefined Publishers

Property Description
OutputPublisher Publish the results of the build on the console, this Publisher will only print the task name and duration
InfluxDbPublisher Publish the results of the build to the InfluxDb database defined in the configuration
TaskDependencyGraphPublisher Publish the results of the build using the dependency graph of the tasks executed
PushGatewayGraphPublisher Publish the results of the build to the PushGateway server defined in the configuration
JsonPublisher Publish the results of the build with a json format
TimelinePublisher Publish the results of the build decomposed by the different workers used in the execution
ElasticSearchPublisher Publish the results of the build to the ElasticSearch instance defined in the configuration
HybridPublisher Publish the results of the build in two different publishers defined for tasks metrics and build metrics

InfluxDbPublisher

Talaiot will send to the InfluxDb server defined in the configuration the values collected during the execution

Property Description
dbName Name of the database
url Url of the InfluxDb Server
taskMetricName Name of the metric used for specific task in the execution
buildMetricName Name of the metric used for the overall information of the build in the execution
username username which is used to authorize against the influxDB instance (optional)
password password for the username which is used to authorize against the influxDB (optional)
retentionPolicyConfiguration retention policy which is used for writing points
publishBuildMetrics Publish build metrics of the publisher, true by default
publishTaskMetrics Publish tasks metrics of the publisher, true by default
RetentionPolicyConfiguration

Retention Policy (RP) describes how long InfluxDB keeps data, how many copies of the data to store in the cluster, and the time range covered by shard groups. RPs are unique per database and along with the measurement and tag set define a series. Since version 1.0.0 we are including by default RP in all the operations included in the publisher. The RetentionPolicyConfiguration includes:

Property Description
name name of the retentionPolicy(rp). Default rpTalaiot
duration duration of the rp. Default 30d
shardDuration the shardDuration. Default 30m
replicationFactor the replicationFactor of the rp. Default 2
isDefault if the rp is the default rp for the database or not. Default false

Example of custom RP Configuration:

influxDbPublisher {
  dbName = "xxxxxx"
  url = "xxxxxx"
  retentionPolicyConfiguration {
    name = "customRp"
    duration = "4w"
    shardDuration = "30m"
    replicationFactor = 1
    isDefault = true
  }
}

TaskDependencyGraphPublisher

Talaiot will generate the Task Dependency Graph in the specific format specified in the configuration

Property Description
ignoreWhen Configuration to ignore the execution of the publisher
html Export the task dependency graph in Html format with support of vis.js
gexf Export the task dependency graph in gexf format
dot Export the task dependency graph in png format. See Graphviz

This new category of publishers does not require constantly evaluating the builds, that's why there is an extra parameter configuration in the Publisher to ignore the execution unless there is some property enabled. Typical use case is use this publisher and collect the files on CI.

PushGatewayPublisher

Talaiot will send to the PushGateway server defined in the configuration the values collected during the execution.

Property Description
url Url of the PushGateway Server
taskJobName Name of the job required for the tasks metrics to be exported to Prometheus
buildJobName Name of the job required for the build metrics to be exported to Prometheus
publishBuildMetrics Publish build metrics of the publisher, true by default
publishTaskMetrics Publish tasks metrics of the publisher, true by default

JsonPublisher

Talaiot will Publish the results of the build with a json format .

    publishers {
        jsonPublisher = true
   
    }

TimelinePublisher

Talaiot will create a PNG file with the detailed information in chronological order by task of the execution in the different workers.

    publishers {
        timelinePublisher = true
   
    }

ElasticSearchPublisher

Talaiot will send to the ElasticSearch server defined in the configuration the values collected for tasks and build metrics during the execution in the different workers.

Property Description
url ElasticSearch server
taskIndexName Name for the index used to report tasks metrics
buildIndexName Name for the index used to report build metrics
publishBuildMetrics Publish build metrics of the publisher, true by default
publishTaskMetrics Publish tasks metrics of the publisher, true by default

Example:

    publishers {
        elasticSearchPublisher {
          url = "http://localhost:9200"
          taskIndexName = "task"
          buildIndexName = "build"
        }
    }

HybridPublisher

This Publisher allows composition over publishers to report tasks and build metrics.

Property Description
taskPublisher Publisher configuration used to publish tasks metrics
buildPublisher Publisher configuration used to publish build metrics

Example:

    publishers {
        hybridPublisher {
            taskPublisher = ElasticSearchPublisherConfiguration().apply {
                url = "http://localhost:9200"
                buildIndexName = "build"
                taskIndexName = "task"
            }
            
            buildPublisher = InfluxDbPublisherConfiguration().apply {
                dbName = "tracking"
                url = "http://localhost:8086"
                buildMetricName = "build"
                taskMetricName = "task"
            }
        }
    }

In this example we are using InfluxDbPublisher to report build metrics and ElasticSearchPublisher to report task metrics.

OutputPublisher

Publish the results of the build by duration and task

OutputConfiguration
Property Description
order Disable the output of the execution
numberOfTasks Disable the output of the execution
Example
  talaiot {
      publishers{
        outputPublisher
      }
  }
:consumer-server:domain-server:clean : 1 ms
:consumer-server:repository-server:clean : 1 ms
:consumer-server:server:clean : 2 ms
:core-network:clean : 3 ms
:core-domain:clean : 7 ms
¯\ :consumer-android:repository-android:clean : 39 ms
¯\_(ツ)_/¯ ¯\_(ツ)_/¯ ¯\_(ツ)_/¯ ¯\_(ツ)_/¯ ¯\_(ツ)_/¯ :consumer-android:app:clean : 832 ms

CustomPublisher

We can define custom Publishers depending on our requirements. The Talaiot configuration used to add more publishers is customPublisher:

Property Description
customPublisher Custom Publisher defined

To create a new Publisher we need to implement the interface Publisher:

interface Publisher {
     fun publish(report: ExecutionReport)
}

The function publish includes the argument ExecutionReport. This entity contains the information of the build including the data of the tasks and general build information:

data class ExecutionReport(
    var environment: Environment = Environment(),
    var customProperties: CustomProperties = CustomProperties(),
    var beginMs: String? = null,
    var endMs: String? = null,
    var durationMs: String? = null,
    var configurationDurationMs: String? = null,
    var tasks: List<TaskLength>? = null,
    var unfilteredTasks: List<TaskLength>? = null,
    var buildId: String? = null,
    var rootProject: String? = null,
    var requestedTasks: String? = null,
    var success: Boolean = false,
    var scanLink: String? = null,
    var buildInvocationId: String? = null
)

In this example the implementation would be:

class CustomPublisher : Publisher {

    override fun publish(report: ExecutionReport) {
        println("[CustomPublisher] : Number of tasks = ${report.tasks?.size}")
    }
}

And finally, we need to include it in the Talaiot configuration:

talaiot {
    logger = LogTracker.Mode.INFO
    publishers {
        customPublisher = CustomPublisher()
    }
}
Groovy
talaiot {
    publishers {
        customPublisher(new CustomPublisher())
    }
}