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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
61561a9e
Commit
61561a9e
authored
Jan 07, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'remove-more-influxdb-tags' into 'master'
See merge request !2328
parents
9f268708
7b10cb6f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
lib/gitlab/metrics/rack_middleware.rb
lib/gitlab/metrics/rack_middleware.rb
+2
-2
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+5
-3
spec/lib/gitlab/metrics/rack_middleware_spec.rb
spec/lib/gitlab/metrics/rack_middleware_spec.rb
+3
-3
spec/lib/gitlab/metrics/transaction_spec.rb
spec/lib/gitlab/metrics/transaction_spec.rb
+13
-2
No files found.
lib/gitlab/metrics/rack_middleware.rb
View file @
61561a9e
...
@@ -32,8 +32,8 @@ module Gitlab
...
@@ -32,8 +32,8 @@ module Gitlab
def
transaction_from_env
(
env
)
def
transaction_from_env
(
env
)
trans
=
Transaction
.
new
trans
=
Transaction
.
new
trans
.
add_tag
(
:request_method
,
env
[
'REQUEST_METHOD
'
])
trans
.
set
(
:request_uri
,
env
[
'REQUEST_URI
'
])
trans
.
add_tag
(
:request_uri
,
env
[
'REQUEST_URI
'
])
trans
.
set
(
:request_method
,
env
[
'REQUEST_METHOD
'
])
trans
trans
end
end
...
...
lib/gitlab/metrics/transaction.rb
View file @
61561a9e
...
@@ -4,7 +4,7 @@ module Gitlab
...
@@ -4,7 +4,7 @@ module Gitlab
class
Transaction
class
Transaction
THREAD_KEY
=
:_gitlab_metrics_transaction
THREAD_KEY
=
:_gitlab_metrics_transaction
attr_reader
:
uuid
,
:tag
s
attr_reader
:
tags
,
:value
s
def
self
.
current
def
self
.
current
Thread
.
current
[
THREAD_KEY
]
Thread
.
current
[
THREAD_KEY
]
...
@@ -12,7 +12,6 @@ module Gitlab
...
@@ -12,7 +12,6 @@ module Gitlab
def
initialize
def
initialize
@metrics
=
[]
@metrics
=
[]
@uuid
=
SecureRandom
.
uuid
@started_at
=
nil
@started_at
=
nil
@finished_at
=
nil
@finished_at
=
nil
...
@@ -38,7 +37,6 @@ module Gitlab
...
@@ -38,7 +37,6 @@ module Gitlab
end
end
def
add_metric
(
series
,
values
,
tags
=
{})
def
add_metric
(
series
,
values
,
tags
=
{})
tags
=
tags
.
merge
(
transaction_id:
@uuid
)
prefix
=
sidekiq?
?
'sidekiq_'
:
'rails_'
prefix
=
sidekiq?
?
'sidekiq_'
:
'rails_'
@metrics
<<
Metric
.
new
(
"
#{
prefix
}#{
series
}
"
,
values
,
tags
)
@metrics
<<
Metric
.
new
(
"
#{
prefix
}#{
series
}
"
,
values
,
tags
)
...
@@ -48,6 +46,10 @@ module Gitlab
...
@@ -48,6 +46,10 @@ module Gitlab
@values
[
name
]
+=
value
@values
[
name
]
+=
value
end
end
def
set
(
name
,
value
)
@values
[
name
]
=
value
end
def
add_tag
(
key
,
value
)
def
add_tag
(
key
,
value
)
@tags
[
key
]
=
value
@tags
[
key
]
=
value
end
end
...
...
spec/lib/gitlab/metrics/rack_middleware_spec.rb
View file @
61561a9e
...
@@ -40,9 +40,9 @@ describe Gitlab::Metrics::RackMiddleware do
...
@@ -40,9 +40,9 @@ describe Gitlab::Metrics::RackMiddleware do
expect
(
transaction
).
to
be_an_instance_of
(
Gitlab
::
Metrics
::
Transaction
)
expect
(
transaction
).
to
be_an_instance_of
(
Gitlab
::
Metrics
::
Transaction
)
end
end
it
'
tags the transaction with the request method and URI
'
do
it
'
stores the request method and URI in the transaction as values
'
do
expect
(
transaction
.
tag
s
[
:request_method
]).
to
eq
(
'GET'
)
expect
(
transaction
.
value
s
[
:request_method
]).
to
eq
(
'GET'
)
expect
(
transaction
.
tag
s
[
:request_uri
]).
to
eq
(
'/foo'
)
expect
(
transaction
.
value
s
[
:request_uri
]).
to
eq
(
'/foo'
)
end
end
end
end
...
...
spec/lib/gitlab/metrics/transaction_spec.rb
View file @
61561a9e
...
@@ -30,9 +30,9 @@ describe Gitlab::Metrics::Transaction do
...
@@ -30,9 +30,9 @@ describe Gitlab::Metrics::Transaction do
end
end
describe
'#add_metric'
do
describe
'#add_metric'
do
it
'adds a metric t
agged with the transaction UUID
'
do
it
'adds a metric t
o the transaction
'
do
expect
(
Gitlab
::
Metrics
::
Metric
).
to
receive
(
:new
).
expect
(
Gitlab
::
Metrics
::
Metric
).
to
receive
(
:new
).
with
(
'rails_foo'
,
{
number:
10
},
{
transaction_id:
transaction
.
uuid
})
with
(
'rails_foo'
,
{
number:
10
},
{})
transaction
.
add_metric
(
'foo'
,
number:
10
)
transaction
.
add_metric
(
'foo'
,
number:
10
)
end
end
...
@@ -50,6 +50,17 @@ describe Gitlab::Metrics::Transaction do
...
@@ -50,6 +50,17 @@ describe Gitlab::Metrics::Transaction do
end
end
end
end
describe
'#set'
do
it
'sets a value'
do
transaction
.
set
(
:number
,
10
)
expect
(
transaction
).
to
receive
(
:add_metric
).
with
(
'transactions'
,
{
duration:
0.0
,
number:
10
},
{})
transaction
.
track_self
end
end
describe
'#add_tag'
do
describe
'#add_tag'
do
it
'adds a tag'
do
it
'adds a tag'
do
transaction
.
add_tag
(
:foo
,
'bar'
)
transaction
.
add_tag
(
:foo
,
'bar'
)
...
...
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