md_doc_binary-logging.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.17"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>GRPC PHP: Binary Logging</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectalign" style="padding-left: 0.5em;">
  24. <div id="projectname">GRPC PHP
  25. &#160;<span id="projectnumber">1.36.1</span>
  26. </div>
  27. </td>
  28. </tr>
  29. </tbody>
  30. </table>
  31. </div>
  32. <!-- end header part -->
  33. <!-- Generated by Doxygen 1.8.17 -->
  34. <script type="text/javascript">
  35. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  36. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  37. /* @license-end */
  38. </script>
  39. <script type="text/javascript" src="menudata.js"></script>
  40. <script type="text/javascript" src="menu.js"></script>
  41. <script type="text/javascript">
  42. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  43. $(function() {
  44. initMenu('',true,false,'search.php','Search');
  45. $(document).ready(function() { init_search(); });
  46. });
  47. /* @license-end */</script>
  48. <div id="main-nav"></div>
  49. <!-- window showing the filter options -->
  50. <div id="MSearchSelectWindow"
  51. onmouseover="return searchBox.OnSearchSelectShow()"
  52. onmouseout="return searchBox.OnSearchSelectHide()"
  53. onkeydown="return searchBox.OnSearchSelectKey(event)">
  54. </div>
  55. <!-- iframe showing the search results (closed by default) -->
  56. <div id="MSearchResultsWindow">
  57. <iframe src="javascript:void(0)" frameborder="0"
  58. name="MSearchResults" id="MSearchResults">
  59. </iframe>
  60. </div>
  61. </div><!-- top -->
  62. <div class="PageDoc"><div class="header">
  63. <div class="headertitle">
  64. <div class="title">Binary Logging </div> </div>
  65. </div><!--header-->
  66. <div class="contents">
  67. <div class="textblock"><h1><a class="anchor" id="autotoc_md30"></a>
  68. Format</h1>
  69. <p>The log format is described in <a href="/src/proto/grpc/binary_log/v1alpha/log.proto">this proto file</a>. It is intended that multiple parts of the call will be logged in separate files, and then correlated by analysis tools using the rpc_id.</p>
  70. <h1><a class="anchor" id="autotoc_md31"></a>
  71. API</h1>
  72. <p>The binary logger will be a separate library from gRPC, in each language that we support. The user will need to explicitly call into the library to generate logs. The library will provide the ability to log sending or receiving, as relevant, the following on both the client and the server:</p>
  73. <ul>
  74. <li>Initial metadata</li>
  75. <li>Messages</li>
  76. <li>Status with trailing metadata from the server</li>
  77. <li>Additional key/value pairs that are associated with a call but not sent over the wire</li>
  78. </ul>
  79. <p>The following is an example of what such an API could look like in C++:</p>
  80. <div class="fragment"><div class="line"> {c++}</div>
  81. <div class="line">// The context provides the method_name, deadline, peer, and metadata contents.</div>
  82. <div class="line">// direction = CLIENT_SEND</div>
  83. <div class="line">LogRequestHeaders(ClientContext context);</div>
  84. <div class="line">// direction = SERVER_RECV</div>
  85. <div class="line">LogRequestHeaders(ServerContext context);</div>
  86. <div class="line"> </div>
  87. <div class="line">// The context provides the metadata contents</div>
  88. <div class="line">// direction = CLIENT_RECV</div>
  89. <div class="line">LogResponseHeaders(ClientContext context);</div>
  90. <div class="line">// direction = SERVER_SEND</div>
  91. <div class="line">LogResponseHeaders(ServerContext context);</div>
  92. <div class="line"> </div>
  93. <div class="line">// The context provides the metadata contents</div>
  94. <div class="line">// direction = CLIENT_RECV</div>
  95. <div class="line">LogStatus(ClientContext context, grpc_status_code code, string details);</div>
  96. <div class="line">// direction = SERVER_SEND</div>
  97. <div class="line">LogStatus(ServerContext context, grpc_status_code code, string details);</div>
  98. <div class="line"> </div>
  99. <div class="line">// The context provides the user data contents</div>
  100. <div class="line">// direction = CLIENT_SEND</div>
  101. <div class="line">LogUserData(ClientContext context);</div>
  102. <div class="line">// direction = SERVER_SEND</div>
  103. <div class="line">LogUserData(ServerContext context);</div>
  104. <div class="line"> </div>
  105. <div class="line">// direction = CLIENT_SEND</div>
  106. <div class="line">LogRequestMessage(ClientContext context, uint32_t length, T message);</div>
  107. <div class="line">// direction = SERVER_RECV</div>
  108. <div class="line">LogRequestMessage(ServerContext context, uint32_t length, T message);</div>
  109. <div class="line">// direction = CLIENT_RECV</div>
  110. <div class="line">LogResponseMessage(ClientContext context, uint32_t length, T message);</div>
  111. <div class="line">// direction = SERVER_SEND</div>
  112. <div class="line">LogResponseMessage(ServerContext context, uint32_t length, T message);</div>
  113. </div><!-- fragment --><p>In all of those cases, the <code>rpc_id</code> is provided by the context, and each combination of method and context argument type implies a single direction, as noted in the comments.</p>
  114. <p>For the message log functions, the <code>length</code> argument indicates the length of the complete message, and the <code>message</code> argument may be only part of the complete message, stripped of sensitive material and/or shortened for efficiency.</p>
  115. <h1><a class="anchor" id="autotoc_md32"></a>
  116. Language differences</h1>
  117. <p>In other languages, more or less data will need to be passed explicitly as separate arguments. In some languages, for example, the metadata will be separate from the context-like object and will need to be passed as a separate argument. </p>
  118. </div></div><!-- contents -->
  119. </div><!-- PageDoc -->
  120. <!-- start footer part -->
  121. <hr class="footer"/><address class="footer"><small>
  122. Generated on Wed Mar 3 2021 19:20:17 for GRPC PHP by &#160;<a href="http://www.doxygen.org/index.html">
  123. <img class="footer" src="doxygen.png" alt="doxygen"/>
  124. </a> 1.8.17
  125. </small></address>
  126. </body>
  127. </html>