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