|
@@ -23,6 +23,7 @@
|
|
|
#define TAB g_parse->getTab()
|
|
|
#define INC_TAB g_parse->incTab()
|
|
|
#define DEL_TAB g_parse->delTab()
|
|
|
+#define G_TRACE_PARAM_OVER_MAX_LEN "\"{\\\"trace_param_over_max_len\\\":true}\""
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
//
|
|
@@ -1322,7 +1323,8 @@ string Tars2Cpp::generateDispatchAsync(const OperationPtr& pPtr, const string& c
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CR))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CR, _is.size());" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -1340,6 +1342,13 @@ string Tars2Cpp::generateDispatchAsync(const OperationPtr& pPtr, const string& c
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
+
|
|
|
s << TAB << "TARS_TRACE(pSptd->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -1694,7 +1703,8 @@ string Tars2Cpp::generateServantDispatch(const OperationPtr& pPtr, const string&
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_SR))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_SR, _is.size());" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -1706,6 +1716,13 @@ string Tars2Cpp::generateServantDispatch(const OperationPtr& pPtr, const string&
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
+
|
|
|
s << TAB << "TARS_TRACE(pSptd->getTraceKey(ServantProxyThreadData::TraceContext::EST_SR), TRACE_ANNOTATION_SR, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -1859,7 +1876,8 @@ string Tars2Cpp::generateServantDispatch(const OperationPtr& pPtr, const string&
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_SS))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_SS, _sResponseBuffer.size());" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -1877,6 +1895,12 @@ string Tars2Cpp::generateServantDispatch(const OperationPtr& pPtr, const string&
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
s << TAB << "TARS_TRACE(pSptd->getTraceKey(ServantProxyThreadData::TraceContext::EST_SS), TRACE_ANNOTATION_SS, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -2028,7 +2052,8 @@ string Tars2Cpp::generateHAsync(const OperationPtr& pPtr, const string& cn) cons
|
|
|
INC_TAB;
|
|
|
s << TAB << "pSptd->newSpan();" << endl;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CS))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CS, _os.getLength());" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -2040,6 +2065,12 @@ string Tars2Cpp::generateHAsync(const OperationPtr& pPtr, const string& cn) cons
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
s << TAB << "TARS_TRACE(pSptd->getTraceKey(ServantProxyThreadData::TraceContext::EST_CS), TRACE_ANNOTATION_CS, ServerConfig::Application + \".\" + ServerConfig::ServerName, tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -2204,7 +2235,8 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
INC_TAB;
|
|
|
s << TAB << "pSptd->newSpan();" << endl;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CS))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CS, _os.getLength());" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -2216,6 +2248,12 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
s << TAB << "TARS_TRACE(pSptd->getTraceKey(ServantProxyThreadData::TraceContext::EST_CS), TRACE_ANNOTATION_CS, ServerConfig::Application + \".\" + ServerConfig::ServerName, tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -2270,7 +2308,8 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CR))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = pSptd->needTraceParam(ServantProxyThreadData::TraceContext::EST_CR, _is.size());" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -2288,6 +2327,12 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
s << TAB << "TARS_TRACE(pSptd->getTraceKey(ServantProxyThreadData::TraceContext::EST_CR), TRACE_ANNOTATION_CR, ServerConfig::Application + \".\" + ServerConfig::ServerName, tars_name(), \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -2346,6 +2391,11 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
|
|
|
+ if (_bTrace)
|
|
|
+ {
|
|
|
+ s << TAB << "size_t _rsp_len_ = 0;" << endl;
|
|
|
+ }
|
|
|
+
|
|
|
s << TAB << "if (current->getRequestVersion() == TUPVERSION )" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
@@ -2371,6 +2421,10 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "vector<char> sTupResponseBuffer;" << endl;
|
|
|
s << TAB << "tarsAttr.encode(sTupResponseBuffer);"<< endl;
|
|
|
s << TAB << "current->sendResponse(tars::TARSSERVERSUCCESS, sTupResponseBuffer);" << endl;
|
|
|
+ if (_bTrace)
|
|
|
+ {
|
|
|
+ s << TAB << "_rsp_len_ = sTupResponseBuffer.size();" << endl;
|
|
|
+ }
|
|
|
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -2378,7 +2432,7 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
if (_bJsonSupport)
|
|
|
{
|
|
|
|
|
|
- s << TAB << "else if (current->getRequestVersion() == JSONVERSION)" << endl;
|
|
|
+ s << TAB << "else if (current->getRequestVersion() == JSONVERSION)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p = new " << _namespace << "::JsonValueObj();" << endl;
|
|
@@ -2407,6 +2461,10 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
|
|
|
s << TAB << _namespace << "::TC_Json::writeValue(_p, sJsonResponseBuffer);" << endl;
|
|
|
s << TAB << "current->sendResponse(tars::TARSSERVERSUCCESS, sJsonResponseBuffer);" << endl;
|
|
|
+ if (_bTrace)
|
|
|
+ {
|
|
|
+ s << TAB << "_rsp_len_ = sJsonResponseBuffer.size();" << endl;
|
|
|
+ }
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
|
|
@@ -2433,6 +2491,10 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
|
|
|
//s << TAB << "current->sendResponse(tars::TARSSERVERSUCCESS, string(_os.getBuffer(), _os.getLength()));" << endl;
|
|
|
s << TAB << "current->sendResponse(tars::TARSSERVERSUCCESS, _os.getByteBuffer());" << endl;
|
|
|
+ if (_bTrace)
|
|
|
+ {
|
|
|
+ s << TAB << "_rsp_len_ = _os.getLength();" << endl;
|
|
|
+ }
|
|
|
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
@@ -2443,7 +2505,8 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << "string _trace_param_;" << endl;
|
|
|
- s << TAB << "if (ServantProxyThreadData::needTraceParam(ServantProxyThreadData::TraceContext::EST_SS, current->getTraceKey()))" << endl;
|
|
|
+ s << TAB << "int _trace_param_flag_ = ServantProxyThreadData::needTraceParam(ServantProxyThreadData::TraceContext::EST_SS, current->getTraceKey(), _rsp_len_);" << endl;
|
|
|
+ s << TAB << "if (ServantProxyThreadData::TraceContext::ENP_NORMAL == _trace_param_flag_)" << endl;
|
|
|
s << TAB << "{" << endl;
|
|
|
INC_TAB;
|
|
|
s << TAB << _namespace << "::JsonValueObjPtr _p_ = new " << _namespace <<"::JsonValueObj();" << endl;
|
|
@@ -2461,6 +2524,12 @@ string Tars2Cpp::generateH(const OperationPtr& pPtr, bool bVirtual, const string
|
|
|
s << TAB << "_trace_param_ = " + _namespace + "::TC_Json::writeValue(_p_);" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|
|
|
+ s << TAB << "else if(ServantProxyThreadData::TraceContext::ENP_OVERMAXLEN == _trace_param_flag_)" << endl;
|
|
|
+ s << TAB << "{" << endl;
|
|
|
+ INC_TAB;
|
|
|
+ s << TAB << "_trace_param_ = " << G_TRACE_PARAM_OVER_MAX_LEN << ";" << endl;
|
|
|
+ DEL_TAB;
|
|
|
+ s << TAB << "}" << endl;
|
|
|
s << TAB << "TARS_TRACE(current->getTraceKey(), TRACE_ANNOTATION_SS, \"\", ServerConfig::Application + \".\" + ServerConfig::ServerName, \"" << pPtr->getId() << "\", 0, _trace_param_, \"\");" << endl;
|
|
|
DEL_TAB;
|
|
|
s << TAB << "}" << endl;
|