-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: add basic ods support to Counter
Summary: Now (when compiled by buck in fbsource) the Counter type also contains an ODS counter that gets updated as the Counter is updated. Rather than using the dynamic counter in stats::define_stats macro, I directly instantiate a BoxSingletonCounter and store it in the Counter. This avoids computing the String metric name every time when incrementing. Reviewed By: quark-zju Differential Revision: D66848953 fbshipit-source-id: 71858669fb3c4e55339ed52bd2a5023aa7927e6b
- Loading branch information
1 parent
cdcd438
commit cba4249
Showing
4 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
pub(crate) type Counter = (); | ||
|
||
pub(crate) fn new_counter(_name: &'static str) -> Counter { | ||
() | ||
} | ||
|
||
pub(crate) fn increment(_counter: &Counter, _value: i64) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
pub(crate) type Counter = stats_traits::stat_types::BoxSingletonCounter; | ||
|
||
pub(crate) fn new_counter(name: &'static str) -> Counter { | ||
stats::create_singleton_counter(name.to_string()) | ||
} | ||
|
||
pub(crate) fn increment(counter: &Counter, value: i64) { | ||
if !fbinit::was_performed() { | ||
return; | ||
} | ||
|
||
counter.increment_value(fbinit::expect_init(), value); | ||
} |