-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[core][obsclean/04] move metric registration to constructor #55544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors metric registration by moving it from the Record
method into the constructors of metric classes. This is a good change for performance and clarity. However, I've identified a potential thread-safety issue where a mutex was removed during this refactoring, which could lead to race conditions. I've also pointed out an opportunity to reduce code duplication in the derived metric classes to improve maintainability. Please see the detailed comments for suggestions.
5210e2a
to
12139b6
Compare
ad514ea
to
e9162d1
Compare
12139b6
to
af3804d
Compare
2705ff8
to
0750a73
Compare
0750a73
to
0f037e3
Compare
0f037e3
to
a60c493
Compare
a60c493
to
b6a8c2c
Compare
bd6f10c
to
4e6d29a
Compare
Signed-off-by: Cuong Nguyen <[email protected]>
4e6d29a
to
9e868ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…ect#55544) Currently, the `Metric` class registers the metric name each time it records a new value, due to the [C++ static initialization order fiasco](https://en.cppreference.com/w/cpp/language/siof.html). The base of this PR move all static metrics to runtime initialization, allowing us to safely perform metric registration in the constructor. Note that I'm only doing this for the open-telemetry stack. The opencensus has a complex registration sequence using view+measure and I have hard time make it to work so I don't bother fixing it. Test: - CI Signed-off-by: Cuong Nguyen <[email protected]> Signed-off-by: Lehui Liu <[email protected]>
…ect#55544) Currently, the `Metric` class registers the metric name each time it records a new value, due to the [C++ static initialization order fiasco](https://en.cppreference.com/w/cpp/language/siof.html). The base of this PR move all static metrics to runtime initialization, allowing us to safely perform metric registration in the constructor. Note that I'm only doing this for the open-telemetry stack. The opencensus has a complex registration sequence using view+measure and I have hard time make it to work so I don't bother fixing it. Test: - CI Signed-off-by: Cuong Nguyen <[email protected]> Signed-off-by: Masahiro Tanaka <[email protected]>
…ect#55544) Currently, the `Metric` class registers the metric name each time it records a new value, due to the [C++ static initialization order fiasco](https://en.cppreference.com/w/cpp/language/siof.html). The base of this PR move all static metrics to runtime initialization, allowing us to safely perform metric registration in the constructor. Note that I'm only doing this for the open-telemetry stack. The opencensus has a complex registration sequence using view+measure and I have hard time make it to work so I don't bother fixing it. Test: - CI Signed-off-by: Cuong Nguyen <[email protected]> Signed-off-by: Masahiro Tanaka <[email protected]>
Currently, the
Metric
class registers the metric name each time it records a new value, due to the C++ static initialization order fiasco. The base of this PR move all static metrics to runtime initialization, allowing us to safely perform metric registration in the constructor.Note that I'm only doing this for the open-telemetry stack. The opencensus has a complex registration sequence using view+measure and I have hard time make it to work so I don't bother fixing it.
Test: