File tree 4 files changed +14
-6
lines changed
lib/gitlab/metrics/subscribers
spec/lib/gitlab/metrics/subscribers
4 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def track(event)
19
19
values = values_for ( event )
20
20
tags = tags_for ( event )
21
21
22
- current_transaction . increment ( :view_duration , event . duration )
22
+ current_transaction . increment ( :view_duration , duration ( event ) )
23
23
current_transaction . add_metric ( SERIES , values , tags )
24
24
end
25
25
@@ -28,7 +28,7 @@ def relative_path(path)
28
28
end
29
29
30
30
def values_for ( event )
31
- { duration : event . duration }
31
+ { duration : duration ( event ) }
32
32
end
33
33
34
34
def tags_for ( event )
@@ -48,6 +48,10 @@ def tags_for(event)
48
48
def current_transaction
49
49
Transaction . current
50
50
end
51
+
52
+ def duration ( event )
53
+ event . duration * 1000.0
54
+ end
51
55
end
52
56
end
53
57
end
Original file line number Diff line number Diff line change @@ -8,14 +8,18 @@ class ActiveRecord < ActiveSupport::Subscriber
8
8
def sql ( event )
9
9
return unless current_transaction
10
10
11
- current_transaction . increment ( :sql_duration , event . duration )
11
+ current_transaction . increment ( :sql_duration , duration ( event ) )
12
12
end
13
13
14
14
private
15
15
16
16
def current_transaction
17
17
Transaction . current
18
18
end
19
+
20
+ def duration ( event )
21
+ event . duration * 1000.0
22
+ end
19
23
end
20
24
end
21
25
end
Original file line number Diff line number Diff line change 21
21
22
22
describe '#render_template' do
23
23
it 'tracks rendering of a template' do
24
- values = { duration : 2.1 }
24
+ values = { duration : 2100 }
25
25
tags = {
26
26
view : 'app/views/x.html.haml' ,
27
27
file : 'app/views/x.html.haml' ,
28
28
line : 4
29
29
}
30
30
31
31
expect ( transaction ) . to receive ( :increment ) .
32
- with ( :view_duration , 2.1 )
32
+ with ( :view_duration , 2100 )
33
33
34
34
expect ( transaction ) . to receive ( :add_metric ) .
35
35
with ( described_class ::SERIES , values , tags )
Original file line number Diff line number Diff line change 26
26
and_return ( transaction )
27
27
28
28
expect ( transaction ) . to receive ( :increment ) .
29
- with ( :sql_duration , 0.2 )
29
+ with ( :sql_duration , 200 )
30
30
31
31
subscriber . sql ( event )
32
32
end
You can’t perform that action at this time.
0 commit comments