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 <Foundation/Foundation.h>
|
|
|
16 |
|
|
|
17 |
#import "FIRPerformanceAttributable.h"
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* FIRTrace objects contain information about a "Trace", which is a sequence of steps. Traces can be
|
|
|
21 |
* used to measure the time taken for a sequence of steps.
|
|
|
22 |
* Traces also include "Counters". Counters are used to track information which is cumulative in
|
|
|
23 |
* nature (e.g., Bytes downloaded). Counters are scoped to an FIRTrace object.
|
|
|
24 |
*/
|
|
|
25 |
NS_EXTENSION_UNAVAILABLE("Firebase Performance is not supported for extensions.")
|
|
|
26 |
NS_SWIFT_NAME(Trace)
|
|
|
27 |
@interface FIRTrace : NSObject <FIRPerformanceAttributable>
|
|
|
28 |
|
|
|
29 |
/** @brief Name of the trace. */
|
|
|
30 |
@property(nonatomic, copy, readonly, nonnull) NSString *name;
|
|
|
31 |
|
|
|
32 |
/** @brief Not a valid initializer. */
|
|
|
33 |
- (nonnull instancetype)init NS_UNAVAILABLE;
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* Starts the trace.
|
|
|
37 |
*/
|
|
|
38 |
- (void)start;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Stops the trace if the trace is active.
|
|
|
42 |
*/
|
|
|
43 |
- (void)stop;
|
|
|
44 |
|
|
|
45 |
#pragma mark - Metrics API
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* Atomically increments the metric for the provided metric name with the provided value. If it is a
|
|
|
49 |
* new metric name, the metric value will be initialized to the value. Does nothing if the trace
|
|
|
50 |
* has not been started or has already been stopped.
|
|
|
51 |
*
|
|
|
52 |
* @param metricName The name of the metric to increment.
|
|
|
53 |
* @param incrementValue The value to increment the metric by.
|
|
|
54 |
*/
|
|
|
55 |
- (void)incrementMetric:(nonnull NSString *)metricName
|
|
|
56 |
byInt:(int64_t)incrementValue NS_SWIFT_NAME(incrementMetric(_:by:));
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Gets the value of the metric for the provided metric name. If the metric doesn't exist, a 0 is
|
|
|
60 |
* returned.
|
|
|
61 |
*
|
|
|
62 |
* @param metricName The name of metric whose value to get.
|
|
|
63 |
* @return The value of the given metric or 0 if it hasn't yet been set.
|
|
|
64 |
*/
|
|
|
65 |
- (int64_t)valueForIntMetric:(nonnull NSString *)metricName NS_SWIFT_NAME(valueForMetric(_:));
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Sets the value of the metric for the provided metric name to the provided value. Does nothing if
|
|
|
69 |
* the trace has not been started or has already been stopped.
|
|
|
70 |
*
|
|
|
71 |
* @param metricName The name of the metric to set.
|
|
|
72 |
* @param value The value to set the metric to.
|
|
|
73 |
*/
|
|
|
74 |
- (void)setIntValue:(int64_t)value
|
|
|
75 |
forMetric:(nonnull NSString *)metricName NS_SWIFT_NAME(setValue(_:forMetric:));
|
|
|
76 |
|
|
|
77 |
@end
|