FIRTrace+Internal.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 "FirebasePerformance/Sources/Timer/FPRCounterList.h"
  15. #import "FirebasePerformance/Sources/AppActivity/FPRSessionDetails.h"
  16. #import "FirebasePerformance/Sources/FIRPerformance+Internal.h"
  17. /**
  18. * Extension that is added on top of the class FIRTrace to make certain methods used internally
  19. * within the SDK, but not public facing. A category could be ideal, but Firebase recommends not
  20. * using categories as that mandates including -ObjC flag for build which is an extra step for the
  21. * developer.
  22. */
  23. @interface FIRTrace () <FIRPerformanceAttributable>
  24. /** @brief List of currently active counters. */
  25. @property(atomic, readonly, nonnull) NSDictionary<NSString *, NSNumber *> *counters;
  26. /** @brief The number of active counters on the given trace. */
  27. @property(atomic, readonly) NSUInteger numberOfCounters;
  28. /** Denotes if the trace is internal. */
  29. @property(nonatomic, getter=isInternal) BOOL internal;
  30. /** @brief List of sessions the trace is associated with. */
  31. @property(nonnull, atomic, readonly) NSArray<FPRSessionDetails *> *sessions;
  32. /**
  33. * Creates an instance of FIRTrace.
  34. *
  35. * @param name The name of the Trace. Name cannot be an empty string.
  36. *
  37. * @return An instance of FIRTrace.
  38. */
  39. - (nullable instancetype)initWithName:(nonnull NSString *)name;
  40. /**
  41. * Creates an instance of FIRTrace.
  42. *
  43. * @param name Name of the Trace. Name cannot be an empty string.
  44. *
  45. * @return An instance of FIRTrace.
  46. */
  47. - (nullable instancetype)initTraceWithName:(nonnull NSString *)name NS_DESIGNATED_INITIALIZER;
  48. /**
  49. * Creates an instance of internal FIRTrace. Internal FIRTrace objects do not have any validation on
  50. * the name provided except that it cannot be empty.
  51. *
  52. * @param name Name of the Trace. Name cannot be an empty string.
  53. *
  54. * @return An instance of FIRTrace.
  55. */
  56. - (nullable instancetype)initInternalTraceWithName:(nonnull NSString *)name;
  57. /**
  58. * Starts the trace with a specified start time.
  59. *
  60. * @param startTime Start time of the trace. If the startTime is nil, current time will be set.
  61. */
  62. - (void)startWithStartTime:(nullable NSDate *)startTime;
  63. /**
  64. * Creates a stage inside the trace with a defined start time. This stops the already existing
  65. * active stage if any and starts the new stage with the name provided. If the startTime is nil, the
  66. * start time of the stage is set to the current date.
  67. * @param stageName Name of the stages.
  68. * @param startTime Start time of the stage.
  69. */
  70. - (void)startStageNamed:(nonnull NSString *)stageName startTime:(nullable NSDate *)startTime;
  71. /** Cancels the trace without sending an event to Google Data Transport. */
  72. - (void)cancel;
  73. /**
  74. * Deletes a metric with the given name. If the metric doesnt exist, this has no effect.
  75. *
  76. * @param metricName The name of the metric to delete.
  77. */
  78. - (void)deleteMetric:(nonnull NSString *)metricName;
  79. @end