Skip to content

Custom Xcode Instruments package that implements tracing of any activities inside the app. See detailed description here: https://appspector.com/blog/instruments-part-2

License

Notifications You must be signed in to change notification settings

appspector/Tracer

Repository files navigation

Tracer

This repo contains example project and custom Xcode Instruments package for opentracing-like inspection of any activities in your iOS/macOS app. See detailed description here: https://appspector.com/blog/instruments-part-2

Requirements

os_signpost API is available starting from iOS 12 and macOS 10.14. To install custom package you need Xcode 10.

Installation

To add the package to your Instruments you have to download it from the Releases, extract, doubleclick and install. After that it will appear in the list of instruments. Unfortunately there is no way to install and update it automatically.

To use the package you need to issue appropriate os_signpost calls, which is more convinient using wrapper from TracingModule directory in sample project. Wrapper could be installed via CocoaPods:

pod 'Tracer', '~> 1.0.1'

or manually by just moving TracingModule directory to your project and importing Tracer:

#import <Tracer/ASTracer.h>

Usage

Manual

There are two ways you can play with tracer. First is manually by using the following API:

- (ASScope *)addScope:(NSString *)scopeName;
- (void)removeScope:(NSString *)scopeName;
- (void)startSpan:(NSString *)spanName inScope:(NSString *)scopeName;
- (void)stopSpan:(NSString *)spanName inScope:(NSString *)scopeName success:(BOOL)success;

Scopes and spans are concepts describing activites you want to trace, i.e. if you want to trace your view controllers activities scope coud be a view controller and span - any activity performed within it. Span and scope names should be unique. Stopping a span you can pass success flag which indicates span completion status, failed spans will be displayed red on a graph lane.

Tracing NSOperations

Also you can use tracer to atomatically trace NSOperations using startTracingOperations call:

[[ASTracer tracer] startTracingOperations];

This will install hooks and KVO observers to track operations lifecycle.

Sample app

If you want to play with package yo ucan use Tracer app in the package Xcode project. It allows to create NSOperationQueues and operations inside them and automatically starts tracing them. Install package then start Tracer app, run Instruments, choose blank template add Tracer package to it and start recording:

Resources

About Us

Looking for better debugging instrument? Try AppSpector. With AppSpector you can remotely debug your app running in the same room or on another continent. You can measure app performance, view CoreData and SQLite content, logs, network requests and many more in realtime. This is the instrument that you've been looking for.