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 |
/**
|
|
|
18 |
* FPRCounterList contains information about a list of counters. Every item in the list is a
|
|
|
19 |
* key value pair, where the key is the reference to the name of a counter and the value is the
|
|
|
20 |
* current count for the key. Counter values can be incremented.
|
|
|
21 |
*/
|
|
|
22 |
@interface FPRCounterList : NSObject
|
|
|
23 |
|
|
|
24 |
@property(atomic, nonnull, readonly) NSDictionary<NSString *, NSNumber *> *counters;
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* The number of counters.
|
|
|
28 |
*/
|
|
|
29 |
@property(atomic, readonly) NSUInteger numberOfCounters;
|
|
|
30 |
|
|
|
31 |
/** Serial queue to manage incrementing counters. */
|
|
|
32 |
@property(nonatomic, nonnull, readonly) dispatch_queue_t counterSerialQueue;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Increments the counter for the provided counter name with the provided value.
|
|
|
36 |
*
|
|
|
37 |
* @param counterName Name of the counter.
|
|
|
38 |
* @param incrementValue Value the counter would be incremented with.
|
|
|
39 |
*/
|
|
|
40 |
- (void)incrementCounterNamed:(nonnull NSString *)counterName by:(NSInteger)incrementValue;
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Verifies if the metrics are valid.
|
|
|
44 |
*
|
|
|
45 |
* @return A boolean stating if the metrics are valid.
|
|
|
46 |
*/
|
|
|
47 |
- (BOOL)isValid;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* Increments the metric for the provided metric name with the provided value.
|
|
|
51 |
*
|
|
|
52 |
* @param metricName Name of the metric.
|
|
|
53 |
* @param incrementValue Value the metric would be incremented with.
|
|
|
54 |
*/
|
|
|
55 |
- (void)incrementMetric:(nonnull NSString *)metricName byInt:(int64_t)incrementValue;
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Gets the value of the metric for the provided metric name. If the metric doesn't exist, a 0 is
|
|
|
59 |
* returned.
|
|
|
60 |
*
|
|
|
61 |
* @param metricName The name of metric whose value to get.
|
|
|
62 |
*/
|
|
|
63 |
- (int64_t)valueForIntMetric:(nonnull NSString *)metricName;
|
|
|
64 |
|
|
|
65 |
/**
|
|
|
66 |
* Sets the value of the metric for the provided metric name to the provided value. If it is a new
|
|
|
67 |
* counter name, the counter value will be initialized to the value. Does nothing if the trace has
|
|
|
68 |
* not been started or has already been stopped.
|
|
|
69 |
*
|
|
|
70 |
* @param metricName The name of the metric whose value to set.
|
|
|
71 |
* @param value The value to set the metric to.
|
|
|
72 |
*/
|
|
|
73 |
- (void)setIntValue:(int64_t)value forMetric:(nonnull NSString *)metricName;
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Deletes the metric with the given name. Does nothing if that metric doesn't exist.
|
|
|
77 |
*
|
|
|
78 |
* @param metricName The name of the metric to delete.
|
|
|
79 |
*/
|
|
|
80 |
- (void)deleteMetric:(nonnull NSString *)metricName;
|
|
|
81 |
|
|
|
82 |
@end
|