GithubHelp home page GithubHelp logo

cocoongg / ios-apm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mediaios/ios-apm

0.0 1.0 0.0 782 KB

Research and implement an ios apm sdk

License: MIT License

Objective-C 83.17% Ruby 5.43% C 11.40%

ios-apm's Introduction

ios-apm

介绍

背景

此前曾关注过一些apm(应用性能管理平台)系统,对其实现很是好奇。此SDK是对apm系统中ios平台信息采集的一个技术预研。我觉得在整个apm系统中,对网络的监控是最复杂的,所以我们先从网络监控入手循序渐进的理解整个系统。

整个技术预研的过程是通过一个SDK的形式展现的,该SDK只做信息采集和回显。

灵感

由于市场上很多的apm系统都是收费的(不收费的有数量和查询功能的限制),所以我觉得我们可以在我们自己的应用中做一个隐藏开关来控制debug信息的显示,这些debug信息就是我们应用中很多关键性能的信息,比如:http请求情况、当前应用的帧率、cpu利用率等信息。当用户反馈哪个功能有问题时,可以通过打开隐藏开关来显示debug信息的方式进行黑盒测试,进而更直观的定位到引起bug的原因。

所以,你可以使用该SDK查看应用中这些关键的信息。

环境要求

  • iOS >= 10.0
  • XCode >= 8.0
  • 设置Enable BitcodeNO

安装使用

通过pod方式

在你工程的Podfile中添加以下依赖:

pod 'MIApm'

快速开始

首先是引入SDK,在你的项目中最开始的地方(我们推荐是main.m中)导入SDK头文件:

#import <MIApm/MIApm.h>

然后再main方法中调用MIApmClient中的apmClient方法:

 int main(int argc, char * argv[]) {
    @autoreleasepool {
        [MIApmClient apmClient];
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

另外,你需要将 -ObjC 添加到项目的Build Setting->other links flags中。 如下所示:

回显监控的数据

当前版本支持持网络请求监控和对UIWebView的监控。

监控网路请求

支持的网络请求有:

  • NSURLConnection
  • NSURLSession
  • AFNetWorking
  • 其它使用NSURLConnectionNSURLSession请求的网络请求框架

首先在你想要回显的类里面引入头文件,利用SDK中的代理回显相关信息。

// 设置代理  
[MIApmClient apmClient].delegate = self;

// 回显数据 
- (void)apm:(MIApmClient *)apm monitorNetworkRequest:(MIRequestMonitorRes *)netModel
{
	// 你的处理逻辑 
    NSLog(@"%@",netModel);
}


监控UIWebView

同样通过实现代理的方式回显相关信息:

- (void)apm:(MIApmClient *)apm monitorUIWebView:(MIWebViewRequestMonitorRes *)webViewMonitorRes{
	// 你的处理逻辑
	NSLog(@"%@", webViewMonitorRes);
}

其它功能

  • 待完善中。。。

联系我们

  • 如果你有任何问题或需求,请提交issue
  • 如果你要提交代码,欢迎提交 pull request
  • 欢迎点星

ios-apm's People

Contributors

mediaios avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.