From 8a852f27a67124db9bcd919fbaf41fea5078f983 Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Fri, 10 Feb 2017 10:51:22 -0800 Subject: [PATCH 1/2] Use official attribute names --- src/envoy/mixer/http_control.cc | 36 ++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/envoy/mixer/http_control.cc b/src/envoy/mixer/http_control.cc index b1b5ba816e5..88a26877496 100644 --- a/src/envoy/mixer/http_control.cc +++ b/src/envoy/mixer/http_control.cc @@ -24,31 +24,25 @@ namespace Http { namespace Mixer { namespace { -const std::string kProxyPeerID = "Istio/Proxy"; - // Define lower case string for X-Forwarded-Host. const LowerCaseString kHeaderNameXFH("x-forwarded-host", false); -const std::string kRequestHeaderPrefix = "requestHeader:"; -const std::string kRequestParamPrefix = "requestParameter:"; -const std::string kResponseHeaderPrefix = "responseHeader:"; +const std::string kRequestHeaderPrefix = "request.headers."; +const std::string kResponseHeaderPrefix = "response.headers."; // Define attribute names -const std::string kAttrNamePeerId = "peerId"; -const std::string kAttrNameURL = "url"; -const std::string kAttrNameHttpMethod = "httpMethod"; -const std::string kAttrNameRequestSize = "requestSize"; -const std::string kAttrNameResponseSize = "responseSize"; -const std::string kAttrNameLogMessage = "logMessage"; -const std::string kAttrNameResponseTime = "responseTime"; -const std::string kAttrNameOriginIp = "originIp"; -const std::string kAttrNameOriginHost = "originHost"; +const std::string kAttrNameRequestPath = "request.path"; +const std::string kAttrNameRequestSize = "request.size"; +const std::string kAttrNameResponseSize = "response.size"; +const std::string kAttrNameResponseTime = "response.time"; +const std::string kAttrNameOriginIp = "origin.ip"; +const std::string kAttrNameOriginHost = "origin.host"; const std::string kEnvNameSourceService = "SOURCE_SERVICE"; const std::string kEnvNameTargetService = "TARGET_SERVICE"; -const std::string kAttrNameSourceService = "sourceService"; -const std::string kAttrNameTargetService = "targetService"; +const std::string kAttrNameSourceService = "source.service"; +const std::string kAttrNameTargetService = "target.service"; Attributes::Value StringValue(const std::string& str) { Attributes::Value v; @@ -106,14 +100,7 @@ void FillRequestHeaderAttributes(const HeaderMap& header_map, }, attr); - // Pass in all Query parameters. - auto path = header_map.Path(); - if (path != nullptr) { - for (const auto& it : Utility::parseQueryString(path->value().c_str())) { - attr->attributes[kRequestParamPrefix + it.first] = StringValue(it.second); - } - } - + SetStringAttribute(kAttrNameRequestPath, header_map.Path()->value().c_str(), attr); SetStringAttribute(kAttrNameOriginIp, GetFirstForwardedFor(header_map), attr); SetStringAttribute(kAttrNameOriginHost, GetLastForwardedHost(header_map), attr); @@ -167,7 +154,6 @@ void HttpControl::FillCheckAttributes(const HeaderMap& header_map, SetStringAttribute(kAttrNameSourceService, source_service_, attr); SetStringAttribute(kAttrNameTargetService, target_service_, attr); - attr->attributes[kAttrNamePeerId] = StringValue(kProxyPeerID); } void HttpControl::Check(HttpRequestDataPtr request_data, HeaderMap& headers, From 78d883bb6709bc6bfb1fa97f471cd95d0dabdeb6 Mon Sep 17 00:00:00 2001 From: Wayne Zhang Date: Fri, 10 Feb 2017 11:03:29 -0800 Subject: [PATCH 2/2] fix format --- src/envoy/mixer/http_control.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/envoy/mixer/http_control.cc b/src/envoy/mixer/http_control.cc index 88a26877496..6ae266ef088 100644 --- a/src/envoy/mixer/http_control.cc +++ b/src/envoy/mixer/http_control.cc @@ -100,7 +100,8 @@ void FillRequestHeaderAttributes(const HeaderMap& header_map, }, attr); - SetStringAttribute(kAttrNameRequestPath, header_map.Path()->value().c_str(), attr); + SetStringAttribute(kAttrNameRequestPath, header_map.Path()->value().c_str(), + attr); SetStringAttribute(kAttrNameOriginIp, GetFirstForwardedFor(header_map), attr); SetStringAttribute(kAttrNameOriginHost, GetLastForwardedHost(header_map), attr);