Skip to content

Commit

Permalink
MOD: add collecting metrics in YTKNetworkConfig
Browse files Browse the repository at this point in the history
Change-Id: Ie25a408360ff540a3cf2c9cc56d249eb0e2606a2
  • Loading branch information
shangcr committed Apr 26, 2020
1 parent 35dc3e6 commit 995a604
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions YTKNetwork/YTKNetworkAgent.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ - (instancetype)init {
// Take over the status code validation
_manager.responseSerializer.acceptableStatusCodes = _allStatusCodes;
_manager.completionQueue = _processingQueue;
[_manager setTaskDidFinishCollectingMetricsBlock:_config.collectingMetricsBlock];
}
return self;
}
Expand Down
4 changes: 4 additions & 0 deletions YTKNetwork/YTKNetworkConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
@class YTKBaseRequest;
@class AFSecurityPolicy;

typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * metrics) API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));

/// YTKUrlFilterProtocol can be used to append common parameters to requests before sending them.
@protocol YTKUrlFilterProtocol <NSObject>
/// Preprocess request URL before actually sending them.
Expand Down Expand Up @@ -74,6 +76,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) BOOL debugLogEnabled;
/// SessionConfiguration will be used to initialize AFHTTPSessionManager. Default is nil.
@property (nonatomic, strong) NSURLSessionConfiguration* sessionConfiguration;
/// NSURLSessionTaskMetrics
@property (nonatomic, strong) AFURLSessionTaskDidFinishCollectingMetricsBlock collectingMetricsBlock API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10));

/// Add a new URL filter.
- (void)addUrlFilter:(id<YTKUrlFilterProtocol>)filter;
Expand Down

0 comments on commit 995a604

Please sign in to comment.