perf_metric.proto 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Protos for logging firebase performance monitoring metrics collected by the
  15. // Firebase performance sdk and transmitted to the backend using clearcut.
  16. syntax = "proto2";
  17. package firebase.perf.v1;
  18. option java_multiple_files = true;
  19. option java_outer_classname = "FirebasePerfMetricProto";
  20. option java_package = "com.google.firebase.perf.v1";
  21. // Firebase Perf Reporting Message
  22. option objc_class_prefix = "FPRMSG";
  23. // Single unit of performance data collected from firebase integrated 3P apps by
  24. // the firebase performance sdk. This will be an an extension to
  25. // GWSLogEntryProto and will correspond to one record in the RecordIO logs
  26. // generated by clearcut. Every firebase performance related event logged to
  27. // clearcut/Firelog by the sdk will encapsulate one instance of this object.
  28. //
  29. // Next tag: 6
  30. message PerfMetric {
  31. // Additional metadata about an application and its state (including state of
  32. // the device at runtime) that is not provided by clearcut.
  33. optional ApplicationInfo application_info = 1;
  34. // A metric which represents the performance statistics collected within an
  35. // instrumented trace.
  36. optional TraceMetric trace_metric = 2;
  37. // A metric which represents the network latency, bandwidth and network
  38. // connection info about a network request captured by the firebase sdk.
  39. optional NetworkRequestMetric network_request_metric = 3;
  40. // A metric which represents session gauges, such as cpu, memory, battery,
  41. // within a session.
  42. optional GaugeMetric gauge_metric = 4;
  43. // A metric which represents the transport related information.
  44. // When transport_info field is empty, it means the message is from clearcut.
  45. optional TransportInfo transport_info = 5;
  46. }
  47. // Metric which represents everything collected in the span of a trace. A trace
  48. // may be further divided into subtraces.
  49. // The trace can either be a default out of the box trace which is a
  50. // part of the default instrumentation provided by the firebase performance sdk
  51. // or a custom trace instrumented by the app developer using the sdk apis.
  52. //
  53. // Next tag: 10
  54. message TraceMetric {
  55. // The name of the trace. This could either be a user defined name for the
  56. // developer instrumented custom traces or a default for traces automatically
  57. // instrumented by the Firebase Performance SDK. The max length of 64
  58. // characters will be enforced by the sdk.
  59. optional string name = 1; // required.
  60. // If true, then this is considered to be a trace automatically instrumented
  61. // by the performance sdk. Otherwise, it is considered to be a custom trace
  62. // instrumented by the developer using firebase perf sdk apis.
  63. optional bool is_auto = 2;
  64. // The timestamp in microseconds since epoch when the trace was started. This
  65. // time is recorded using the device clock.
  66. optional int64 client_start_time_us = 4; // required.
  67. // The duration of the trace in microseconds.
  68. optional int64 duration_us = 5; // required.
  69. // A map of custom or default counter names to values.
  70. map<string, int64> counters = 6;
  71. // The metrics for subtraces within the trace.
  72. // The following restrictions are currently enforced by the sdk on subtraces:
  73. // Subtraces should only have 1 level of nesting.
  74. // Subtraces should be non overlapping.
  75. // Subtraces should be continuous, i.e no gaps between consecutive subtraces.
  76. repeated TraceMetric subtraces = 7;
  77. // A map of trace-level custom attribute names to values.
  78. map<string, string> custom_attributes = 8;
  79. // Sessions across which the trace spanned. A session lasts from one
  80. // change in the app state (foreground/background) to the next. Basically
  81. // every foreground and background session gets it's own session id. A trace
  82. // may span across multiple such sessions. So we need a list to identify which
  83. // sessions it spanned across.
  84. repeated PerfSession perf_sessions = 9;
  85. }
  86. // Metric which represents the latency, bandwidth consumption and other details
  87. // about a network request captured by the firebase sdk.
  88. //
  89. // Next tag: 14
  90. message NetworkRequestMetric {
  91. // The parameterless url to which the network request was made. The sdk will
  92. // redact the unnecessary components of the URL and only log the components
  93. // which are useful. For a url of the form
  94. // scheme://host[:port]/path[?params][#fragment], the sdk should only log
  95. // scheme://host[:port]/path
  96. // Example:
  97. // Captured Url: https://wwww.google.com/maps/cities#seattle?id=123
  98. // Logged Url: https://wwww.google.com/maps/cities
  99. optional string url = 1; // required.
  100. // Supported HTTP methods for aggregating network requests. All network
  101. // requests that can not be classified into the 9 methods below should be set
  102. // to HTTP_METHOD_UNKNOWN.
  103. enum HttpMethod {
  104. HTTP_METHOD_UNKNOWN = 0;
  105. GET = 1;
  106. PUT = 2;
  107. POST = 3;
  108. DELETE = 4;
  109. HEAD = 5;
  110. PATCH = 6;
  111. OPTIONS = 7;
  112. TRACE = 8;
  113. CONNECT = 9;
  114. }
  115. // The HTTP verb for the network request. Common values include GET,
  116. // PUT, POST and DELETE
  117. optional HttpMethod http_method = 2; // required.
  118. // The size of the payload in the request.
  119. optional int64 request_payload_bytes = 3;
  120. // The size of the payload in the response.
  121. optional int64 response_payload_bytes = 4;
  122. // Info about the type of client error during network call.
  123. enum NetworkClientErrorReason {
  124. // Unspecified Network Client Error Reason.
  125. NETWORK_CLIENT_ERROR_REASON_UNKNOWN = 0;
  126. // No attempt made to classify the error.
  127. GENERIC_CLIENT_ERROR = 1;
  128. // Add the specific client error types below.
  129. }
  130. // The client error received from the networking library.
  131. // Do not record a client error if we have HTTP response code available.
  132. optional NetworkClientErrorReason network_client_error_reason = 11;
  133. // The Http response code received from the server.
  134. optional int32 http_response_code = 5; // required.
  135. // The value of the content type header in the response.
  136. optional string response_content_type = 6;
  137. // The timestamp in microseconds since epoch when the network request was
  138. // initiated. This time is recorded using the device clock.
  139. optional int64 client_start_time_us = 7; // required.
  140. // The time in microseconds since the start of the network request and the
  141. // upload of the last request byte.
  142. optional int64 time_to_request_completed_us = 8;
  143. // The time in microseconds between the start of the network request and the
  144. // receipt of the first byte of the response headers.
  145. optional int64 time_to_response_initiated_us = 9;
  146. // The time in microseconds between the start of the network request and the
  147. // receipt of the last response byte.
  148. optional int64 time_to_response_completed_us = 10; // required.
  149. // A map of network-level custom attribute names to values.
  150. map<string, string> custom_attributes = 12;
  151. // Sessions across which the network request spanned. A session lasts
  152. // from one change in the app state (foreground/background) to the next.
  153. // Basically every foreground and background session gets it's own session id.
  154. // A network request may span across multiple such sessions. So we need a list
  155. // to identify which sessions it spanned across.
  156. repeated PerfSession perf_sessions = 13;
  157. }
  158. // Metadata about a session and the amount of detail information it contains.
  159. message PerfSession {
  160. // The id of a session.
  161. optional string session_id = 1;
  162. // The level of amount of detailed information that this session captures.
  163. repeated SessionVerbosity session_verbosity = 2;
  164. }
  165. // Metric which represents gauges collected during the span of a session,
  166. // including cpu, memory, battery, etc.
  167. // The gauges will be collected by our own sdk and be purely numeric readings,
  168. // user cannot pass any information here, so cannot contain PIIs.
  169. //
  170. // Next tag: 6
  171. message GaugeMetric {
  172. // Identifier of the session in which this gauge reading takes place.
  173. // A session_id is specific to a device instance, and is used to tie gauge
  174. // metrics to other peer traces and network requests that occurs during
  175. // the session.
  176. optional string session_id = 1;
  177. // Metadata of gauge metrics whose value stay constant throughout the session.
  178. optional GaugeMetadata gauge_metadata = 3;
  179. // List of cpu gauge readings recorded in the session.
  180. repeated CpuMetricReading cpu_metric_readings = 2;
  181. // List of Android memory readings recorded, absent for iOS apps.
  182. repeated AndroidMemoryReading android_memory_readings = 4;
  183. // List of iOS memory readings recorded, absent for Android apps.
  184. repeated IosMemoryReading ios_memory_readings = 5;
  185. }
  186. // One reading of cpu gauge metric.
  187. //
  188. // Next tag: 4
  189. message CpuMetricReading {
  190. // The timestamp in microseconds since epoch when this snapshot took place.
  191. // This time is recorded using the device clock.
  192. optional int64 client_time_us = 1;
  193. // The total user cpu time since process started in microseconds.
  194. optional int64 user_time_us = 2;
  195. // The total system cpu time since process started in microseconds.
  196. optional int64 system_time_us = 3;
  197. }
  198. // One reading of iOS memory gauge metric.
  199. //
  200. // Next tag: 4
  201. message IosMemoryReading {
  202. // The timestamp in microseconds since epoch when this snapshot took place.
  203. // This time is recorded using the device clock.
  204. optional int64 client_time_us = 1;
  205. // The amount of heap memory that the app is using, in kilobytes.
  206. optional int32 used_app_heap_memory_kb = 2;
  207. // The amount of heap memory that is free for the app to use, in kilobytes.
  208. optional int32 free_app_heap_memory_kb = 3;
  209. }
  210. // One reading of Android memory gauge metric.
  211. // Note that this is cheap-to-capture memory reading, which is different from
  212. // application's summary of memory usage (expensive to capture). Summary of
  213. // memory usage will be captured at a much lower frequency in a different proto.
  214. //
  215. // Next tag: 3
  216. message AndroidMemoryReading {
  217. // The timestamp in microseconds since epoch when this snapshot took place.
  218. // This time is recorded using the device clock.
  219. optional int64 client_time_us = 1;
  220. // The amount of java heap memory that the app is using, in kilobytes.
  221. optional int32 used_app_java_heap_memory_kb = 2;
  222. }
  223. // Metadata about gauges of a session.
  224. // These are the gauge values that stay constant throughout the entire session.
  225. // Examples include maxAppJavaHeapMemory (max memory allowed for the app) and
  226. // cpuFrequency (frequency of cpu of the device that the app is running on).
  227. // As long as one GaugeMetadata is sent for a session, these metadata will be
  228. // available for all elements of the session. If multiple GaugeMetadata are sent
  229. // for the same session, they are expected to be identical.
  230. //
  231. // Next tag: 7
  232. message GaugeMetadata {
  233. // The process in which Firebase instance is initialized and collecting data.
  234. // Fireperf sdk collects information in the context of a process (instead of
  235. // the whole app). The process name helps developer identifies which process
  236. // are the gauge data coming from.
  237. optional string process_name = 1;
  238. // Clock rate of the cpu of the device, in kHz.
  239. optional int32 cpu_clock_rate_khz = 2;
  240. // The number of cpu cores that the device has.
  241. optional int32 cpu_processor_count = 6;
  242. // Size of RAM of the device, in kilobytes.
  243. optional int32 device_ram_size_kb = 3;
  244. // Maximum amount of memory the app can use before an OutOfMemoryException
  245. // is triggered, in kilobytes.
  246. // Only present for Android apps.
  247. optional int32 max_app_java_heap_memory_kb = 4;
  248. // The maximum amount of memory the app is encouraged to use to be properly
  249. // respectful of the limits of the client device.
  250. // Only present for Android apps.
  251. optional int32 max_encouraged_app_java_heap_memory_kb = 5;
  252. }
  253. // Additional metadata about an application and its state (including state of
  254. // the device at runtime) that is not provided by clearcut.
  255. //
  256. // Next tag: 8
  257. message ApplicationInfo {
  258. // Identifier for the application that has been registered with firebase.
  259. // Contains pantheon project number, platform and the hash of the (package
  260. // name or bundle id) fields in hex.
  261. // [Version]:[Project Number]:[Platform]:[Hash(package_name/bundle_id)]
  262. // The app id contains Pantheon project number which is a GAIA ID that
  263. // identifies a particular organization or a customer.
  264. optional string google_app_id = 1; // required.
  265. // The App Instance Id which is used to compute the distinct users for which
  266. // the metrics are recorded.
  267. optional string app_instance_id = 2; // required.
  268. // One of android_app_info, ios_app_info, and web_app_info is required.
  269. // Additional information specific to an android app.
  270. optional AndroidApplicationInfo android_app_info = 3;
  271. // Additional information specific to an ios app.
  272. optional IosApplicationInfo ios_app_info = 4;
  273. // Additional information specific to a web app.
  274. optional WebApplicationInfo web_app_info = 7;
  275. // State of the application process during metric collection.
  276. optional ApplicationProcessState application_process_state = 5; // required.
  277. // A map of global-level custom attribute names to values.
  278. map<string, string> custom_attributes = 6;
  279. }
  280. // Additional metadata about a web application that is not provided by
  281. // clearcut.
  282. //
  283. // Next tag: 6
  284. message WebApplicationInfo {
  285. // The sdk version of the firebase perf web sdk.
  286. optional string sdk_version = 1;
  287. // The url of the web page from which this event occurs.
  288. optional string page_url = 2;
  289. // Service worker status of the web page.
  290. optional ServiceWorkerStatus service_worker_status = 3;
  291. // Visibility state of the web page.
  292. optional VisibilityState visibility_state = 4;
  293. // Effective connection type of a web page.
  294. optional EffectiveConnectionType effective_connection_type = 5;
  295. }
  296. // Additional metadata about an android application that is not provided by
  297. // clearcut.
  298. //
  299. // Next tag: 4
  300. message AndroidApplicationInfo {
  301. // The package name of the android application.
  302. // e.g com.google.android.apps.maps
  303. optional string package_name = 1; // required.
  304. // The sdk version of the firebase perf android sdk.
  305. optional string sdk_version = 2; // required.
  306. // The versionName of the android application as shown on the play store.
  307. // Clearcut logs the versionCode in the GWSLogEntryProto field:
  308. // PlayExtension.client_info.android_client_info.application_build
  309. // This field is necessary till clearcut supports logging version_name by
  310. // default: b/32584283
  311. optional string version_name = 3;
  312. }
  313. // To describe the network connectivity of the client.
  314. // Copied from android/play/playlog/proto/clientanalytics.proto
  315. // Next tag: 3
  316. message NetworkConnectionInfo {
  317. enum NetworkType {
  318. NONE = -1;
  319. MOBILE = 0;
  320. WIFI = 1;
  321. MOBILE_MMS = 2;
  322. MOBILE_SUPL = 3;
  323. MOBILE_DUN = 4;
  324. MOBILE_HIPRI = 5;
  325. WIMAX = 6;
  326. BLUETOOTH = 7;
  327. DUMMY = 8;
  328. ETHERNET = 9;
  329. MOBILE_FOTA = 10;
  330. MOBILE_IMS = 11;
  331. MOBILE_CBS = 12;
  332. WIFI_P2P = 13;
  333. MOBILE_IA = 14;
  334. MOBILE_EMERGENCY = 15;
  335. PROXY = 16;
  336. VPN = 17;
  337. }
  338. enum MobileSubtype {
  339. UNKNOWN_MOBILE_SUBTYPE = 0;
  340. GPRS = 1;
  341. EDGE = 2;
  342. UMTS = 3;
  343. CDMA = 4;
  344. EVDO_0 = 5;
  345. EVDO_A = 6;
  346. RTT = 7;
  347. HSDPA = 8;
  348. HSUPA = 9;
  349. HSPA = 10;
  350. IDEN = 11;
  351. EVDO_B = 12;
  352. LTE = 13;
  353. EHRPD = 14;
  354. HSPAP = 15;
  355. GSM = 16;
  356. TD_SCDMA = 17;
  357. IWLAN = 18;
  358. LTE_CA = 19;
  359. // COMBINED has value -1 in NetworkIdentity.java, but is given the value
  360. // 100 here to save (disk) space. The value -1 takes up the full 10 bytes in
  361. // a varint for enums, but the value 100 only takes up 1 byte.
  362. COMBINED = 100;
  363. }
  364. // The current network connectivity type when the event was logged in the
  365. // client
  366. optional NetworkType network_type = 1 [default = NONE];
  367. // The current mobile connectivity subtype when the event was logged in the
  368. // client
  369. optional MobileSubtype mobile_subtype = 2 [default = UNKNOWN_MOBILE_SUBTYPE];
  370. }
  371. // Additional metadata about an ios application that is not provided by
  372. // clearcut.
  373. //
  374. // Next tag: 6
  375. message IosApplicationInfo {
  376. reserved 1;
  377. // The version of the firebase perf ios sdk.
  378. optional string sdk_version = 2; // required.
  379. // The CFBundleShortVersionString of the ios application bundle as shown on
  380. // the ios app store.
  381. // Clearcut logs the CFBundleVersion in the GWSLogEntryProto field:
  382. // PlayExtension.client_info.ios_client_info.application_build
  383. optional string bundle_short_version = 3; // required.
  384. // The mobile country code / mobile network code (MCC/MNC) of the device's
  385. // SIM/home network (not the device's active network)
  386. // e.g., 310004 for Verizon USA.
  387. // This field should eventually move to PlaylogIosClientInfo. b/35763500
  388. optional string mcc_mnc = 4;
  389. // The network connectivity of the client when the fetch was done.
  390. optional NetworkConnectionInfo network_connection_info = 5; // required.
  391. }
  392. // Transport related metadata info.
  393. // Next tag: 2
  394. message TransportInfo {
  395. // Dispatch destination for the event.
  396. enum DispatchDestination {
  397. SOURCE_UNKNOWN = 0; // Reserved
  398. FL_LEGACY_V1 = 1; // Firelog legacy endpoint
  399. }
  400. // Destination to which the events are sent.
  401. optional DispatchDestination dispatch_destination = 1;
  402. }
  403. // Metadata about the state of application process during metrics collection.
  404. //
  405. enum ApplicationProcessState {
  406. // Unspecified application process state.
  407. APPLICATION_PROCESS_STATE_UNKNOWN = 0;
  408. // Application process was in foreground
  409. FOREGROUND = 1;
  410. // Application process was in background
  411. BACKGROUND = 2;
  412. // Application process was both in foreground and background for the duration
  413. // of metrics collection.
  414. FOREGROUND_BACKGROUND = 3;
  415. }
  416. // The level of detailed information that is captured in a Perf Session, known
  417. // as a session's verbosity. For different session we collect different levels
  418. // of detailed information (or none at all) to avoid penalizing the same device
  419. // constantly.
  420. enum SessionVerbosity {
  421. // Session doesn't have detailed information.
  422. SESSION_VERBOSITY_NONE = 0;
  423. // Session has gauges and system events information.
  424. GAUGES_AND_SYSTEM_EVENTS = 1;
  425. }
  426. // Visibility state for a web page.
  427. enum VisibilityState {
  428. // Unspecified visibility state.
  429. VISIBILITY_STATE_UNKNOWN = 0;
  430. // The page is at least partially visible. In practice this means the page
  431. // is in the foreground tab of a non-minimized window.
  432. VISIBLE = 1;
  433. // The page's content is not visible to the user.
  434. HIDDEN = 2;
  435. // The page's content is being prerendered and is not visible to the user.
  436. PRERENDER = 3;
  437. // The page is in the process of being unloaded from memory.
  438. UNLOADED = 4;
  439. }
  440. // Service worker status for a web page.
  441. enum ServiceWorkerStatus {
  442. // Unspecified service worker status.
  443. SERVICE_WORKER_STATUS_UNKNOWN = 0;
  444. // Service worker not supported by the browser.
  445. UNSUPPORTED = 1;
  446. // Service worker controlled page.
  447. CONTROLLED = 2;
  448. // Page not controlled by a service worker.
  449. UNCONTROLLED = 3;
  450. }
  451. // Effective connection type for a web application, defined from
  452. // https://wicg.github.io/netinfo/#effective-connection-types
  453. enum EffectiveConnectionType {
  454. EFFECTIVE_CONNECTION_TYPE_UNKNOWN = 0;
  455. EFFECTIVE_CONNECTION_TYPE_SLOW_2G = 1; // Maximum downlink speed 50kbs
  456. EFFECTIVE_CONNECTION_TYPE_2G = 2; // Maximum downlink speed 70kbs
  457. EFFECTIVE_CONNECTION_TYPE_3G = 3; // Maximum downlink speed 700kbs
  458. EFFECTIVE_CONNECTION_TYPE_4G = 4; // Maximum downlink speed Infinity
  459. }