Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apachedex
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
apachedex
Commits
a0b17f3c
Commit
a0b17f3c
authored
Apr 18, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also error error count to hit plot.
So apdex score impact of errors vs. slowness can be easily estimated.
parent
06b24373
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
13 deletions
+41
-13
apachedex/__init__.py
apachedex/__init__.py
+41
-13
No files found.
apachedex/__init__.py
View file @
a0b17f3c
...
@@ -142,30 +142,47 @@ def getClassForStatusHit(hit, status):
...
@@ -142,30 +142,47 @@ def getClassForStatusHit(hit, status):
return
'problem'
return
'problem'
return
''
return
''
def
getDataPoints
(
apdex_dict
):
def
getDataPoints
(
apdex_dict
,
status_period_dict
=
{}):
period_error_dict
=
defaultdict
(
int
)
for
status
,
period_dict
in
status_period_dict
.
iteritems
():
if
statusIsError
(
status
):
for
period
,
hit
in
period_dict
.
iteritems
():
period_error_dict
[
period
]
+=
hit
try
:
# If there was an error, there was a hit, and apdex_dict must contain it
# (at same date).
assert
len
(
set
(
period_error_dict
)
-
set
(
apdex_dict
))
==
0
except
:
import
pdb
;
pdb
.
set_trace
()
raise
return
[
return
[
(
value_date
,
apdex
.
getApdex
()
*
100
,
apdex
.
hit
)
for
value_date
,
apdex
(
in
sorted
(
apdex_dict
.
iteritems
(),
key
=
ITEMGETTER0
)]
value_date
,
apdex
.
getApdex
()
*
100
,
apdex
.
hit
,
period_error_dict
.
get
(
value_date
,
0
),
)
for
value_date
,
apdex
in
sorted
(
apdex_dict
.
iteritems
(),
key
=
ITEMGETTER0
)
]
def
prepareDataForGraph
(
daily_data
,
date_format
,
placeholder_delta
,
def
prepareDataForGraph
(
daily_data
,
date_format
,
placeholder_delta
,
coefficient_callback
,
x_min
=
None
,
x_max
=
None
):
coefficient_callback
,
x_min
=
None
,
x_max
=
None
):
current_date
=
datetime
.
strptime
(
x_min
or
daily_data
[
0
][
0
],
date_format
)
current_date
=
datetime
.
strptime
(
x_min
or
daily_data
[
0
][
0
],
date_format
)
new_daily_data
=
[]
new_daily_data
=
[]
append
=
new_daily_data
.
append
append
=
new_daily_data
.
append
for
(
measure_date_string
,
apdex
,
hit
)
in
daily_data
:
for
(
measure_date_string
,
apdex
,
hit
,
error_hit
)
in
daily_data
:
measure_date
=
datetime
.
strptime
(
measure_date_string
,
date_format
)
measure_date
=
datetime
.
strptime
(
measure_date_string
,
date_format
)
if
current_date
<
measure_date
:
if
current_date
<
measure_date
:
append
((
current_date
.
strftime
(
date_format
),
100
,
0
))
append
((
current_date
.
strftime
(
date_format
),
100
,
0
,
0
))
placeholder_end_date
=
measure_date
-
placeholder_delta
placeholder_end_date
=
measure_date
-
placeholder_delta
if
placeholder_end_date
>
current_date
:
if
placeholder_end_date
>
current_date
:
append
((
placeholder_end_date
.
strftime
(
date_format
),
100
,
0
))
append
((
placeholder_end_date
.
strftime
(
date_format
),
100
,
0
,
0
))
append
((
measure_date_string
,
apdex
,
coef
=
coefficient_callback
(
measure_date
)
hit
*
coefficient_callback
(
measure_date
)
))
append
((
measure_date_string
,
apdex
,
hit
*
coef
,
error_hit
*
coef
))
current_date
=
measure_date
+
placeholder_delta
current_date
=
measure_date
+
placeholder_delta
if
x_max
is
not
None
and
current_date
<
datetime
.
strptime
(
x_max
,
if
x_max
is
not
None
and
current_date
<
datetime
.
strptime
(
x_max
,
date_format
):
date_format
):
append
((
current_date
.
strftime
(
date_format
),
100
,
0
))
append
((
current_date
.
strftime
(
date_format
),
100
,
0
,
0
))
append
((
x_max
,
100
,
0
))
append
((
x_max
,
100
,
0
,
0
))
return
new_daily_data
return
new_daily_data
def
graphPair
(
daily_data
,
date_format
,
graph_period
,
apdex_y_min
=
None
,
def
graphPair
(
daily_data
,
date_format
,
graph_period
,
apdex_y_min
=
None
,
...
@@ -200,7 +217,17 @@ def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
...
@@ -200,7 +217,17 @@ def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
},
},
},
},
)
+
graph
(
'Hits (per %s)'
%
graph_period
,
)
+
graph
(
'Hits (per %s)'
%
graph_period
,
[
zip
(
date_list
,
(
x
[
2
]
for
x
in
daily_data
))],
[
{
'label'
:
'Errors'
,
'data'
:
zip
(
date_list
,
(
x
[
3
]
for
x
in
daily_data
)),
'color'
:
'red'
,
},
{
'label'
:
'Hits'
,
'data'
:
zip
(
date_list
,
(
x
[
2
]
for
x
in
daily_data
)),
},
],
{
{
'xaxis'
:
{
'xaxis'
:
{
'mode'
:
'time'
,
'mode'
:
'time'
,
...
@@ -221,6 +248,7 @@ def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
...
@@ -221,6 +248,7 @@ def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
},
},
)
)
def
graph
(
title
,
data
,
options
=
{}):
def
graph
(
title
,
data
,
options
=
{}):
result
=
[]
result
=
[]
append
=
result
.
append
append
=
result
.
append
...
@@ -369,7 +397,7 @@ class GenericSiteStats(object):
...
@@ -369,7 +397,7 @@ class GenericSiteStats(object):
self
.
user_agent_counter
[
match
.
group
(
'agent'
)]
+=
1
self
.
user_agent_counter
[
match
.
group
(
'agent'
)]
+=
1
def
getApdexData
(
self
):
def
getApdexData
(
self
):
return
getDataPoints
(
self
.
apdex
)
return
getDataPoints
(
self
.
apdex
,
self
.
status
)
def
asHTML
(
self
,
date_format
,
placeholder_delta
,
graph_period
,
def
asHTML
(
self
,
date_format
,
placeholder_delta
,
graph_period
,
graph_coefficient
,
encoding
,
stat_filter
=
lambda
x
:
x
,
graph_coefficient
,
encoding
,
stat_filter
=
lambda
x
:
x
,
...
@@ -1043,7 +1071,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
...
@@ -1043,7 +1071,7 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
if
apdex_data_list
:
if
apdex_data_list
:
x_min
=
min
(
x_min
,
apdex_data_list
[
0
][
0
])
x_min
=
min
(
x_min
,
apdex_data_list
[
0
][
0
])
x_max
=
max
(
x_max
,
apdex_data_list
[
-
1
][
0
])
x_max
=
max
(
x_max
,
apdex_data_list
[
-
1
][
0
])
for
hit_date
,
_
,
hit
in
apdex_data_list
:
for
hit_date
,
_
,
hit
,
_
in
apdex_data_list
:
hit_per_day
[
decimator
(
hit_date
)]
+=
hit
hit_per_day
[
decimator
(
hit_date
)]
+=
hit
if
x_min
==
LARGER_THAN_INTEGER_STR
:
if
x_min
==
LARGER_THAN_INTEGER_STR
:
x_min
=
None
x_min
=
None
...
...
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