Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gitlab-exporter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gitlab-org
gitlab-exporter
Commits
d466a6f1
Verified
Commit
d466a6f1
authored
Apr 03, 2019
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ci_created_builds to be gathered by default with option to disable
parent
400c4cf5
Pipeline
#108692
passed with stage
in 25 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
+15
-15
config/gitlab-monitor.yml.example
config/gitlab-monitor.yml.example
+1
-1
lib/gitlab_monitor/database/ci_builds.rb
lib/gitlab_monitor/database/ci_builds.rb
+3
-3
spec/database/ci_builds_spec.rb
spec/database/ci_builds_spec.rb
+11
-11
No files found.
config/gitlab-monitor.yml.example
View file @
d466a6f1
...
...
@@ -46,7 +46,7 @@ probes:
opts:
<<: *db_common_opts
allowed_repeated_commands_count: 2
c
ount_created_builds: fals
e
c
reated_builds_counting_disabled: tru
e
tuple_stats:
class_name: Database::TuplesProber
<<: *db_common
...
...
lib/gitlab_monitor/database/ci_builds.rb
View file @
d466a6f1
...
...
@@ -239,12 +239,12 @@ module GitLab
super
(
opts
)
@allowed_repeated_commands_count
=
opts
[
:allowed_repeated_commands_count
]
@c
ount_created_builds
=
opts
[
:count_created_builds
]
@c
reated_builds_counting_disabled
=
opts
[
:created_builds_counting_disabled
]
end
def
run
results
=
{}
results
[
:created_builds
]
=
builds
(
STATUS_CREATED
)
if
@count_created_builds
results
[
:created_builds
]
=
builds
(
STATUS_CREATED
)
unless
@created_builds_counting_disabled
results
[
:pending_builds
]
=
builds
(
STATUS_PENDING
)
results
[
:stale_builds
]
=
stale_builds
results
[
:per_runner
]
=
per_runner_builds
...
...
@@ -378,7 +378,7 @@ module GitLab
collector_opts
=
{
connection_string:
opts
[
:connection_string
],
allowed_repeated_commands_count:
opts
[
:allowed_repeated_commands_count
],
c
ount_created_builds:
opts
[
:count_created_builds
]
}
c
reated_builds_counting_disabled:
opts
[
:created_builds_counting_disabled
]
}
@collector
=
CiBuildsCollector
.
new
(
collector_opts
)
end
...
...
spec/database/ci_builds_spec.rb
View file @
d466a6f1
...
...
@@ -15,7 +15,7 @@ describe GitLab::Monitor::Database do
let
(
:connection_pool
)
{
double
(
"connection pool"
)
}
let
(
:connection
)
{
double
(
"connection"
)
}
let
(
:allowed_repeated_commands_count
)
{
5
}
let
(
:c
ount_created_builds
)
{
fals
e
}
let
(
:c
reated_builds_counting_disabled
)
{
tru
e
}
def
stub_ee
allow
(
connection
).
to
receive
(
:exec
).
with
(
mirror_column_query
).
and_return
([{
"exists"
=>
"t"
}])
...
...
@@ -146,7 +146,7 @@ describe GitLab::Monitor::Database do
let
(
:collector
)
do
described_class
.
new
(
connection_string:
"host=localhost"
,
allowed_repeated_commands_count:
allowed_repeated_commands_count
,
c
ount_created_builds:
count_created_builds
)
c
reated_builds_counting_disabled:
created_builds_counting_disabled
)
end
let
(
:expected_stale_builds
)
{
2
}
...
...
@@ -161,8 +161,8 @@ describe GitLab::Monitor::Database do
expect
(
subject
[
:pending_builds
]).
to
include
(
*
expected_pending_builds
)
end
context
"when c
ount_created_build is set to tru
e"
do
let
(
:c
ount_created_builds
)
{
tru
e
}
context
"when c
reated_builds_counting_disabled is set to fals
e"
do
let
(
:c
reated_builds_counting_disabled
)
{
fals
e
}
it
"returns raw created_builds data"
do
expect
(
subject
).
to
have_key
(
:created_builds
)
...
...
@@ -170,8 +170,8 @@ describe GitLab::Monitor::Database do
end
end
context
"when c
ount_created_build is set to fals
e"
do
let
(
:c
ount_created_builds
)
{
fals
e
}
context
"when c
reated_builds_counting_disabled is set to tru
e"
do
let
(
:c
reated_builds_counting_disabled
)
{
tru
e
}
it
"doesn't return raw created_builds data"
do
expect
(
subject
).
not_to
have_key
(
:created_builds
)
...
...
@@ -257,7 +257,7 @@ describe GitLab::Monitor::Database do
let
(
:prober
)
do
opts
=
{
connection_string:
"host=localhost"
,
allowed_repeated_commands_count:
allowed_repeated_commands_count
,
c
ount_created_builds:
count_created_builds
}
c
reated_builds_counting_disabled:
created_builds_counting_disabled
}
described_class
.
new
(
opts
,
metrics:
GitLab
::
Monitor
::
PrometheusMetrics
.
new
(
include_timestamp:
false
))
end
...
...
@@ -274,8 +274,8 @@ describe GitLab::Monitor::Database do
end
context
"when PG exceptions aren't raised"
do
context
"when c
ount_created_builds is set to tru
e"
do
let
(
:c
ount_created_builds
)
{
tru
e
}
context
"when c
reated_builds_counting_disabled is set to fals
e"
do
let
(
:c
reated_builds_counting_disabled
)
{
fals
e
}
it
"responds with created builds Prometheus metrics"
do
ci_created_builds_expected_lines
.
each
do
|
expected_line
|
...
...
@@ -284,8 +284,8 @@ describe GitLab::Monitor::Database do
end
end
context
"when c
ount_created_builds is set to fals
e"
do
let
(
:c
ount_created_builds
)
{
fals
e
}
context
"when c
reated_builds_counting_disabled is set to tru
e"
do
let
(
:c
reated_builds_counting_disabled
)
{
tru
e
}
it
"doesn't respond with created builds Prometheus metrics"
do
ci_created_builds_expected_lines
.
each
do
|
expected_line
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment