2019-03-28 17:27:06 +02:00
|
|
|
import com.sap.piper.GenerateDocumentation
|
2018-09-21 16:55:31 +02:00
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
2019-04-11 11:39:41 +02:00
|
|
|
import com.sap.piper.analytics.InfluxData
|
|
|
|
|
2018-09-21 16:55:31 +02:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
2018-11-29 10:54:05 +02:00
|
|
|
@Field STEP_NAME = getClass().getName()
|
2018-09-21 16:55:31 +02:00
|
|
|
|
2019-04-04 17:01:30 +02:00
|
|
|
@Field Set GENERAL_CONFIG_KEYS = []
|
|
|
|
|
|
|
|
@Field Set STEP_CONFIG_KEYS = []
|
|
|
|
|
2019-03-28 17:27:06 +02:00
|
|
|
@Field Set PARAMETER_KEYS = [
|
|
|
|
/** Defines the name of the measurement which is written to the Influx database.*/
|
|
|
|
'measurementName'
|
|
|
|
]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This step is used to measure the duration of a set of steps, e.g. a certain stage.
|
|
|
|
* The duration is stored in a Map. The measurement data can then be written to an Influx database using step [influxWriteData](influxWriteData.md).
|
|
|
|
*
|
|
|
|
* !!! tip
|
|
|
|
* Measuring for example the duration of pipeline stages helps to identify potential bottlenecks within the deployment pipeline.
|
|
|
|
* This then helps to counter identified issues with respective optimization measures, e.g parallelization of tests.
|
|
|
|
*/
|
|
|
|
@GenerateDocumentation
|
2018-01-24 10:55:38 +02:00
|
|
|
def call(Map parameters = [:], body) {
|
|
|
|
|
2018-09-21 16:55:31 +02:00
|
|
|
def script = checkScript(this, parameters)
|
|
|
|
|
2018-01-24 10:55:38 +02:00
|
|
|
def measurementName = parameters.get('measurementName', 'test_duration')
|
|
|
|
|
|
|
|
//start measurement
|
|
|
|
def start = System.currentTimeMillis()
|
|
|
|
|
|
|
|
body()
|
|
|
|
|
|
|
|
//record measurement
|
|
|
|
def duration = System.currentTimeMillis() - start
|
|
|
|
|
2019-04-11 11:39:41 +02:00
|
|
|
InfluxData.addField('pipeline_data', measurementName, duration)
|
2018-01-24 10:55:38 +02:00
|
|
|
|
|
|
|
return duration
|
|
|
|
}
|