BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f464adaa
Commit
f464adaa
authored
Aug 29, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove transaction tags and map transaction metrics to prometheus
+ clean transaction metrics + Gemfile.lock file update
parent
3b146480
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
58 deletions
+24
-58
influx_db.rb
lib/gitlab/metrics/influx_db.rb
+0
-10
transaction.rb
lib/gitlab/metrics/transaction.rb
+24
-15
transaction_spec.rb
spec/lib/gitlab/metrics/transaction_spec.rb
+0
-8
metrics_spec.rb
spec/lib/gitlab/metrics_spec.rb
+0
-25
No files found.
lib/gitlab/metrics/influx_db.rb
View file @
f464adaa
...
...
@@ -109,16 +109,6 @@ module Gitlab
retval
end
# Adds a tag to the current transaction (if any)
#
# name - The name of the tag to add.
# value - The value of the tag.
def
tag_transaction
(
name
,
value
)
trans
=
current_transaction
trans
&
.
add_tag
(
name
,
value
)
end
# Sets the action of the current transaction (if any)
#
# action - The name of the action.
...
...
lib/gitlab/metrics/transaction.rb
View file @
f464adaa
...
...
@@ -40,6 +40,24 @@ module Gitlab
@memory_after
-
@memory_before
end
def
self
.
metric_transaction_duration_milliseconds
@metrics_transaction_duration_milliseconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_duration_milliseconds
,
'Method duration milliseconds'
,
{},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
5000
]
)
end
def
self
.
metric_transaction_allocated_memory_bytes
@metric_transaction_allocated_memory_bytes
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_allocated_memory_bytes
,
'Method duration milliseconds'
,
{},
[
1000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
5000000
]
)
end
def
run
Thread
.
current
[
THREAD_KEY
]
=
self
...
...
@@ -51,10 +69,8 @@ module Gitlab
@memory_after
=
System
.
memory_usage
@finished_at
=
System
.
monotonic_time
Gitlab
::
Metrics
.
histogram
(
"gitlab_method_duration_seconds"
.
to_sym
,
"Method duration seconds"
,
@tags
).
observe
({},
)
self
.
class
.
prometheus_gauge
(
:duration
).
set
(
@tags
,
duration
)
self
.
class
.
prometheus_gauge
(
:allocated_memory
).
set
(
@tags
,
allocated_memory
)
self
.
class
.
metric_transaction_duration_milliseconds
.
observe
({},
duration
)
self
.
class
.
metric_transaction_allocated_memory_bytes
.
observe
({},
allocated_memory
)
Thread
.
current
[
THREAD_KEY
]
=
nil
end
...
...
@@ -71,8 +87,8 @@ 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
=
{})
Gitlab
::
Metrics
.
counter
(
"gitlab_
event_
#{
event_name
}
"
.
to_sym
,
"E
vent
#{
event_name
}
"
,
tags
).
increment
({})
@metrics
<<
Metric
.
new
(
EVENT_SERIES
,
{
count:
1
},
label
s
,
:event
)
Gitlab
::
Metrics
.
counter
(
"gitlab_
transaction_event_
#{
event_name
}
_total"
.
to_sym
,
"Transaction e
vent
#{
event_name
}
"
,
tags
).
increment
({})
@metrics
<<
Metric
.
new
(
EVENT_SERIES
,
{
count:
1
},
tag
s
,
:event
)
end
# Returns a MethodCall object for the given name.
...
...
@@ -85,17 +101,15 @@ module Gitlab
end
def
increment
(
name
,
value
)
Gitlab
::
Metrics
.
counter
(
"gitlab_transaction_
#{
name
}
_total"
.
to_sym
,
"Transaction counter
#{
name
}
"
,
{}).
increment
({},
value
)
@values
[
name
]
+=
value
end
def
set
(
name
,
value
)
Gitlab
::
Metrics
.
gauge
(
"gitlab_transaction_
#{
name
}
"
.
to_sym
,
"Transaction gauge
#{
name
}
"
,
{},
:livesum
).
set
({},
value
)
@values
[
name
]
=
value
end
def
add_tag
(
key
,
value
)
@tags
[
key
]
=
value
end
def
finish
track_self
submit
...
...
@@ -106,16 +120,11 @@ module Gitlab
@values
.
each
do
|
name
,
value
|
values
[
name
]
=
value
self
.
class
.
prometheus_gauge
(
name
).
set
(
@tags
,
value
)
end
add_metric
(
'transactions'
,
values
,
@tags
)
end
def
self
.
prometheus_gauge
(
name
)
Gitlab
::
Metrics
.
gauge
(
"gitlab_transaction_
#{
name
}
"
.
to_sym
,
"Gitlab Transaction
#{
name
}
"
)
end
def
submit
submit
=
@metrics
.
dup
...
...
spec/lib/gitlab/metrics/transaction_spec.rb
View file @
f464adaa
...
...
@@ -85,14 +85,6 @@ describe Gitlab::Metrics::Transaction do
end
end
describe
'#add_tag'
do
it
'adds a tag'
do
transaction
.
add_tag
(
:foo
,
'bar'
)
expect
(
transaction
.
tags
).
to
eq
({
foo:
'bar'
})
end
end
describe
'#finish'
do
it
'tracks the transaction details and submits them to Sidekiq'
do
expect
(
transaction
).
to
receive
(
:track_self
)
...
...
spec/lib/gitlab/metrics_spec.rb
View file @
f464adaa
...
...
@@ -143,31 +143,6 @@ describe Gitlab::Metrics do
end
end
describe
'.tag_transaction'
do
context
'without a transaction'
do
it
'does nothing'
do
expect_any_instance_of
(
Gitlab
::
Metrics
::
Transaction
)
.
not_to
receive
(
:add_tag
)
described_class
.
tag_transaction
(
:foo
,
'bar'
)
end
end
context
'with a transaction'
do
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
}
it
'adds the tag to the transaction'
do
expect
(
described_class
).
to
receive
(
:current_transaction
)
.
and_return
(
transaction
)
expect
(
transaction
).
to
receive
(
:add_tag
)
.
with
(
:foo
,
'bar'
)
described_class
.
tag_transaction
(
:foo
,
'bar'
)
end
end
end
describe
'.action='
do
context
'without a transaction'
do
it
'does nothing'
do
...
...
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