FPRGaugeManager.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #import <Foundation/Foundation.h>
  15. NS_ASSUME_NONNULL_BEGIN
  16. FOUNDATION_EXTERN NSInteger const kGaugeDataBatchSize;
  17. /** List of gauges the gauge manager controls. */
  18. typedef NS_OPTIONS(NSUInteger, FPRGauges) {
  19. FPRGaugeNone = 0,
  20. FPRGaugeCPU = (1 << 0),
  21. FPRGaugeMemory = (1 << 1),
  22. };
  23. /** This class controls different gauge collection in the system. List of the gauges this class
  24. manages are listed above. */
  25. NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
  26. @interface FPRGaugeManager : NSObject
  27. /** @brief List of gauges that are currently being actively captured. */
  28. @property(nonatomic, readonly) FPRGauges activeGauges;
  29. /**
  30. * Creates an instance of GaugeManager.
  31. *
  32. * @return Instance of GaugeManager.
  33. */
  34. + (instancetype)sharedInstance;
  35. /**
  36. * Initializer for the gauge manager. This is not available.
  37. */
  38. - (instancetype)init NS_UNAVAILABLE;
  39. /**
  40. * Starts collecting gauge metrics for the specified set of gauges. Calling this will dispatch all
  41. * the currently existing gauge data and will start collecting the new data with the new sessionId.
  42. *
  43. * @param gauges Gauges that needs to be collected.
  44. * @param sessionId SessionId for which the gauges are collected.
  45. */
  46. - (void)startCollectingGauges:(FPRGauges)gauges forSessionId:(NSString *)sessionId;
  47. /**
  48. * Stops collecting gauge metrics for the specified set of gauges. Calling this will dispatch all
  49. * the existing gauge data.
  50. *
  51. * @param gauges Gauges that needs to be stopped collecting.
  52. */
  53. - (void)stopCollectingGauges:(FPRGauges)gauges;
  54. /**
  55. * Collects all the gauges.
  56. */
  57. - (void)collectAllGauges;
  58. /**
  59. * Takes a gauge metric and tries to dispatch the gauge metric.
  60. *
  61. * @param gaugeMetric Gauge metric that needs to be dispatched.
  62. */
  63. - (void)dispatchMetric:(id)gaugeMetric;
  64. @end
  65. NS_ASSUME_NONNULL_END