diff --git a/userspace/falco/grpc_context.cpp b/userspace/falco/grpc_context.cpp index f8559755..4c6d5c4d 100644 --- a/userspace/falco/grpc_context.cpp +++ b/userspace/falco/grpc_context.cpp @@ -16,12 +16,29 @@ See the License for the specific language governing permissions and limitations under the License. */ +#include + #include "grpc_context.h" context::context(grpc::ServerContext* ctx): m_ctx(ctx) { - // todo: set thread-specific prefix "[session id][request id]" + std::string session_id; + std::string request_id; + + get_metadata(meta_session, session_id); + get_metadata(meta_session, request_id); + + std::stringstream meta; + if(!session_id.empty()) + { + meta << "[sid=" << session_id << "]"; + } + + if(!request_id.empty()) + { + meta << "[rid=" << request_id << "]"; + } } 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 07021792..c8c73dbe 100644 --- a/userspace/falco/grpc_context.h +++ b/userspace/falco/grpc_context.h @@ -24,6 +24,9 @@ limitations under the License. #include #endif +const std::string meta_session = "session_id"; +const std::string meta_request = "request_id"; + class context { public: