developer
2023-05-20 e12c7b4c22df631ebdcd16b2f98fbef8f738f92f
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//  '########'########::'######:'########:'##:::'##:
//  ... ##..::##.... ##'##... ##:##.... ##:##::'##::
//  ::: ##::::##:::: ##:##:::..::##:::: ##:##:'##:::
//  ::: ##::::########:. ######::##:::: ##:#####::::
//  ::: ##::::##.... ##:..... ##:##:::: ##:##. ##:::
//  ::: ##::::##:::: ##'##::: ##:##:::: ##:##:. ##::
//  ::: ##::::########:. ######::########::##::. ##:
//  :::..::::........:::......::........::..::::..::
//
//  UTListener.h
//  TBSDK
//
//  Created by Roger.Mu on 3/19/14.
//  Copyright (c) 2014 Taobao.com. All rights reserved.
//
 
#import <Foundation/Foundation.h>
 
@protocol MtopLaunchTypeProtocol;
@class MtopExtResponse;
@class MtopExtRequest;
 
#define UT_TYPE_PERF @"performace"
#define UT_TYPE_TOTALTCP @"totalTcp"
#define UT_TYPE_DEMOTELEVEL @"demote"
#define UT_TYPE_STD @"stdUTLog"
#define UT_TYPE_ERROR @"error"
#define UT_TYPE_MTOPUT @"mtoput"
 
 
#define NOTIFICATION_FILE_UPLOADED  @"kTBSDKFileUploaded"
 
// report cache
@interface UTReportDataSet : NSObject
 
@property (nonatomic, copy) NSNumber *spdyTotalTimes;
@property (nonatomic, copy) NSNumber *spdyTotaldates;
@property (nonatomic, copy) NSNumber *spdyTotalContentLength;
@property (nonatomic, copy) NSNumber *httpTotalTimes;
@property (nonatomic, copy) NSNumber *httpTotalDates;
@property (nonatomic, copy) NSNumber *httpTotalContentLength;
 
// cache properties
@property (nonatomic, assign) int cacheTotalTimes;
@property (nonatomic, assign) int cacheReadTotalDates;
@property (nonatomic, assign) int cacheReadTotalTimes;
@property (nonatomic, assign) int cacheWriteTotalDates;
@property (nonatomic, assign) int cacheWriteTotalTimes;
@property (nonatomic, assign) int cacheWriteTotalContentLength;
 
 
+ (UTReportDataSet *)shareInstance;
 
- (void) saveHttpTotalData:(NSInteger) totalTimes
             withTotalDate:(NSNumber *) totalDate
    withTotalContentLength:(NSNumber *) totalContentLength;
- (void) saveSPDYTotalData:(NSInteger) totalTimes
             withTotalDate:(NSNumber *) totalDate
    withTotalContentLength:(NSNumber *) totalContentLength;
 
// increment tcp link times
- (void) incrementTcpLinks:(NSNumber *) times;
 
// increment cache hit times
- (void) incrementCacheHitTimes:(NSNumber *) readDate;
 
// increment cache times
- (void) incrementCacheTimes;
 
// increment cache 
- (void) incrementCacheWrite:(NSNumber *) writeDate withCacheSize: (long) cacheSize;
 
- (int) getTotalTimes;
- (double) getTotalDates;
- (int) getTotalContantLength;
- (NSInteger) getTcpLinkTimes;
- (NSInteger) getTcpLinkDates;
- (void) cleanAll;
@end
 
 
// write log data set of UT framework
@interface UTDataSet : NSObject <NSCopying>
 
@property (nonatomic, copy) NSNumber *dnsStartTime;
@property (nonatomic, copy) NSNumber *dnsEndTime;
@property (nonatomic, copy) NSString *tcpLinkDate;
@property (nonatomic, copy) NSString *oneWayTime;
@property (nonatomic, copy) NSString *dnsTime;
@property (nonatomic, copy) NSString *utType;
@property (nonatomic, copy) NSString *tcpTotalTimes;
@property (nonatomic, copy) NSString *tcpTotalDates;
@property (nonatomic, copy) NSString *SpdyTotalTimes;
 
