From c389ec1b61d28da447d92389158ed107b34747d0 Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Mon, 16 Sep 2019 05:22:40 +0000 Subject: [PATCH] new(userspace/falco): store context metadata for future usage Signed-off-by: Leonardo Di Donato --- userspace/falco/grpc_context.cpp | 9 ++++++++- userspace/falco/grpc_context.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/userspace/falco/grpc_context.cpp b/userspace/falco/grpc_context.cpp index 4c6d5c4d..c5257049 100644 --- a/userspace/falco/grpc_context.cpp +++ b/userspace/falco/grpc_context.cpp @@ -29,16 +29,23 @@ context::context(grpc::ServerContext* ctx): get_metadata(meta_session, session_id); get_metadata(meta_session, request_id); + bool has_meta = false; std::stringstream meta; if(!session_id.empty()) { meta << "[sid=" << session_id << "]"; + has_meta = true; } - if(!request_id.empty()) { meta << "[rid=" << request_id << "]"; + has_meta = true; } + if(has_meta) + { + meta << " "; + } + m_prefix = meta.str(); } void context::get_metadata(std::string key, std::string& val) diff --git a/userspace/falco/grpc_context.h b/userspace/falco/grpc_context.h index c8c73dbe..4781517a 100644 --- a/userspace/falco/grpc_context.h +++ b/userspace/falco/grpc_context.h @@ -18,6 +18,8 @@ limitations under the License. #pragma once +#include + #ifdef GRPC_INCLUDE_IS_GRPCPP #include #else @@ -37,6 +39,7 @@ public: private: grpc::ServerContext* m_ctx = nullptr; + std::string m_prefix; }; class stream_context : public context