Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
827c01b1
Commit
827c01b1
authored
Aug 21, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ability to add values to Metric events
parent
12d7d9fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
5 deletions
+39
-5
app/workers/stuck_import_jobs_worker.rb
app/workers/stuck_import_jobs_worker.rb
+6
-2
lib/gitlab/metrics/influx_db.rb
lib/gitlab/metrics/influx_db.rb
+4
-2
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+5
-1
spec/lib/gitlab/metrics/transaction_spec.rb
spec/lib/gitlab/metrics/transaction_spec.rb
+24
-0
No files found.
app/workers/stuck_import_jobs_worker.rb
View file @
827c01b1
...
...
@@ -5,8 +5,12 @@ class StuckImportJobsWorker
IMPORT_JOBS_EXPIRATION
=
15
.
hours
.
to_i
def
perform
mark_projects_without_jid_as_failed!
mark_projects_with_jid_as_failed!
values
=
{
projects_without_jid_count:
mark_projects_without_jid_as_failed!
,
projects_with_jid_count:
mark_projects_with_jid_as_failed!
}
Gitlab
::
Metrics
.
add_event_with_values
(
:stuck_import_jobs
,
values
)
end
private
...
...
lib/gitlab/metrics/influx_db.rb
View file @
827c01b1
...
...
@@ -132,9 +132,11 @@ module Gitlab
#
# See `Gitlab::Metrics::Transaction#add_event` for more details.
def
add_event
(
*
args
)
trans
=
current_transaction
current_transaction
&
.
add_event
(
*
args
)
end
trans
&
.
add_event
(
*
args
)
def
add_event_with_values
(
*
args
)
current_transaction
&
.
add_event_with_values
(
*
args
)
end
# Returns the prefix to use for the name of a series.
...
...
lib/gitlab/metrics/transaction.rb
View file @
827c01b1
...
...
@@ -66,8 +66,12 @@ module Gitlab
# event_name - The name of the event (e.g. "git_push").
# tags - A set of tags to attach to the event.
def
add_event
(
event_name
,
tags
=
{})
add_event_with_values
(
event_name
,
{},
tags
)
end
def
add_event_with_values
(
event_name
,
values
,
tags
=
{})
@metrics
<<
Metric
.
new
(
EVENT_SERIES
,
{
count:
1
},
{
count:
1
}
.
merge
(
values
)
,
{
event:
event_name
}.
merge
(
tags
),
:event
)
end
...
...
spec/lib/gitlab/metrics/transaction_spec.rb
View file @
827c01b1
...
...
@@ -161,6 +161,30 @@ describe Gitlab::Metrics::Transaction do
end
end
describe
'#add_event_with_values'
do
it
'adds a metric'
do
transaction
.
add_event_with_values
(
:meow
,
{})
expect
(
transaction
.
metrics
[
0
]).
to
be_an_instance_of
(
Gitlab
::
Metrics
::
Metric
)
end
it
'tracks values for every event'
do
transaction
.
add_event_with_values
(
:meow
,
{
number:
10
})
metric
=
transaction
.
metrics
[
0
]
expect
(
metric
.
values
).
to
eq
(
count:
1
,
number:
10
)
end
it
'allows tracking of custom tags'
do
transaction
.
add_event_with_values
(
:meow
,
{},
animal:
'cat'
)
metric
=
transaction
.
metrics
[
0
]
expect
(
metric
.
tags
).
to
eq
(
event: :meow
,
animal:
'cat'
)
end
end
describe
'#add_event'
do
it
'adds a metric'
do
transaction
.
add_event
(
:meow
)
...
...
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