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)

Multiple NSURLSessions

Starting from SDK v11.0.3, Luciq supports multiple NSURLSession objects.

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];
}

@end

Using 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.

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:

  1. Import our destination: import Luciq_gRPC_Swift

  2. Create an interceptor factory that confirms to the interceptor factory protocol that you have in your .grpc file

  3. Make sure to return new instance of our interceptor LuciqClientInterceptor() in the methods that require being logged by Luciq

  4. You can pass the port optionally in LuciqClientInterceptor as LuciqClientInterceptor(port: <#T##Int?#>) to see it on the dashboard

  5. You can convert your model to Data by conforming to Encodable

  6. 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:

  1. Create an array of GRPCInterceptorFactory

  2. Create a class that conforms to GRPCInterceptorFactory protocol

  1. Override createInterceptorWithManager in GRPCFactory and return LuciqClientInterceptor

  1. Create a new instance of GRPCFactory and add it to the interceptors array

  2. Create a new instance of GRPCInterceptorManager with the interceptorFactories array

  3. Pass the manager to the factory instance

  4. Finally pass interceptorFactories to options.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.

You can add up to 20 unique trace attributes per each trace.

Last updated