BBAProbeLogInfo.h
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// BBAProbeLogInfo.h
// BBAAPIRequest
//
// Created by liumuye on 2021/3/5.
//
// Copyright © 2021年 baidu. All rights reserved.
#import <Foundation/Foundation.h>
#import "BBABaseAPIRequest.h"
#import "BBAAPIRequestConfiguration.h"
@class BBABaseAPIRequest;
NS_ASSUME_NONNULL_BEGIN
// 探测类型
typedef NS_ENUM(NSInteger, APIRequestProbeType) {
APIRequestProbeTypeFailure, // 好网下连续失败
APIRequestProbeTypeSuccess, // 弱网下连续成功
APIRequestProbeTypeTTFBWeak, // 好网下ttfb慢
APIRequestProbeTypeTTFBGood // 弱网下ttfb快
};
/// 记录探测过程, 用于日志打点
@interface BBAProbeLogInfo : NSObject
/// 初始化方法
/// @param type 探测类型
- (instancetype)initWithType:(APIRequestProbeType)type;
/// 增加一条触发探测的日志
/// @param task 触发探测对应的请求
/// @param from 请求业务来源
/// @param subFrom 请求业务子来源
/// @param bdTraceId TraceID
/// @param isSuccess 成功/失败的请求
/// @param ttfb 请求的TTFB
/// @param err 请求错误
- (void)addRequest:(NSURLSessionTask *)task
from:(APIRequestFrom)from
subFrom:(APIRequestSubFrom)subFrom
bdTraceId:(NSString *)bdTraceId
isSuccess:(BOOL)isSuccess
ttfb:(NSTimeInterval)ttfb
error:(NSError * _Nullable)err;
/// 重置日志信息
- (void)reset;
/// 检测前网络质量
@property (nonatomic, assign) NSUInteger netQualityBefore;
/// 检测后网络质量
@property (nonatomic, assign) NSUInteger netQualityAfter;
/// 引起检测的类型 (TTFB、成功、失败)
@property (nonatomic, assign) NSUInteger probeType;
/// 触发探测的请求列表信息
@property (atomic, strong) NSArray <NSDictionary *> *requestInfoList;
/// 检测开始时间
@property (atomic, assign) NSTimeInterval startTime;
/// 检测结束时间
@property (atomic, assign) NSTimeInterval endTime;
@end
NS_ASSUME_NONNULL_END