Code Monkey home page Code Monkey logo

oadtracer's Introduction

OADTracer

Build Status Version License Platform

OADTracer is an objective c library that facilitates the sending of DTrace events. OADTracer exposes methods for sending NSURLRequest and NSURLResponse as JSON strings to DTRace.

Why use DTrace?

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 performance overhead.

Usage

Sending DTrace events

OADTracer exposes three method to send DTrace events.

Using [OADTracer traceRequest:], NSURLRequest are packaged and sent as JSON to oadprobe:::request probe.

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.google.com"]];

[[OADTracer instance] traceRequest:request];

Using [OADTracer traceResponse:data:error], NSURLResponse, NSData and NSError are group and sent as JSON to oadprobe:::response probe.

[[OADTracer instance] traceResponse:response data:data error:error];

response, data and error are passed with the callback of [NSURLSession dataTaskWithRequest]

Using [OADTracer traceString:], NSString is sent to oadprobe:::custom probe.

[[OADTracer instance] traceString:@"Some string"];

Listening to DTrace events

To listen to the DTrace command sent, you can either use the dtrace command, a good explanation on how to do that is here, or you can use dtracer gem.

DTracer gem

dtracer gem was written to be conveniently used with OADTracer library. dtracer provides equivalent commands to register and print the DTrace events sent.

dtracer provides the following commands:

dtracer curl

Outputs the NSURLRequest sent with [OADTracer traceRequest:] as a curl command

dtracer details

Outputs the NSURLRequest sent with [OADTracer traceRequest:] as a formatted string. It also accepts multiple flags to customise the printed string. Run dtracer help details for additional info.

dtracer response

Outputs the event sent with [OADTracer traceResponse:data:error:] as a formatted string.

dtracer custom

Outputs the string sent with [OADTracer traceString:].

Check dtracer page form more info.

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

OADTracer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "OADTracer"

Author

Omar Abdelhafith, [email protected]

License

OADTracer is available under the MIT license. See the LICENSE file for more info.

oadtracer's People

Watchers

James Cloos avatar  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.