@property (nonatomic, copy) NSString *errorCode;
@property (nonatomic, copy) NSString *errorInfo;
@property (nonatomic, copy) NSString *errorMemo;
 
@property (nonatomic, assign) int eventid;
@property (nonatomic, copy) NSDictionary *args;
@property (nonatomic, copy) NSString *arg1;
@property (nonatomic, copy) NSString *arg2;
@property (nonatomic, copy) NSString *arg3;
@property (nonatomic, copy) NSString *cacheSwitch;
@property (nonatomic, copy) NSString *cacheHitType;
 
@property (nonatomic, copy) NSString *expression;
 
// mtop properties
@property (atomic, assign) CFAbsoluteTime mtopStartTime;
@property (atomic, assign) CFAbsoluteTime mtopEndTime;
@property (nonatomic, assign) CFAbsoluteTime jsonParseStartTime;
@property (nonatomic, assign) CFAbsoluteTime jsonParseEndTime;
@property (nonatomic, assign) CFAbsoluteTime sendWaitStart;
@property (nonatomic, assign) CFAbsoluteTime sendWaitEnd;
@property (nonatomic, copy) NSString *mtopOneWayTime;
@property (nonatomic, copy) NSString *isSync;
 
//mtop fullTrace measure
@property (nonatomic,copy) NSString *mtopReqProcessStartT;
@property (nonatomic,copy) NSString *mtopRspProcessStartT;
@property (nonatomic,copy) NSString *mtopRspDispatchT;
@property (nonatomic,copy) NSString *mtopRspCbStartT;
@property (nonatomic,copy) NSString *mtopRspCbEndT;
@property (nonatomic,copy) NSString *jsonPraseTime;
 
-(UTDataSet *)initWithType: (NSString *)utype;
 
@end
 
// UT log base object
@interface TBSDKUTUtility : NSObject
 
// ----- properties -----
@property (nonatomic, strong) NSMutableArray *utCacheArray;
// ----------------------
 
#pragma mark init
// UT share instance
+ (TBSDKUTUtility *)shareInstance;
 
- (TBSDKUTUtility *)init;
 
#pragma mark event listener
// dns parse event by listen
- (void)onDnsParseTime: (UTDataSet *) dataSet;
 
// tcp create link event by listen
- (void)onTcpLinkTime: (long long) startDate withEndDate: (long long) endDate;
 
// request start event
- (void)onRequestStart: (NSString *) requestType;
 
// request cache event
- (void)onRequestCache;
 
// request hit cache event
- (void)onHitedRequestCache: (NSNumber *) readDate;
 
// request write cache event
- (void)onWriteResponseCache: (NSNumber *) writeDate withCacheSize: (long) cacheSize;
 
// request end event
- (void)onRequestEnd: (NSString *) requestType
   withContentLength: (int) contentLength
   withError        : (NSError *) error;
 
// handle error event
- (void)onError: (NSError *) error;
 
// on times finished event
- (void)onOneTimesFinished: (UTDataSet *) dataSet;
 
// write UT log
- (void)writeUTLog: (UTDataSet *)dataSet;
 
#pragma mark notification
// home key event listener
-(void) writeUtLogByHomeKey: (NSNotification *) notification;
 
// spdy demote event listener
+ (void) writeUtLogByDemoteSpdy: (NSString *) errorInfo withUrl:(NSString *) url;
 
@end
 
 
/**
 * 全链路埋点类
 */
@interface MtopFullTraceUtil : NSObject
 
+ (instancetype)sharedInstance;
 
- (NSString *)fullTraceID;
 
- (void)reportTraceData:(NSDictionary<NSString *,NSString *> *)reportData;
 
- (void)reportTraceData:(MtopExtRequest *)erequest response:(MtopExtResponse *)response;
 
- (id<MtopLaunchTypeProtocol>)fetchLaunchObj;
 
@end