Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
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:
...
@@ -46,7 +46,7 @@ probes:
opts:
opts:
<<: *db_common_opts
<<: *db_common_opts
allowed_repeated_commands_count: 2
allowed_repeated_commands_count: 2
count_
created_builds
: fals
e
created_builds
_counting_disabled: tru
e
tuple_stats:
tuple_stats:
class_name: Database::TuplesProber
class_name: Database::TuplesProber
<<: *db_common
<<: *db_common
...
...
lib/gitlab_monitor/database/ci_builds.rb
View file @
d466a6f1
...
@@ -239,12 +239,12 @@ module GitLab
...
@@ -239,12 +239,12 @@ module GitLab
super
(
opts
)
super
(
opts
)
@allowed_repeated_commands_count
=
opts
[
:allowed_repeated_commands_count
]
@allowed_repeated_commands_count
=
opts
[
:allowed_repeated_commands_count
]
@
count_
created_builds
=
opts
[
:
count_
created_builds
]
@created_builds
_counting_disabled
=
opts
[
:created_builds
_counting_disabled
]
end
end
def
run
def
run
results
=
{}
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
[
:pending_builds
]
=
builds
(
STATUS_PENDING
)
results
[
:stale_builds
]
=
stale_builds
results
[
:stale_builds
]
=
stale_builds
results
[
:per_runner
]
=
per_runner_builds
results
[
:per_runner
]
=
per_runner_builds
...
@@ -378,7 +378,7 @@ module GitLab
...
@@ -378,7 +378,7 @@ module GitLab
collector_opts
=
{
connection_string:
opts
[
:connection_string
],
collector_opts
=
{
connection_string:
opts
[
:connection_string
],
allowed_repeated_commands_count:
opts
[
:allowed_repeated_commands_count
],
allowed_repeated_commands_count:
opts
[
:allowed_repeated_commands_count
],
count_
created_builds:
opts
[
:
count_
created_builds
]
}
created_builds
_counting_disabled
:
opts
[
:created_builds
_counting_disabled
]
}
@collector
=
CiBuildsCollector
.
new
(
collector_opts
)
@collector
=
CiBuildsCollector
.
new
(
collector_opts
)
end
end
...
...
spec/database/ci_builds_spec.rb
View file @
d466a6f1
...
@@ -15,7 +15,7 @@ describe GitLab::Monitor::Database do
...
@@ -15,7 +15,7 @@ describe GitLab::Monitor::Database do
let
(
:connection_pool
)
{
double
(
"connection pool"
)
}
let
(
:connection_pool
)
{
double
(
"connection pool"
)
}
let
(
:connection
)
{
double
(
"connection"
)
}
let
(
:connection
)
{
double
(
"connection"
)
}
let
(
:allowed_repeated_commands_count
)
{
5
}
let
(
:allowed_repeated_commands_count
)
{
5
}
let
(
:
count_
created_builds
)
{
fals
e
}
let
(
:created_builds
_counting_disabled
)
{
tru
e
}
def
stub_ee
def
stub_ee
allow
(
connection
).
to
receive
(
:exec
).
with
(
mirror_column_query
).
and_return
([{
"exists"
=>
"t"
}])
allow
(
connection
).
to
receive
(
:exec
).
with
(
mirror_column_query
).
and_return
([{
"exists"
=>
"t"
}])
...
@@ -146,7 +146,7 @@ describe GitLab::Monitor::Database do
...
@@ -146,7 +146,7 @@ describe GitLab::Monitor::Database do
let
(
:collector
)
do
let
(
:collector
)
do
described_class
.
new
(
connection_string:
"host=localhost"
,
described_class
.
new
(
connection_string:
"host=localhost"
,
allowed_repeated_commands_count:
allowed_repeated_commands_count
,
allowed_repeated_commands_count:
allowed_repeated_commands_count
,
count_
created_builds
:
count
_created_builds
)
created_builds
_
count
ing_disabled:
created_builds_counting_disabled
)
end
end
let
(
:expected_stale_builds
)
{
2
}
let
(
:expected_stale_builds
)
{
2
}
...
@@ -161,8 +161,8 @@ describe GitLab::Monitor::Database do
...
@@ -161,8 +161,8 @@ describe GitLab::Monitor::Database do
expect
(
subject
[
:pending_builds
]).
to
include
(
*
expected_pending_builds
)
expect
(
subject
[
:pending_builds
]).
to
include
(
*
expected_pending_builds
)
end
end
context
"when
count_
created_build is set to
tru
e"
do
context
"when created_build
s_counting_disabled
is set to
fals
e"
do
let
(
:
count_
created_builds
)
{
tru
e
}
let
(
:created_builds
_counting_disabled
)
{
fals
e
}
it
"returns raw created_builds data"
do
it
"returns raw created_builds data"
do
expect
(
subject
).
to
have_key
(
:created_builds
)
expect
(
subject
).
to
have_key
(
:created_builds
)
...
@@ -170,8 +170,8 @@ describe GitLab::Monitor::Database do
...
@@ -170,8 +170,8 @@ describe GitLab::Monitor::Database do
end
end
end
end
context
"when
count_
created_build is set to
fals
e"
do
context
"when created_build
s_counting_disabled
is set to
tru
e"
do
let
(
:
count_
created_builds
)
{
fals
e
}
let
(
:created_builds
_counting_disabled
)
{
tru
e
}
it
"doesn't return raw created_builds data"
do
it
"doesn't return raw created_builds data"
do
expect
(
subject
).
not_to
have_key
(
:created_builds
)
expect
(
subject
).
not_to
have_key
(
:created_builds
)
...
@@ -257,7 +257,7 @@ describe GitLab::Monitor::Database do
...
@@ -257,7 +257,7 @@ describe GitLab::Monitor::Database do
let
(
:prober
)
do
let
(
:prober
)
do
opts
=
{
connection_string:
"host=localhost"
,
opts
=
{
connection_string:
"host=localhost"
,
allowed_repeated_commands_count:
allowed_repeated_commands_count
,
allowed_repeated_commands_count:
allowed_repeated_commands_count
,
count_
created_builds
:
count
_created_builds
}
created_builds
_
count
ing_disabled:
created_builds_counting_disabled
}
described_class
.
new
(
opts
,
described_class
.
new
(
opts
,
metrics:
GitLab
::
Monitor
::
PrometheusMetrics
.
new
(
include_timestamp:
false
))
metrics:
GitLab
::
Monitor
::
PrometheusMetrics
.
new
(
include_timestamp:
false
))
end
end
...
@@ -274,8 +274,8 @@ describe GitLab::Monitor::Database do
...
@@ -274,8 +274,8 @@ describe GitLab::Monitor::Database do
end
end
context
"when PG exceptions aren't raised"
do
context
"when PG exceptions aren't raised"
do
context
"when
count_
created_builds is set to
tru
e"
do
context
"when created_builds
_counting_disabled
is set to
fals
e"
do
let
(
:
count_
created_builds
)
{
tru
e
}
let
(
:created_builds
_counting_disabled
)
{
fals
e
}
it
"responds with created builds Prometheus metrics"
do
it
"responds with created builds Prometheus metrics"
do
ci_created_builds_expected_lines
.
each
do
|
expected_line
|
ci_created_builds_expected_lines
.
each
do
|
expected_line
|
...
@@ -284,8 +284,8 @@ describe GitLab::Monitor::Database do
...
@@ -284,8 +284,8 @@ describe GitLab::Monitor::Database do
end
end
end
end
context
"when
count_
created_builds is set to
fals
e"
do
context
"when created_builds
_counting_disabled
is set to
tru
e"
do
let
(
:
count_
created_builds
)
{
fals
e
}
let
(
:created_builds
_counting_disabled
)
{
tru
e
}
it
"doesn't respond with created builds Prometheus metrics"
do
it
"doesn't respond with created builds Prometheus metrics"
do
ci_created_builds_expected_lines
.
each
do
|
expected_line
|
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