-
Notifications
You must be signed in to change notification settings - Fork 5.3k
filter: add grpc upstream stats #10748
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 all commits
7e36097
084495f
e45b7dc
b2e7758
3aeef8a
b76747a
7c3bb66
a3ac442
c11814b
f7c833d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,8 @@ class GrpcServiceMethodToRequestNamesMap { | |
| struct Config { | ||
| Config(const envoy::extensions::filters::http::grpc_stats::v3::FilterConfig& proto_config, | ||
| Server::Configuration::FactoryContext& context) | ||
| : context_(context.grpcContext()), emit_filter_state_(proto_config.emit_filter_state()) { | ||
| : context_(context.grpcContext()), emit_filter_state_(proto_config.emit_filter_state()), | ||
| enable_upstream_stats_(proto_config.enable_upstream_stats()) { | ||
|
|
||
| switch (proto_config.per_method_stat_specifier_case()) { | ||
| case envoy::extensions::filters::http::grpc_stats::v3::FilterConfig:: | ||
|
|
@@ -134,7 +135,8 @@ struct Config { | |
| } | ||
| } | ||
| Grpc::Context& context_; | ||
| bool emit_filter_state_; | ||
| const bool emit_filter_state_; | ||
| const bool enable_upstream_stats_; | ||
| bool stats_for_all_methods_{false}; | ||
| absl::optional<GrpcServiceMethodToRequestNamesMap> allowlist_; | ||
| }; | ||
|
|
@@ -226,6 +228,16 @@ class GrpcStatsFilter : public Http::PassThroughFilter { | |
| if (doStatTracking()) { | ||
| config_->context_.chargeStat(*cluster_, Grpc::Context::Protocol::Grpc, request_names_, | ||
| trailers.GrpcStatus()); | ||
|
|
||
| if (config_->enable_upstream_stats_ && | ||
| decoder_callbacks_->streamInfo().lastUpstreamTxByteSent().has_value() && | ||
| decoder_callbacks_->streamInfo().lastUpstreamRxByteReceived().has_value()) { | ||
| std::chrono::milliseconds chrono_duration = | ||
| std::chrono::duration_cast<std::chrono::milliseconds>( | ||
| decoder_callbacks_->streamInfo().lastUpstreamRxByteReceived().value() - | ||
| decoder_callbacks_->streamInfo().lastUpstreamTxByteSent().value()); | ||
| config_->context_.chargeUpstreamStat(*cluster_, request_names_, chrono_duration); | ||
| } | ||
|
Comment on lines
+232
to
+240
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. @ggreenway @Sh4d1 post review drive by: this would not include "trailers only" responses (headers only responses with an error). I think this is probably not what we want and we should include error responses also? Can we fix/clarify this in a follow up? Thank you.
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. @mattklein123 good catch! I think adding the same logic in encodeHeaders if
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. Or move the whole logic there 🤔 |
||
| } | ||
| return Http::FilterTrailersStatus::Continue; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.