-
Notifications
You must be signed in to change notification settings - Fork 661
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
Get rid of typeid in statistics-related code #3227
Conversation
d7e4b08
to
568da88
Compare
src/worker.cc
Outdated
} | ||
midgard::Finally<std::function<void()>> service_worker_t::measure_scope_time(Api& api) const { | ||
#ifdef ENABLE_STATSD_CLIENT |
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.
i would suggest a different fix here.. while i dont disagree that disabling the statsd client is a useful thing to have. the main thing you are trying to accomplish here is to remove the need of using typeid
. indeed this function below actually doesnt make any calls to statsd at all, yet it is disabled if your new flag for statsd is set to disable it. in fact this function adds statistics to the protobuf which we later, optionally emit through statsd. i think these stats being in protobuf is still useful regardless of sending to statsd. thought i cant blame you for thinking of them as tightly coupled.
also, and again i dont blame you for not knowing this, statsd is disabled so long as you dont configure it properly. if your statsd host is either a bogus one or a blank string (the default) the client is disabled. we still make the client, and we still call the clients functions but they all return immediately and are basically a no-op.
anyway i propose a different approach than this one. i propose you simply refactor the workers to know their own names.
basically add a pure virtual method to std::string service_worker_t::name() const = 0
this will force you to implement that m ethod in all the service workers and then you can call that in the fucntions below and not have to use typeid
at all. i think this will be simpler and not require the ifdef
swiss cheese
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.
i think we should take a different approach: https://github.com/valhalla/valhalla/pull/3227/files#r675002791
568da88
to
9cfff20
Compare
Hi @kevinkreiser |
@SiarheiFedartsou i dont know how its possible but it seems like master failed because of the tests and it seems your build did not. i wonder if the build shortcuts are screwed up somehow and it didnt actually build your code? |
cc @mandeepsandhu it looks like some trick happened here that made CI think @SiarheiFedartsou didnt change anything that needed building |
pushed a hot fix to master |
@kevinkreiser indeed. The |
@mandeepsandhu yeah frankly i wish we could disable force pushing, since we always squash merge there is no point to cleaning up the history unless its really important to make well-organized commits for the sake of review (which is pretty rare imho) that said, your suggestion of making the check more conservative makes good sense to me! |
yeah, agreed. I opened #3244 for fixing this issue in the skip ci script. |
Issue
typeid requires RTTI, which is not acceptable for some projects using Valhalla. So this PR refactors it in order to not use RTTI.
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?