lightstep-tracer-objc
LightStep 分布式跟踪库,适用于 Objective-C 和 Swift。
CocoaPods 安装
- 请确保您已安装 CocoaPods (TL;DR:
sudo gem install cocoapods
) - 在您的 Xcode 项目中创建一个
Podfile
并添加以下行
pod 'lightstep', '~>3.2'
- 在项目目录中运行
pod install
。在 Xcode 中打开新创建的工作空间文件。
入门
#import "LSTracer.h"
#import "OTGlobal.h"
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize the LightStep tracer implementation
LSTracer* tracer = [[LSTracer alloc] initWithToken:@"{your_access_token}"];
[OTGlobal initSharedTracer:tracer];
// <Your normal initialization code here>
return YES;
}
// Elsewhere:
- (void)someFunction:... {
id<OTSpan> span = [[OTGlobal sharedTracer] startSpan:@"someFunction:"];
...
[span finish];
}
- 有关 OpenTracing 的更多信息,请参阅 opentracing.io。