Setup Network
This page helps you get started with Luciq's network performance monitoring on iOS
Getting Started
Luciq App Performance Monitoring automatically captures your HTTP/S network requests when you're using the shared session. If some of your requests don't appear, you can follow the instructions below, depending on your setup: Custom Session Configuration, AFNetworking, or Alamofire.
Using Custom Session Configuration?
If you're using a custom NSURLSession or NSURLSessionConfiguration, add the following code snippet.
let configuration = URLSessionConfiguration.ephemeral
NetworkLogger.enableLogging(for: configuration)
let session = URLSession(configuration: configuration)NSURLSessionConfiguration *configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration;
[LCQNetworkLogger enableLoggingForURLSessionConfiguration:configuration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];Using AFNetworking
To enable network monitoring for AFNetworking, create the following class. Then use LCQAFURLSessionManager to create your requests.
// LCQAFURLSessionManager.h
#import <AFNetworking/AFNetworking.h>
@interface LCQAFURLSessionManager : AFURLSessionManager
@end
// LCQAFURLSessionManager.m
#import "LCQAFURLSessionManager.h"
#import <Luciq/Luciq.h>
@implementation LCQAFURLSessionManager
- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration {
[LCQNetworkLogger enableLoggingForURLSessionConfiguration:configuration];
return [super initWithSessionConfiguration:configuration];
}
@endUsing Alamofire?
To enable logging for Alamofire, create the following class. Then use LCQSessionManager to create your requests.
Using Apollo?
To enable logging for Apollo, pass your session configuration to our NetworkLogger and Apollo client
gRPC Support
Luciq supports the logging of gRPC requests. Depending on whether your codebase is Objective-C or Swift, a few different steps are required.
iOS minimum version
Logging gRPC requests is supported on iOS 10 and above.
gRPC Requests for Swift apps
To log gRPC requests in your Swift app, you'll need to add pod Luciq-gRPC-Swift to your podfile. Below you can find a few sample steps to assist with setting it up:
Import our destination:
import Luciq_gRPC_SwiftCreate an interceptor factory that confirms to the interceptor factory protocol that you have in your .grpc file
Make sure to return new instance of our interceptor
LuciqClientInterceptor()in the methods that require being logged by LuciqYou can pass the port optionally in
LuciqClientInterceptorasLuciqClientInterceptor(port: <#T##Int?#>)to see it on the dashboardYou can convert your model to Data by conforming to Encodable
You can pass the port optional in LuciqClientInterceptor as LuciqClientInterceptor(port: <#T##Int?#>) to see it on the dashboard
Below is sample code for the interceptor factory:
gRPC requests for Objective-C apps
To log gRPC requests in your Swift app, you'll need to add pod Luciq_gRPC_ObjC to your podfile. Below you can find a few sample steps to assist with setting it up:
Create an array of
GRPCInterceptorFactoryCreate a class that conforms to GRPCInterceptorFactory protocol
Override
createInterceptorWithManagerinGRPCFactoryand returnLuciqClientInterceptor
Create a new instance of
GRPCFactoryand add it to the interceptors arrayCreate a new instance of
GRPCInterceptorManagerwith theinterceptorFactoriesarrayPass the manager to the factory instance
Finally pass
interceptorFactoriestooptions.interceptorFactories
Trace Attributes
Sometimes, you may need to add additional data or attributes to your network traces. This can be done using the API below.
Last updated