lwtrace.proto 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /*
  2. * This file defines language for trace queries and serialization format for trace logs
  3. */
  4. syntax = "proto3";
  5. package NLWTrace;
  6. option go_package = "a.yandex-team.ru/library/cpp/lwtrace/protos";
  7. message TProbeDesc {
  8. string Name = 1; // Use either name+provider
  9. string Provider = 3;
  10. string Group = 2; // or group
  11. }
  12. enum EOperatorType {
  13. OT_EQ = 0;
  14. OT_NE = 1;
  15. OT_LT = 2;
  16. OT_LE = 3;
  17. OT_GT = 4;
  18. OT_GE = 5;
  19. }
  20. message TArgument {
  21. string Param = 1;
  22. bytes Value = 2;
  23. string Variable = 3;
  24. }
  25. message TOperator {
  26. EOperatorType Type = 1;
  27. repeated TArgument Argument = 8;
  28. }
  29. message TPredicate {
  30. repeated TOperator Operators = 1; // All operators are combined using logical AND
  31. double SampleRate = 2; // value 1.0 means trigger actions on 100% events (do not sample if value is not set)
  32. }
  33. message TLogAction {
  34. bool DoNotLogParams = 2;
  35. bool LogTimestamp = 3;
  36. uint32 MaxRecords = 4; // Do not write more than MaxRecords records to the log (count from the trace beginning, not start)
  37. }
  38. message TPrintToStderrAction {
  39. }
  40. message TKillAction {
  41. }
  42. message TSleepAction {
  43. uint64 NanoSeconds = 1;
  44. }
  45. message TCustomAction {
  46. string Name = 1;
  47. repeated string Opts = 2;
  48. }
  49. enum EStatementType {
  50. ST_MOV = 0;
  51. ST_ADD = 1;
  52. ST_SUB = 2;
  53. ST_MUL = 3;
  54. ST_DIV = 4;
  55. ST_MOD = 5;
  56. ST_ADD_EQ = 6;
  57. ST_SUB_EQ = 7;
  58. ST_INC = 8;
  59. ST_DEC = 9;
  60. }
  61. message TStatementAction {
  62. EStatementType Type = 1;
  63. repeated TArgument Argument = 2;
  64. }
  65. message TRunLogShuttleAction {
  66. bool Ignore = 1;
  67. uint64 ShuttlesCount = 2;
  68. uint64 MaxTrackLength = 3;
  69. }
  70. message TEditLogShuttleAction {
  71. bool Ignore = 1;
  72. }
  73. message TDropLogShuttleAction {
  74. }
  75. message TAction {
  76. TLogAction LogAction = 2;
  77. TPrintToStderrAction PrintToStderrAction = 3;
  78. TCustomAction CustomAction = 4;
  79. TKillAction KillAction = 6;
  80. TSleepAction SleepAction = 7;
  81. TStatementAction StatementAction = 8;
  82. TRunLogShuttleAction RunLogShuttleAction = 100;
  83. TEditLogShuttleAction EditLogShuttleAction = 101;
  84. TDropLogShuttleAction DropLogShuttleAction = 102;
  85. }
  86. message TBlock {
  87. TProbeDesc ProbeDesc = 1;
  88. TPredicate Predicate = 2;
  89. repeated TAction Action = 3;
  90. }
  91. message TQuery {
  92. // Number of events to hold for every thread in cyclic buffer
  93. // (Won't be used if LogDurationUs is set to non-zero value)
  94. uint32 PerThreadLogSize = 1;
  95. // Hold events for last Duration microseconds
  96. // (If zero, than per-thread cyclic buffer will be used to store events)
  97. uint64 LogDurationUs = 2;
  98. repeated TBlock Blocks = 3;
  99. }
  100. message TDashboard {
  101. message TCell {
  102. optional string Url = 1;
  103. optional string Title = 2;
  104. optional string Text = 3;
  105. optional uint32 RowSpan = 4;
  106. optional uint32 ColSpan = 5;
  107. }
  108. message TRow {
  109. repeated TCell Cells = 1;
  110. }
  111. optional string Name = 1;
  112. optional string Description = 2;
  113. repeated TRow Rows = 3;
  114. }
  115. //////////////////////////////////////////////////////////////////////////////////////////////
  116. // Serialization format for trace logs //
  117. //////////////////////////////////////////////////////////////////////////////////////////////
  118. enum EParamTypePb {
  119. PT_UNKNOWN = 0;
  120. PT_I64 = 1;
  121. PT_Ui64 = 2;
  122. PT_Double = 3;
  123. PT_Str = 4;
  124. PT_Symbol = 5;
  125. PT_Check = 6;
  126. }
  127. message TEventPb {
  128. string Name = 1;
  129. repeated string Groups = 2; // First group is provider
  130. repeated EParamTypePb ParamTypes = 3;
  131. repeated string ParamNames = 4;
  132. }
  133. message TLogItemPb {
  134. uint64 Thread = 1;
  135. string Name = 2;
  136. string Provider = 3;
  137. repeated bytes Params = 4;
  138. uint64 Timestamp = 5; // microseconds since epoch
  139. uint64 TimestampCycles = 6; // cycles since machine boot
  140. }
  141. message TThreadLogPb {
  142. uint64 ThreadId = 1;
  143. repeated TLogItemPb LogItems = 2;
  144. }
  145. message TLogPb {
  146. // Trace info
  147. string Name = 1;
  148. string Description = 2;
  149. uint64 EventsCount = 3;
  150. uint64 CrtTime = 4; // Log creation time (seconds since epoch)
  151. // Traced host info
  152. string Hostname = 101;
  153. // Traced process info
  154. string ProcessName = 201;
  155. bytes CommandLine = 202;
  156. uint64 ProcessStartTime = 203;
  157. uint64 Pid = 204;
  158. string VersionInfo = 205; // Svn info
  159. // Trace query and results
  160. TQuery Query = 301;
  161. repeated TEventPb Events = 302;
  162. repeated TThreadLogPb ThreadLogs = 303;
  163. }
  164. message TShuttlePb {
  165. repeated TLogPb Parts = 1;
  166. TQuery Query = 2;
  167. }
  168. message TOrbitPb {
  169. repeated TShuttlePb Shuttles = 1;
  170. }
  171. ////////////////////////////////////////////////////////////////////////////////
  172. // Trace parameter.
  173. message TTraceParam
  174. {
  175. // Value.
  176. oneof Value
  177. {
  178. int64 IntValue = 2;
  179. uint64 UintValue = 3;
  180. double DoubleValue = 4;
  181. bytes StrValue = 5;
  182. }
  183. }
  184. ////////////////////////////////////////////////////////////////////////////////
  185. // Trace Event .
  186. message TTraceEvent
  187. {
  188. // Probe name.
  189. string Name = 1;
  190. // Provider name.
  191. string Provider = 2;
  192. // Probe parameters.
  193. repeated TTraceParam Params = 3;
  194. // Event timestamp in nanosec since epoch.
  195. uint64 TimestampNanosec = 4;
  196. }
  197. ////////////////////////////////////////////////////////////////////////////////
  198. // Shuttle trace .
  199. message TShuttleTrace
  200. {
  201. // Request events.
  202. repeated TTraceEvent Events = 1;
  203. }
  204. ////////////////////////////////////////////////////////////////////////////////
  205. // Trace request.
  206. message TTraceRequest
  207. {
  208. // trace id of remote trace session
  209. bool IsTraced = 1;
  210. }
  211. ////////////////////////////////////////////////////////////////////////////////
  212. // Trace response.
  213. message TTraceResponse
  214. {
  215. // traced events
  216. TShuttleTrace Trace = 1;
  217. }