Skip to content

Commit

Permalink
added more example metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
wickenkamp committed Oct 30, 2019
1 parent 323dcc7 commit ec3be9d
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 0 deletions.
19 changes: 19 additions & 0 deletions projects/default/metrics/bugsratiojira.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# values starting with $$ are looked up in project.properties
index=$$jira.index

enabled=true
name=Non-Bug Density
description=Percentage of open issues not being Bugs
factors=softwarestability
weights=1.0

param.project=$$jira.project
param.status.unresolved=["Open","In Progress","To be reviewed","Ready for Implementation"]
param.bug.issuetypes = ["Bug"]

result.openIssues=hits.total
result.openBugs=aggregations.openbugs.doc_count

# metric defines a formula based on execution results of parameter- and metric-queries
metric= ( openIssues - openBugs ) / openIssues
onError=set0
16 changes: 16 additions & 0 deletions projects/default/metrics/bugsratiojira.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"size": 0,
"query": {
"bool": {
"must" : [
{"term" : { "projectKey": "{{projectKey}}" } },
{"terms" : { "status" : {{#toJson}}status.unresolved{{/toJson}} } }
]
}
},
"aggs": {
"openbugs": {
"filter": { "terms" : {"issuetype" : {{#toJson}}bug.issuetypes{{/toJson}} } }
}
}
}
19 changes: 19 additions & 0 deletions projects/default/metrics/bugsratioredmine.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# values starting with $$ are looked up in project.properties
index=$$redmine.index

enabled=true
name=Non-Bug Density
description=Percentage of open issues not being Bugs
factors=softwarestability
weights=1.0

param.project=$$redmine.project
param.status.unresolved=["New","Assigned","Feedback"]
param.bug.trackers = ["Issue"]

result.openIssues=hits.total
result.openBugs=aggregations.openbugs.doc_count

# metric defines a formula based on execution results of parameter- and metric-queries
metric= ( openIssues - openBugs ) / openIssues
onError=set0
16 changes: 16 additions & 0 deletions projects/default/metrics/bugsratioredmine.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"size": 0,
"query": {
"bool": {
"must" : [
{"term" : { "project": "{{project}}" } },
{"terms" : { "status" : {{#toJson}}status.unresolved{{/toJson}} } }
]
}
},
"aggs": {
"openbugs": {
"filter": { "terms" : {"tracker" : {{#toJson}}bug.trackers{{/toJson}} } }
}
}
}
19 changes: 19 additions & 0 deletions projects/default/metrics/testperformance.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# values starting with $$ are looked up in project.properties
index=$$jenkins.index

enabled=true
name=Test Performance
description=Last test duration is within limit
factors=testingstatus
weights=2.0

param.testperformance.limit.seconds=900
param.jobName=$$jenkins.jobName

# the metric is computed by a script
# "if ( doc['testDuration'].value < {{testperformance.limit.seconds}}) return 1; else return 0;"
result.performanceOK=hits.hits[0].fields.performanceOK[0]

# metric defines a formula based on execution results of parameter- and metric-queries
metric = performanceOK
onError=set0
14 changes: 14 additions & 0 deletions projects/default/metrics/testperformance.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"query" : {"bool": { "must" : { "match" : { "jobName" : "{{jobName}}" }}}},
"sort" : { "buildNumber" : {"order" : "desc"}},
"size" : 1,

"script_fields": {
"performanceOK": {
"script": {
"lang": "painless",
"inline": "if ( doc['testDuration'].value < {{testperformance.limit.seconds}} ) return 1; else return 0;"
}
}
}
}
18 changes: 18 additions & 0 deletions projects/default/metrics/testsuccess.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# values starting with $$ are looked up in project.properties
index=$$jenkins.index

enabled=true
name=Passed Tests Percentage
description=Percentage tests being passed
factors=testingstatus
weights=2.0

param.jobName=$$jenkins.jobName

result.testsPass = hits.hits[0]._source.testsPass
result.testsFail = hits.hits[0]._source.testsFail
result.testsSkip = hits.hits[0]._source.testsSkip

# metric defines a formula based on execution results of parameter- and metric-queries
metric = testsPass / ( testsPass + testsFail + testsSkip )
onError=set0
5 changes: 5 additions & 0 deletions projects/default/metrics/testsuccess.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"query" : {"bool": { "must" : { "match" : { "jobName" : "{{jobName}}" }}}},
"sort" : { "buildNumber" : {"order" : "desc"}},
"size" : 1
}
17 changes: 17 additions & 0 deletions projects/default/metrics/welldefinedissuesjira.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# values starting with $$ are looked up in project.properties
index=$$jira.status.index

enabled=true
name=Well defined issues (Jira)
description=Percentage of issues created within the last month that have required properties defined
factors=qualityissuespecification
weights=1.0

param.projectKey=$$jira.projectKey

result.totalIssues=hits.total
result.welldefinedIssues=aggregations.welldefined.doc_count

# metric defines a formula based on execution results of parameter- and metric-queries
metric= welldefinedIssues / totalIssues
onError=set0
23 changes: 23 additions & 0 deletions projects/default/metrics/welldefinedissuesjira.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"size": 0,
"query": {
"bool" : {
"must" : [
{ "term" : { "projectKey" : "{{projectKey}}" } },
{ "range" : { "created" : { "from" : "now-3000d" } } }
]
}
},
"aggs" : {
"welldefined" : {
"filter" : {
"bool" : {
"must" : [
{ "exists" : { "field" : "duedate" } },
{ "exists" : { "field" : "description" } }
]
}
}
}
}
}

0 comments on commit ec3be9d

Please sign in to comment.