-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from davidmogar/metrics
Add new function to send metric messages
- Loading branch information
Showing
15 changed files
with
441 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"code": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Error code.", | ||
"required": true | ||
}, | ||
"message": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Error message.", | ||
"required": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"service": { | ||
"value": {}, | ||
"type": "groovy.lang.Closure", | ||
"description": "The service content Map.", | ||
"required": true | ||
}, | ||
"source": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Tool/component making the request (eg. midstream, rhprod, service, ...).", | ||
"required": true | ||
}, | ||
"success": { | ||
"value": true, | ||
"type": "java.lang.Boolean", | ||
"description": "Whether the call succeeded or not.", | ||
"required": true | ||
}, | ||
"error": { | ||
"value": null, | ||
"type": "groovy.lang.Closure", | ||
"description": "The error content Map.", | ||
"required": false | ||
}, | ||
"start": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Time at which the request started. (ISO-8601).", | ||
"required": true | ||
}, | ||
"end": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Time at which the final answer was collected (last call or retry with a proper answer) (ISO-8601).", | ||
"required": true | ||
}, | ||
"retryData": { | ||
"value": {}, | ||
"type": "groovy.lang.Closure", | ||
"description": "The retryData content Map.", | ||
"required": true | ||
} | ||
} |
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,26 @@ | ||
{ | ||
"id": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Unique identification string. Useful for constructing tree of rebuilds of the same artifact in the Web UI. Note that it is up to the CI system to implement. Replaces thread_id from previous versions of the spec. The value must be unique among all systems reporting on the artifact; it is advised to prefix it with a unique string, e.g. the name of the CI system, etc.", | ||
"required": true | ||
}, | ||
"name": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "A human readable name of the pipeline.", | ||
"required": true | ||
}, | ||
"jenkinsUrl": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "The jenkins URL.", | ||
"required": true | ||
}, | ||
"productId": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "The product id.", | ||
"required": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"configuration": { | ||
"value": {}, | ||
"type": "groovy.lang.Closure", | ||
"description": "The RetryDataConfiguration content Map.", | ||
"required": false | ||
}, | ||
"iterations": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Number of iterations (ie. number of retries plus 1 for the first call).", | ||
"required": true | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
resources/msgBus-Metrics-RetryDataConfiguration-Content.json
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,32 @@ | ||
{ | ||
"initialRetryInterval": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Initial retry interval (first retry interval) in seconds.", | ||
"required": false | ||
}, | ||
"maxElapsedTime": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Maximum number of seconds for the whole retry process.", | ||
"required": false | ||
}, | ||
"maxInterval": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Maximum number of seconds between retries.", | ||
"required": false | ||
}, | ||
"maxRetries": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Maximum number of retries.", | ||
"required": false | ||
}, | ||
"timeout": { | ||
"value": 0, | ||
"type": "java.math.BigInteger", | ||
"description": "Timeout used for each call to the external service.", | ||
"required": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Name of the external service.", | ||
"required": true | ||
}, | ||
"type": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Type of call (ie. cli or http).", | ||
"required": true | ||
}, | ||
"server": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Server contacted in case of not targeting the prod server.", | ||
"required": false | ||
}, | ||
"endpoint": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Either http endpoint or cli subcommand.", | ||
"required": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"externalCall": { | ||
"value": {}, | ||
"type": "groovy.lang.Closure", | ||
"description": "The externalCall content Map.", | ||
"required": true | ||
}, | ||
"generated_at": { | ||
"value": null, | ||
"type": "java.lang.String", | ||
"description": "Timestamp of message creation (ISO-8601).", | ||
"required": true | ||
}, | ||
"pipeline": { | ||
"value": {}, | ||
"type": "groovy.lang.Closure", | ||
"description": "The pipeline content Map.", | ||
"required": true | ||
} | ||
} |
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,26 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the error content of an external call metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBus-Metrics-Error-Content.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating closure for external call metric error content failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
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,29 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the external call content of a metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBus-Metrics-ExternalCall-Content.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters['service'] = parameters['service'] ?: msgBusMetricsServiceContent()() | ||
parameters['retryData'] = parameters['retryData'] ?: msgBusMetricsRetryDataContent()() | ||
|
||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating closure for external call content failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
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,30 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBusMetricsMsg.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters['externalCall'] = parameters['externalCall'] ?: msgBusMetricsExternalCallContent()() | ||
parameters['generated_at'] = parameters['generated_at'] ?: java.time.Instant.now().toString() | ||
parameters['pipeline'] = parameters['pipeline'] ?: msgBusMetricsPipelineContent()() | ||
|
||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating the metrics message failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
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,26 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the pipeline content of a metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBus-Metrics-Pipeline-Content.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating closure for metric pipeline content failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
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,26 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the configuration content of a retry closure in an external call metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBus-Metrics-RetryDataConfiguration-Content.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating the retry configuration closure for retry metrics message failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
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,26 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the retry content of a retry metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBus-Metrics-RetryData-Content.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating retryData closure for metrics message failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
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,26 @@ | ||
import org.centos.contra.pipeline.Utils | ||
|
||
/** | ||
* Defines the service content of an external call metrics message | ||
* This will merge parameters with the defaults and will validate each parameter | ||
* @param parameters | ||
* @return HashMap | ||
*/ | ||
def call(Map parameters = [:]) { | ||
|
||
def utils = new Utils() | ||
|
||
def defaults = readJSON text: libraryResource('msgBus-Metrics-Service-Content.json') | ||
|
||
return { Map runtimeArgs = [:] -> | ||
parameters = utils.mapMergeQuotes([parameters, runtimeArgs]) | ||
try { | ||
mergedMessage = utils.mergeBusMessage(parameters, defaults) | ||
} catch(e) { | ||
throw new Exception("Creating closure for external call metric service content failed: " + e) | ||
} | ||
|
||
// sendCIMessage expects String arguments | ||
return utils.getMapStringColon(mergedMessage) | ||
} | ||
} |
Oops, something went wrong.