Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
e2c9d6a7
Commit
e2c9d6a7
authored
Jun 10, 2019
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bvar::Status on integrals supports historical series
parent
71af31e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
11 deletions
+59
-11
passive_status.h
src/bvar/passive_status.h
+2
-3
status.h
src/bvar/status.h
+55
-5
window.h
src/bvar/window.h
+2
-3
No files found.
src/bvar/passive_status.h
View file @
e2c9d6a7
...
...
@@ -149,7 +149,7 @@ public:
detail
::
AddTo
<
Tp
>
op
()
const
{
return
detail
::
AddTo
<
Tp
>
();
}
detail
::
MinusFrom
<
Tp
>
inv_op
()
const
{
return
detail
::
MinusFrom
<
Tp
>
();
}
int
describe_series
(
std
::
ostream
&
os
,
const
SeriesOptions
&
options
)
const
{
int
describe_series
(
std
::
ostream
&
os
,
const
SeriesOptions
&
options
)
const
override
{
if
(
_series_sampler
==
NULL
)
{
return
1
;
}
...
...
@@ -165,10 +165,9 @@ public:
}
protected
:
// @Variable
int
expose_impl
(
const
butil
::
StringPiece
&
prefix
,
const
butil
::
StringPiece
&
name
,
DisplayFilter
display_filter
)
{
DisplayFilter
display_filter
)
override
{
const
int
rc
=
Variable
::
expose_impl
(
prefix
,
name
,
display_filter
);
if
(
ADDITIVE
&&
rc
==
0
&&
...
...
src/bvar/status.h
View file @
e2c9d6a7
...
...
@@ -86,16 +86,41 @@ template <typename T>
class
Status
<
T
,
typename
butil
::
enable_if
<
detail
::
is_atomical
<
T
>::
value
>::
type
>
:
public
Variable
{
public
:
Status
()
{}
Status
(
const
T
&
value
)
:
_value
(
value
)
{
}
Status
(
const
butil
::
StringPiece
&
name
,
const
T
&
value
)
:
_value
(
value
)
{
struct
PlaceHolderOp
{
void
operator
()(
T
&
,
const
T
&
)
const
{}
};
class
SeriesSampler
:
public
detail
::
Sampler
{
public
:
typedef
typename
butil
::
conditional
<
true
,
detail
::
AddTo
<
T
>
,
PlaceHolderOp
>::
type
Op
;
explicit
SeriesSampler
(
Status
*
owner
)
:
_owner
(
owner
),
_series
(
Op
())
{}
void
take_sample
()
{
_series
.
append
(
_owner
->
get_value
());
}
void
describe
(
std
::
ostream
&
os
)
{
_series
.
describe
(
os
,
NULL
);
}
private
:
Status
*
_owner
;
detail
::
Series
<
T
,
Op
>
_series
;
};
public
:
Status
()
:
_series_sampler
(
NULL
)
{}
Status
(
const
T
&
value
)
:
_value
(
value
),
_series_sampler
(
NULL
)
{
}
Status
(
const
butil
::
StringPiece
&
name
,
const
T
&
value
)
:
_value
(
value
),
_series_sampler
(
NULL
)
{
this
->
expose
(
name
);
}
Status
(
const
butil
::
StringPiece
&
prefix
,
const
butil
::
StringPiece
&
name
,
const
T
&
value
)
:
_value
(
value
)
{
const
butil
::
StringPiece
&
name
,
const
T
&
value
)
:
_value
(
value
),
_series_sampler
(
NULL
)
{
this
->
expose_as
(
prefix
,
name
);
}
~
Status
()
{
hide
();
}
~
Status
()
{
hide
();
if
(
_series_sampler
)
{
_series_sampler
->
destroy
();
_series_sampler
=
NULL
;
}
}
// Implement Variable::describe() and Variable::get_value().
void
describe
(
std
::
ostream
&
os
,
bool
/*quote_string*/
)
const
{
...
...
@@ -116,8 +141,33 @@ public:
_value
.
store
(
value
,
butil
::
memory_order_relaxed
);
}
int
describe_series
(
std
::
ostream
&
os
,
const
SeriesOptions
&
options
)
const
override
{
if
(
_series_sampler
==
NULL
)
{
return
1
;
}
if
(
!
options
.
test_only
)
{
_series_sampler
->
describe
(
os
);
}
return
0
;
}
protected
:
int
expose_impl
(
const
butil
::
StringPiece
&
prefix
,
const
butil
::
StringPiece
&
name
,
DisplayFilter
display_filter
)
override
{
const
int
rc
=
Variable
::
expose_impl
(
prefix
,
name
,
display_filter
);
if
(
rc
==
0
&&
_series_sampler
==
NULL
&&
FLAGS_save_series
)
{
_series_sampler
=
new
SeriesSampler
(
this
);
_series_sampler
->
schedule
();
}
return
rc
;
}
private
:
butil
::
atomic
<
T
>
_value
;
SeriesSampler
*
_series_sampler
;
};
// Specialize for std::string, adding a printf-style set_value().
...
...
src/bvar/window.h
View file @
e2c9d6a7
...
...
@@ -123,7 +123,7 @@ public:
time_t
window_size
()
const
{
return
_window_size
;
}
int
describe_series
(
std
::
ostream
&
os
,
const
SeriesOptions
&
options
)
const
{
int
describe_series
(
std
::
ostream
&
os
,
const
SeriesOptions
&
options
)
const
override
{
if
(
_series_sampler
==
NULL
)
{
return
1
;
}
...
...
@@ -140,10 +140,9 @@ public:
}
protected
:
// @Variable
int
expose_impl
(
const
butil
::
StringPiece
&
prefix
,
const
butil
::
StringPiece
&
name
,
DisplayFilter
display_filter
)
{
DisplayFilter
display_filter
)
override
{
const
int
rc
=
Variable
::
expose_impl
(
prefix
,
name
,
display_filter
);
if
(
rc
==
0
&&
_series_sampler
==
NULL
&&
...
...
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