1{ 2 "metadata": { 3 "name": "", 4 "signature": "sha256:07509ec03cc71263d49f2d8bb69f21bd039d5ddeeb3f3c81573002794049a1aa" 5 }, 6 "nbformat": 3, 7 "nbformat_minor": 0, 8 "worksheets": [ 9 { 10 "cells": [ 11 { 12 "cell_type": "markdown", 13 "metadata": {}, 14 "source": [ 15 "The `BareTrace` class lets you create a trace class that has been parsed outside of trappy. This lets you leverage trappy's and bart's facilities with any type of trace." 16 ] 17 }, 18 { 19 "cell_type": "markdown", 20 "metadata": {}, 21 "source": [ 22 "Let's assume that we have events available in a csv file. We can import them into a trace object by creating a `BareTrace` object and adding them using `add_parsed_event`." 23 ] 24 }, 25 { 26 "cell_type": "code", 27 "collapsed": false, 28 "input": [ 29 "import pandas as pd\n", 30 "import trappy" 31 ], 32 "language": "python", 33 "metadata": {}, 34 "outputs": [], 35 "prompt_number": 1 36 }, 37 { 38 "cell_type": "markdown", 39 "metadata": {}, 40 "source": [ 41 "First we import the parsed events into a pandas DataFrame" 42 ] 43 }, 44 { 45 "cell_type": "code", 46 "collapsed": false, 47 "input": [ 48 "event = pd.DataFrame.from_csv(\"sample_trace.csv\")" 49 ], 50 "language": "python", 51 "metadata": {}, 52 "outputs": [], 53 "prompt_number": 2 54 }, 55 { 56 "cell_type": "markdown", 57 "metadata": {}, 58 "source": [ 59 "Now we create an trappy trace object and add our event to it. " 60 ] 61 }, 62 { 63 "cell_type": "code", 64 "collapsed": false, 65 "input": [ 66 "trace = trappy.BareTrace()\n", 67 "trace.add_parsed_event(\"http_access\", event)" 68 ], 69 "language": "python", 70 "metadata": {}, 71 "outputs": [], 72 "prompt_number": 3 73 }, 74 { 75 "cell_type": "markdown", 76 "metadata": {}, 77 "source": [ 78 "We can add more events if we had collected them from different sources. Just call `.add_parsed_event()` for each of them" 79 ] 80 }, 81 { 82 "cell_type": "code", 83 "collapsed": false, 84 "input": [ 85 "trappy.ILinePlot(trace, trace.http_access, column=[\"response_time\"]).view()" 86 ], 87 "language": "python", 88 "metadata": {}, 89 "outputs": [], 90 "prompt_number": null 91 } 92 ], 93 "metadata": {} 94 } 95 ] 96}