FPRGaugeManager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. @interface FPRGaugeManager : NSObject
  26. /** @brief List of gauges that are currently being actively captured. */
  27. @property(nonatomic, readonly) FPRGauges activeGauges;
  28. /**
  29. * Creates an instance of GaugeManager.
  30. *
  31. * @return Instance of GaugeManager.
  32. */
  33. + (instancetype)sharedInstance;
  34. /**
  35. * Initializer for the gauge manager. This is not available.
  36. */
  37. - (instancetype)init NS_UNAVAILABLE;
  38. /**
  39. * Starts collecting gauge metrics for the specified set of gauges. Calling this will dispatch all
  40. * the currently existing gauge data and will start collecting the new data with the new sessionId.
  41. *
  42. * @param gauges Gauges that needs to be collected.
  43. * @param sessionId SessionId for which the gauges are collected.
  44. */
  45. - (void)startCollectingGauges:(FPRGauges)gauges forSessionId:(NSString *)sessionId;
  46. /**
  47. * Stops collecting gauge metrics for the specified set of gauges. Calling this will dispatch all
  48. * the existing gauge data.
  49. *
  50. * @param gauges Gauges that needs to be stopped collecting.
  51. */
  52. - (void)stopCollectingGauges:(FPRGauges)gauges;
  53. /**
  54. * Collects all the gauges.
  55. */
  56. - (void)collectAllGauges;
  57. /**
  58. * Takes a gauge metric and tries to dispatch the gauge metric.
  59. *
  60. * @param gaugeMetric Gauge metric that needs to be dispatched.
  61. */
  62. - (void)dispatchMetric:(id)gaugeMetric;
  63. @end
  64. NS_ASSUME_NONNULL_END