tracing.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // Package tracing provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Tracing domain.
  3. //
  4. // Generated by the cdproto-gen command.
  5. package tracing
  6. // Code generated by cdproto-gen. DO NOT EDIT.
  7. import (
  8. "context"
  9. "github.com/chromedp/cdproto/cdp"
  10. )
  11. // EndParams stop trace events collection.
  12. type EndParams struct{}
  13. // End stop trace events collection.
  14. //
  15. // See: https://chromedevtools.github.io/devtools-protocol/tot/Tracing#method-end
  16. func End() *EndParams {
  17. return &EndParams{}
  18. }
  19. // Do executes Tracing.end against the provided context.
  20. func (p *EndParams) Do(ctx context.Context) (err error) {
  21. return cdp.Execute(ctx, CommandEnd, nil, nil)
  22. }
  23. // GetCategoriesParams gets supported tracing categories.
  24. type GetCategoriesParams struct{}
  25. // GetCategories gets supported tracing categories.
  26. //
  27. // See: https://chromedevtools.github.io/devtools-protocol/tot/Tracing#method-getCategories
  28. func GetCategories() *GetCategoriesParams {
  29. return &GetCategoriesParams{}
  30. }
  31. // GetCategoriesReturns return values.
  32. type GetCategoriesReturns struct {
  33. Categories []string `json:"categories,omitempty"` // A list of supported tracing categories.
  34. }
  35. // Do executes Tracing.getCategories against the provided context.
  36. //
  37. // returns:
  38. //
  39. // categories - A list of supported tracing categories.
  40. func (p *GetCategoriesParams) Do(ctx context.Context) (categories []string, err error) {
  41. // execute
  42. var res GetCategoriesReturns
  43. err = cdp.Execute(ctx, CommandGetCategories, nil, &res)
  44. if err != nil {
  45. return nil, err
  46. }
  47. return res.Categories, nil
  48. }
  49. // RecordClockSyncMarkerParams record a clock sync marker in the trace.
  50. type RecordClockSyncMarkerParams struct {
  51. SyncID string `json:"syncId"` // The ID of this clock sync marker
  52. }
  53. // RecordClockSyncMarker record a clock sync marker in the trace.
  54. //
  55. // See: https://chromedevtools.github.io/devtools-protocol/tot/Tracing#method-recordClockSyncMarker
  56. //
  57. // parameters:
  58. //
  59. // syncID - The ID of this clock sync marker
  60. func RecordClockSyncMarker(syncID string) *RecordClockSyncMarkerParams {
  61. return &RecordClockSyncMarkerParams{
  62. SyncID: syncID,
  63. }
  64. }
  65. // Do executes Tracing.recordClockSyncMarker against the provided context.
  66. func (p *RecordClockSyncMarkerParams) Do(ctx context.Context) (err error) {
  67. return cdp.Execute(ctx, CommandRecordClockSyncMarker, p, nil)
  68. }
  69. // RequestMemoryDumpParams request a global memory dump.
  70. type RequestMemoryDumpParams struct {
  71. Deterministic bool `json:"deterministic,omitempty"` // Enables more deterministic results by forcing garbage collection
  72. LevelOfDetail MemoryDumpLevelOfDetail `json:"levelOfDetail,omitempty"` // Specifies level of details in memory dump. Defaults to "detailed".
  73. }
  74. // RequestMemoryDump request a global memory dump.
  75. //
  76. // See: https://chromedevtools.github.io/devtools-protocol/tot/Tracing#method-requestMemoryDump
  77. //
  78. // parameters:
  79. func RequestMemoryDump() *RequestMemoryDumpParams {
  80. return &RequestMemoryDumpParams{}
  81. }
  82. // WithDeterministic enables more deterministic results by forcing garbage
  83. // collection.
  84. func (p RequestMemoryDumpParams) WithDeterministic(deterministic bool) *RequestMemoryDumpParams {
  85. p.Deterministic = deterministic
  86. return &p
  87. }
  88. // WithLevelOfDetail specifies level of details in memory dump. Defaults to
  89. // "detailed".
  90. func (p RequestMemoryDumpParams) WithLevelOfDetail(levelOfDetail MemoryDumpLevelOfDetail) *RequestMemoryDumpParams {
  91. p.LevelOfDetail = levelOfDetail
  92. return &p
  93. }
  94. // RequestMemoryDumpReturns return values.
  95. type RequestMemoryDumpReturns struct {
  96. DumpGUID string `json:"dumpGuid,omitempty"` // GUID of the resulting global memory dump.
  97. Success bool `json:"success,omitempty"` // True iff the global memory dump succeeded.
  98. }
  99. // Do executes Tracing.requestMemoryDump against the provided context.
  100. //
  101. // returns:
  102. //
  103. // dumpGUID - GUID of the resulting global memory dump.
  104. // success - True iff the global memory dump succeeded.
  105. func (p *RequestMemoryDumpParams) Do(ctx context.Context) (dumpGUID string, success bool, err error) {
  106. // execute
  107. var res RequestMemoryDumpReturns
  108. err = cdp.Execute(ctx, CommandRequestMemoryDump, p, &res)
  109. if err != nil {
  110. return "", false, err
  111. }
  112. return res.DumpGUID, res.Success, nil
  113. }
  114. // StartParams start trace events collection.
  115. type StartParams struct {
  116. BufferUsageReportingInterval float64 `json:"bufferUsageReportingInterval,omitempty"` // If set, the agent will issue bufferUsage events at this interval, specified in milliseconds
  117. TransferMode TransferMode `json:"transferMode,omitempty"` // Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ReportEvents).
  118. StreamFormat StreamFormat `json:"streamFormat,omitempty"` // Trace data format to use. This only applies when using ReturnAsStream transfer mode (defaults to json).
  119. StreamCompression StreamCompression `json:"streamCompression,omitempty"` // Compression format to use. This only applies when using ReturnAsStream transfer mode (defaults to none)
  120. TraceConfig *TraceConfig `json:"traceConfig,omitempty"`
  121. PerfettoConfig string `json:"perfettoConfig,omitempty"` // Base64-encoded serialized perfetto.protos.TraceConfig protobuf message When specified, the parameters categories, options, traceConfig are ignored.
  122. TracingBackend Backend `json:"tracingBackend,omitempty"` // Backend type (defaults to auto)
  123. }
  124. // Start start trace events collection.
  125. //
  126. // See: https://chromedevtools.github.io/devtools-protocol/tot/Tracing#method-start
  127. //
  128. // parameters:
  129. func Start() *StartParams {
  130. return &StartParams{}
  131. }
  132. // WithBufferUsageReportingInterval if set, the agent will issue bufferUsage
  133. // events at this interval, specified in milliseconds.
  134. func (p StartParams) WithBufferUsageReportingInterval(bufferUsageReportingInterval float64) *StartParams {
  135. p.BufferUsageReportingInterval = bufferUsageReportingInterval
  136. return &p
  137. }
  138. // WithTransferMode whether to report trace events as series of dataCollected
  139. // events or to save trace to a stream (defaults to ReportEvents).
  140. func (p StartParams) WithTransferMode(transferMode TransferMode) *StartParams {
  141. p.TransferMode = transferMode
  142. return &p
  143. }
  144. // WithStreamFormat trace data format to use. This only applies when using
  145. // ReturnAsStream transfer mode (defaults to json).
  146. func (p StartParams) WithStreamFormat(streamFormat StreamFormat) *StartParams {
  147. p.StreamFormat = streamFormat
  148. return &p
  149. }
  150. // WithStreamCompression compression format to use. This only applies when
  151. // using ReturnAsStream transfer mode (defaults to none).
  152. func (p StartParams) WithStreamCompression(streamCompression StreamCompression) *StartParams {
  153. p.StreamCompression = streamCompression
  154. return &p
  155. }
  156. // WithTraceConfig [no description].
  157. func (p StartParams) WithTraceConfig(traceConfig *TraceConfig) *StartParams {
  158. p.TraceConfig = traceConfig
  159. return &p
  160. }
  161. // WithPerfettoConfig base64-encoded serialized perfetto.protos.TraceConfig
  162. // protobuf message When specified, the parameters categories, options,
  163. // traceConfig are ignored.
  164. func (p StartParams) WithPerfettoConfig(perfettoConfig string) *StartParams {
  165. p.PerfettoConfig = perfettoConfig
  166. return &p
  167. }
  168. // WithTracingBackend backend type (defaults to auto).
  169. func (p StartParams) WithTracingBackend(tracingBackend Backend) *StartParams {
  170. p.TracingBackend = tracingBackend
  171. return &p
  172. }
  173. // Do executes Tracing.start against the provided context.
  174. func (p *StartParams) Do(ctx context.Context) (err error) {
  175. return cdp.Execute(ctx, CommandStart, p, nil)
  176. }
  177. // Command names.
  178. const (
  179. CommandEnd = "Tracing.end"
  180. CommandGetCategories = "Tracing.getCategories"
  181. CommandRecordClockSyncMarker = "Tracing.recordClockSyncMarker"
  182. CommandRequestMemoryDump = "Tracing.requestMemoryDump"
  183. CommandStart = "Tracing.start"
  184. )