-
Notifications
You must be signed in to change notification settings - Fork 5.5k
thrift proxy: add upstream_rq_time histograms to cluster metrics #15884
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
Changes from 2 commits
684469b
cd80842
6a16b93
2ed8cb9
3f4a6d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,15 +180,16 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, | |
| Stats::Scope& scope) | ||
| : cluster_manager_(cluster_manager), stats_(generateStats(stat_prefix, scope)), | ||
| stat_name_set_(scope.symbolTable().makeSet("thrift_proxy")), | ||
| request_call_(stat_name_set_->add("request_call")), | ||
| request_oneway_(stat_name_set_->add("request_oneway")), | ||
| request_invalid_type_(stat_name_set_->add("request_invalid_type")), | ||
| response_reply_(stat_name_set_->add("response_reply")), | ||
| response_reply_success_(stat_name_set_->add("response_success")), | ||
| response_reply_error_(stat_name_set_->add("response_error")), | ||
| response_exception_(stat_name_set_->add("response_exception")), | ||
| response_invalid_type_(stat_name_set_->add("response_invalid_type")), | ||
| passthrough_supported_(false) {} | ||
| symbol_table_(scope.symbolTable()), thrift_(stat_name_set_->add("thrift")), | ||
| upstream_rq_call_(stat_name_set_->add("upstream_rq_call")), | ||
| upstream_rq_oneway_(stat_name_set_->add("upstream_rq_oneway")), | ||
| upstream_rq_invalid_type_(stat_name_set_->add("upstream_rq_invalid_type")), | ||
| upstream_resp_reply_(stat_name_set_->add("upstream_resp_reply")), | ||
| upstream_resp_reply_success_(stat_name_set_->add("upstream_resp_success")), | ||
| upstream_resp_reply_error_(stat_name_set_->add("upstream_resp_error")), | ||
| upstream_resp_exception_(stat_name_set_->add("upstream_resp_exception")), | ||
| upstream_resp_invalid_type_(stat_name_set_->add("upstream_resp_invalid_type")), | ||
| upstream_rq_time_(stat_name_set_->add("upstream_rq_time")), passthrough_supported_(false) {} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should just add the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see both ways being done in the repo
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, np then. |
||
|
|
||
| ~Router() override = default; | ||
|
|
||
|
|
@@ -198,8 +199,23 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, | |
| bool passthroughSupported() const override { return passthrough_supported_; } | ||
|
|
||
| // Stats | ||
| void incClusterScopeCounter(Stats::StatName name) { | ||
| cluster_->statsScope().counterFromStatName(name).inc(); | ||
| void incClusterScopeCounter(const Stats::StatNameVec& names) const { | ||
| const Stats::SymbolTable::StoragePtr stat_name_storage = symbol_table_.join(names); | ||
| cluster_->statsScope().counterFromStatName(Stats::StatName(stat_name_storage.get())).inc(); | ||
| } | ||
|
|
||
| void recordClusterScopeHistogram(const Stats::StatNameVec& names, Stats::Histogram::Unit unit, | ||
| uint64_t count) const { | ||
| const Stats::SymbolTable::StoragePtr stat_name_storage = symbol_table_.join(names); | ||
| cluster_->statsScope() | ||
| .histogramFromStatName(Stats::StatName(stat_name_storage.get()), unit) | ||
| .recordValue(count); | ||
| } | ||
|
|
||
| void chargeResponseTiming(const std::chrono::milliseconds response_time) const { | ||
| const uint64_t count = response_time.count(); | ||
| recordClusterScopeHistogram({thrift_, upstream_rq_time_}, Stats::Histogram::Unit::Milliseconds, | ||
| count); | ||
| } | ||
|
|
||
| // ProtocolConverter | ||
|
|
@@ -261,6 +277,9 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, | |
| bool request_complete_ : 1; | ||
| bool response_started_ : 1; | ||
| bool response_complete_ : 1; | ||
|
|
||
| bool charged_response_timing_{false}; | ||
| MonotonicTime downstream_request_complete_time_; | ||
| }; | ||
|
|
||
| void convertMessageBegin(MessageMetadataSharedPtr metadata); | ||
|
|
@@ -274,14 +293,17 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks, | |
| Upstream::ClusterManager& cluster_manager_; | ||
| RouterStats stats_; | ||
| Stats::StatNameSetPtr stat_name_set_; | ||
| const Stats::StatName request_call_; | ||
| const Stats::StatName request_oneway_; | ||
| const Stats::StatName request_invalid_type_; | ||
| const Stats::StatName response_reply_; | ||
| const Stats::StatName response_reply_success_; | ||
| const Stats::StatName response_reply_error_; | ||
| const Stats::StatName response_exception_; | ||
| const Stats::StatName response_invalid_type_; | ||
| Stats::SymbolTable& symbol_table_; | ||
| const Stats::StatName thrift_; | ||
| const Stats::StatName upstream_rq_call_; | ||
| const Stats::StatName upstream_rq_oneway_; | ||
| const Stats::StatName upstream_rq_invalid_type_; | ||
| const Stats::StatName upstream_resp_reply_; | ||
| const Stats::StatName upstream_resp_reply_success_; | ||
| const Stats::StatName upstream_resp_reply_error_; | ||
| const Stats::StatName upstream_resp_exception_; | ||
| const Stats::StatName upstream_resp_invalid_type_; | ||
| const Stats::StatName upstream_rq_time_; | ||
|
|
||
| ThriftFilters::DecoderFilterCallbacks* callbacks_{}; | ||
| RouteConstSharedPtr route_{}; | ||
|
|
||
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.
nit: derived from upstream clusters?