From 41d8050465518f9c3aab0d3a3fbee90f13c7d325 Mon Sep 17 00:00:00 2001 From: Raul Gutierrez Segales Date: Fri, 1 Feb 2019 17:36:20 -0800 Subject: [PATCH 1/4] Fix setReference() call in hystrix stats sinks Per: https://github.com/envoyproxy/envoy/blob/master/include/envoy/http/header_map.h#L148 `setReference()` needs a std::string ref that will live beyond the lifetime of a request/response, but it's currently receiving a string literal which is used to construct a temporary std::string. So instead pass a static std::string. Signed-off-by: Raul Gutierrez Segales --- source/extensions/stat_sinks/hystrix/hystrix.cc | 5 ++++- source/extensions/stat_sinks/hystrix/hystrix.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/extensions/stat_sinks/hystrix/hystrix.cc b/source/extensions/stat_sinks/hystrix/hystrix.cc index 6c05d4a66c27f..a9a302eafc6c6 100644 --- a/source/extensions/stat_sinks/hystrix/hystrix.cc +++ b/source/extensions/stat_sinks/hystrix/hystrix.cc @@ -9,6 +9,7 @@ #include "common/buffer/buffer_impl.h" #include "common/common/logger.h" +#include "common/common/macros.h" #include "common/config/well_known_names.h" #include "common/http/headers.h" @@ -275,6 +276,8 @@ HystrixSink::HystrixSink(Server::Instance& server, const uint64_t num_buckets) MAKE_ADMIN_HANDLER(handlerHystrixEventStream), false, false); } +const std::string& HystrixSink::zeroValue() const { CONSTRUCT_ON_FIRST_USE(std::string, "0"); } + Http::Code HystrixSink::handlerHystrixEventStream(absl::string_view, Http::HeaderMap& response_headers, Buffer::Instance&, @@ -290,7 +293,7 @@ Http::Code HystrixSink::handlerHystrixEventStream(absl::string_view, AccessControlAllowHeadersValue.AllowHeadersHystrix); response_headers.insertAccessControlAllowOrigin().value().setReference( Http::Headers::get().AccessControlAllowOriginValue.All); - response_headers.insertNoChunks().value().setReference("0"); + response_headers.insertNoChunks().value().setReference(zeroValue()); Http::StreamDecoderFilterCallbacks& stream_decoder_filter_callbacks = admin_stream.getDecoderFilterCallbacks(); diff --git a/source/extensions/stat_sinks/hystrix/hystrix.h b/source/extensions/stat_sinks/hystrix/hystrix.h index 54d26953abc8c..190b9c55a65d9 100644 --- a/source/extensions/stat_sinks/hystrix/hystrix.h +++ b/source/extensions/stat_sinks/hystrix/hystrix.h @@ -147,6 +147,8 @@ class HystrixSink : public Stats::Sink, public Logger::Loggable callbacks_list_; Server::Instance& server_; uint64_t current_index_; From 5dd8944181203d29c5b7fcd3fdb20eec97479e89 Mon Sep 17 00:00:00 2001 From: Raul Gutierrez Segales Date: Fri, 1 Feb 2019 18:11:40 -0800 Subject: [PATCH 2/4] Kick CI Signed-off-by: Raul Gutierrez Segales From c682d326dd9f238f17c8fbf1fb7cda4af75b21bd Mon Sep 17 00:00:00 2001 From: Raul Gutierrez Segales Date: Sat, 2 Feb 2019 19:54:56 -0800 Subject: [PATCH 3/4] Use setInteger() instead Signed-off-by: Raul Gutierrez Segales --- source/extensions/stat_sinks/hystrix/hystrix.cc | 5 +---- source/extensions/stat_sinks/hystrix/hystrix.h | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/source/extensions/stat_sinks/hystrix/hystrix.cc b/source/extensions/stat_sinks/hystrix/hystrix.cc index a9a302eafc6c6..f3a860032ba33 100644 --- a/source/extensions/stat_sinks/hystrix/hystrix.cc +++ b/source/extensions/stat_sinks/hystrix/hystrix.cc @@ -9,7 +9,6 @@ #include "common/buffer/buffer_impl.h" #include "common/common/logger.h" -#include "common/common/macros.h" #include "common/config/well_known_names.h" #include "common/http/headers.h" @@ -276,8 +275,6 @@ HystrixSink::HystrixSink(Server::Instance& server, const uint64_t num_buckets) MAKE_ADMIN_HANDLER(handlerHystrixEventStream), false, false); } -const std::string& HystrixSink::zeroValue() const { CONSTRUCT_ON_FIRST_USE(std::string, "0"); } - Http::Code HystrixSink::handlerHystrixEventStream(absl::string_view, Http::HeaderMap& response_headers, Buffer::Instance&, @@ -293,7 +290,7 @@ Http::Code HystrixSink::handlerHystrixEventStream(absl::string_view, AccessControlAllowHeadersValue.AllowHeadersHystrix); response_headers.insertAccessControlAllowOrigin().value().setReference( Http::Headers::get().AccessControlAllowOriginValue.All); - response_headers.insertNoChunks().value().setReference(zeroValue()); + response_headers.insertNoChunks().value().setInteger(0); Http::StreamDecoderFilterCallbacks& stream_decoder_filter_callbacks = admin_stream.getDecoderFilterCallbacks(); diff --git a/source/extensions/stat_sinks/hystrix/hystrix.h b/source/extensions/stat_sinks/hystrix/hystrix.h index 190b9c55a65d9..54d26953abc8c 100644 --- a/source/extensions/stat_sinks/hystrix/hystrix.h +++ b/source/extensions/stat_sinks/hystrix/hystrix.h @@ -147,8 +147,6 @@ class HystrixSink : public Stats::Sink, public Logger::Loggable callbacks_list_; Server::Instance& server_; uint64_t current_index_; From ea242007581211db8d85ae28c5f6ce639aca68bf Mon Sep 17 00:00:00 2001 From: Raul Gutierrez Segales Date: Sat, 2 Feb 2019 20:04:16 -0800 Subject: [PATCH 4/4] Kick CI Signed-off-by: Raul Gutierrez Segales