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
bd9f86bb
Commit
bd9f86bb
authored
Dec 31, 2015
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use separate series for Rails/Sidekiq transactions
This removes the need for tagging all metrics with a "process_type" tag.
parent
55ed6e1c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
14 deletions
+15
-14
metric.rb
lib/gitlab/metrics/metric.rb
+1
-2
rack_middleware.rb
lib/gitlab/metrics/rack_middleware.rb
+3
-1
sidekiq_middleware.rb
lib/gitlab/metrics/sidekiq_middleware.rb
+3
-1
transaction.rb
lib/gitlab/metrics/transaction.rb
+3
-4
instrumentation_spec.rb
spec/lib/gitlab/metrics/instrumentation_spec.rb
+1
-1
metric_spec.rb
spec/lib/gitlab/metrics/metric_spec.rb
+0
-1
sidekiq_middleware_spec.rb
spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
+1
-1
action_view_spec.rb
spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
+1
-1
transaction_spec.rb
spec/lib/gitlab/metrics/transaction_spec.rb
+2
-2
No files found.
lib/gitlab/metrics/metric.rb
View file @
bd9f86bb
...
...
@@ -19,8 +19,7 @@ module Gitlab
{
series:
@series
,
tags:
@tags
.
merge
(
hostname:
Metrics
.
hostname
,
process_type:
Sidekiq
.
server?
?
'sidekiq'
:
'rails'
hostname:
Metrics
.
hostname
),
values:
@values
,
timestamp:
@created_at
.
to_i
*
1_000_000_000
...
...
lib/gitlab/metrics/rack_middleware.rb
View file @
bd9f86bb
...
...
@@ -4,6 +4,8 @@ module Gitlab
class
RackMiddleware
CONTROLLER_KEY
=
'action_controller.instance'
SERIES
=
'rails_transactions'
def
initialize
(
app
)
@app
=
app
end
...
...
@@ -30,7 +32,7 @@ module Gitlab
end
def
transaction_from_env
(
env
)
trans
=
Transaction
.
new
trans
=
Transaction
.
new
(
SERIES
)
trans
.
add_tag
(
:request_method
,
env
[
'REQUEST_METHOD'
])
trans
.
add_tag
(
:request_uri
,
env
[
'REQUEST_URI'
])
...
...
lib/gitlab/metrics/sidekiq_middleware.rb
View file @
bd9f86bb
...
...
@@ -4,8 +4,10 @@ module Gitlab
#
# This middleware is intended to be used as a server-side middleware.
class
SidekiqMiddleware
SERIES
=
'sidekiq_transactions'
def
call
(
worker
,
message
,
queue
)
trans
=
Transaction
.
new
trans
=
Transaction
.
new
(
SERIES
)
begin
trans
.
run
{
yield
}
...
...
lib/gitlab/metrics/transaction.rb
View file @
bd9f86bb
...
...
@@ -4,8 +4,6 @@ module Gitlab
class
Transaction
THREAD_KEY
=
:_gitlab_metrics_transaction
SERIES
=
'transactions'
attr_reader
:uuid
,
:tags
def
self
.
current
...
...
@@ -13,7 +11,8 @@ module Gitlab
end
# name - The name of this transaction as a String.
def
initialize
def
initialize
(
series
)
@series
=
series
@metrics
=
[]
@uuid
=
SecureRandom
.
uuid
...
...
@@ -55,7 +54,7 @@ module Gitlab
end
def
track_self
add_metric
(
SERIES
,
{
duration:
duration
},
@tags
)
add_metric
(
@series
,
{
duration:
duration
},
@tags
)
end
def
submit
...
...
spec/lib/gitlab/metrics/instrumentation_spec.rb
View file @
bd9f86bb
require
'spec_helper'
describe
Gitlab
::
Metrics
::
Instrumentation
do
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
}
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
(
'rspec'
)
}
before
do
@dummy
=
Class
.
new
do
...
...
spec/lib/gitlab/metrics/metric_spec.rb
View file @
bd9f86bb
...
...
@@ -39,7 +39,6 @@ describe Gitlab::Metrics::Metric do
expect
(
hash
[
:tags
]).
to
be_an_instance_of
(
Hash
)
expect
(
hash
[
:tags
][
:hostname
]).
to
be_an_instance_of
(
String
)
expect
(
hash
[
:tags
][
:process_type
]).
to
be_an_instance_of
(
String
)
end
it
'includes the values'
do
...
...
spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
View file @
bd9f86bb
...
...
@@ -15,7 +15,7 @@ describe Gitlab::Metrics::SidekiqMiddleware do
describe
'#tag_worker'
do
it
'adds the worker class and action to the transaction'
do
trans
=
Gitlab
::
Metrics
::
Transaction
.
new
trans
=
Gitlab
::
Metrics
::
Transaction
.
new
(
'rspec'
)
worker
=
double
(
:worker
,
class:
double
(
:class
,
name:
'TestWorker'
))
expect
(
trans
).
to
receive
(
:add_tag
).
with
(
:action
,
'TestWorker#perform'
)
...
...
spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
View file @
bd9f86bb
require
'spec_helper'
describe
Gitlab
::
Metrics
::
Subscribers
::
ActionView
do
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
}
let
(
:transaction
)
{
Gitlab
::
Metrics
::
Transaction
.
new
(
'rspec'
)
}
let
(
:subscriber
)
{
described_class
.
new
}
...
...
spec/lib/gitlab/metrics/transaction_spec.rb
View file @
bd9f86bb
require
'spec_helper'
describe
Gitlab
::
Metrics
::
Transaction
do
let
(
:transaction
)
{
described_class
.
new
}
let
(
:transaction
)
{
described_class
.
new
(
'rspec'
)
}
describe
'#duration'
do
it
'returns the duration of a transaction in seconds'
do
...
...
@@ -58,7 +58,7 @@ describe Gitlab::Metrics::Transaction do
describe
'#track_self'
do
it
'adds a metric for the transaction itself'
do
expect
(
transaction
).
to
receive
(
:add_metric
).
with
(
described_class
::
SERIES
,
{
duration:
transaction
.
duration
},
{})
with
(
'rspec'
,
{
duration:
transaction
.
duration
},
{})
transaction
.
track_self
end
...
...
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