DTracer is part ruby gem, part iOS pod, that helps the sending and receiving of DTrace commands.
dtracer gem will listen to the DTrace commands that are sent from the OADTraceSender pod.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install dtracer
- Incorporate the
OADTraceSenderin your iOS project (how to?)
OADTraceSenderin your iOS app, to send a dtrace command.
- Run the iOS app to register the probes.
dtracergem command line to register a probe.
Any dtrace command you send will be received on your terminal.
Note: registering a probe using DTrace requires admin privileges, running any dtracer command will ask for that.
Type of probes
One good usage of DTrace is to log the network communicate instead of polluting the Xcode console.
Using DTrace to log network communication has the following benefits:
- Avoids Xcode console pollution with network logs.
- Extremely cheap; probes that are not being listened do not add any overhead.
To check how to implement OADtraceSender in your iOS project, check OADtraceSender pod.
dtracer command you can register 3 types of tracers.
These are probes that listens to dtrace command sent from
[OADTracer traceRequest:] objc method.
Outputs the the
NSURLRequest send with the dtrace event as a curl command.
Outputs the the
NSURLRequest send with the dtrace event as a formatted string. You can pass it multiple flags to decide what to print from the request.
dtracer help details to check how to customize the output.
-r flag with both of the above commands will add a response probe output.
dtracer response adds a probe that outputs the
NSError combination, sent using
[OADTracer traceResponse:data:error:] objc method.
In case you have the need to send any arbitrary string, then use
dtracer custom; This command adds a probe that prints any string sent using
[OADTracer traceString:] objc method.
- Fork it ( https://github.com/oarrabi/dtracer/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request