jaeger-flamegraph 1.1.0 → 1.2.0
raw patch · 4 files changed
+36/−21 lines, 4 filessetup-changed
Files
- Setup.hs +0/−2
- exe/Main.hs +22/−6
- jaeger-flamegraph.cabal +8/−11
- library/Interval.hs +6/−2
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
exe/Main.hs view
@@ -22,7 +22,8 @@ import Data.Text (Text, intercalate, map, pack) import Data.Text.IO (putStrLn) import GHC.Generics (Generic)-import Interval (Interval, interval, measure, width)+import Interval (Interval, interval, intervalEnd,+ intervalStart, measure, width) import qualified Options.Applicative as Opts import Prelude hiding (map, putStrLn) @@ -36,7 +37,8 @@ Jaeger dat <- either fail pure $ eitherDecodeStrict text let processes = if qualify then buildProcesses dat else Map.empty spans = buildLookup dat- stacks = buildStacks ignoreTags annotated =<< buildFlames processes spans+ stacks = buildFlames processes spans >>=+ buildStacks wall ignoreTags annotated traverse_ (putStrLn . drawStack) stacks data Options = Options@@ -44,6 +46,7 @@ , ignoreTags :: [Tag] , annotated :: [ProcessID] , qualify :: Bool+ , wall :: Bool } data Input = FileInput FilePath | StdInput optionsParser :: Opts.Parser Options@@ -52,6 +55,7 @@ <*> Opts.many tag <*> Opts.many ann <*> qual+ <*> wall where file = FileInput <$> Opts.strOption ( Opts.long "file"@@ -72,6 +76,10 @@ ( Opts.short 'q' <> Opts.long "qualify" <> Opts.help "Qualify span names by their process")+ wall = Opts.switch+ ( Opts.short 'w'+ <> Opts.long "walltime"+ <> Opts.help "Takes start/end times of children into account when calculating times.") newtype Jaeger = Jaeger [Data] instance FromJSON Jaeger where@@ -139,6 +147,13 @@ selftime :: Flame -> Integer selftime f = max 0 $ (width $ time f) - (measure $ time <$> children f) +walltime :: Flame -> Integer+walltime f = end' - start' - (measure $ time <$> children f)+ where family = f : children f+ -- only start/end times from immediate children to avoid accumulation+ start' = minimum $ intervalStart . time <$> family+ end' = maximum $ intervalEnd . time <$> family+ -- We only support one parent per span. -- -- https://github.com/opentracing/opentracing.io/issues/28@@ -175,7 +190,7 @@ maybeToList $ lookupSpan ref qualifiedName orig pid = case Map.lookup pid procs of Nothing -> orig- Just p -> Name $ (unName orig) <> "..." <> (serviceName p)+ Just p -> Name $ (unName orig) <> "..." <> (serviceName p) -- https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl --@@ -202,15 +217,16 @@ , annotated :: Bool } -buildStacks :: [Tag] -> [ProcessID] -> Flame -> [Stack]-buildStacks banned annotate = stacks []+buildStacks :: Bool -> [Tag] -> [ProcessID] -> Flame -> [Stack]+buildStacks wall banned annotate = stacks [] where stacks :: [Name] -> Flame -> [Stack] stacks parents f @ Flame{..} = if not . null $ intersect banned tags then []- else Stack (name :| parents) (selftime f) (elem process annotate) :+ else Stack (name :| parents) t (elem process annotate) : (stacks (name : parents) =<< children)+ where t = if wall then walltime f else selftime f drawStack :: Stack -> Text drawStack Stack{..} = intercalate ";" (map cleanup . unName <$>
jaeger-flamegraph.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: jaeger-flamegraph-version: 1.1.0+version: 1.2.0 synopsis: Generate flamegraphs from Jaeger .json dumps. license: BSD-3-Clause license-file: LICENSE@@ -11,19 +11,16 @@ tested-with: GHC ^>= 8.4.4 || ^>= 8.6.2 category: Testing description:- This is a small tool to convert JSON dumps obtained from a Jaeger- server (<https://www.jaegertracing.io/>) into a format consumable+ This is a small tool to convert JSON dumps obtained from a [Jaeger+ server] (https://www.jaegertracing.io/) into a format consumable by [FlameGraph](https://github.com/brendangregg/FlameGraph). .- First download the traces for your SERVICE limiting to LIMIT traces- .- > $ curl http://your-jaeger-installation/api/traces?service=SERVICE&limit=LIMIT > input.json- .- using the [undocumented Jaeger API](https://github.com/jaegertracing/jaeger/issues/456#issuecomment-412560321)- then use @jaeger-flamegraph@ to convert the data and send to @flamegraph.pl@- .- > $ jaeger-flamegraph -f input.json | flamegraph.pl > output.svg+ Filter the traces for your SERVICE from the+ [undocumented Jaeger API](https://github.com/jaegertracing/jaeger/issues/456). .+ > $ curl http://jaeger/api/traces?service=SERVICE&limit=1000 |+ > jaeger-flamegraph |+ > flamegraph.pl > output.svg source-repository head type: git
library/Interval.hs view
@@ -3,6 +3,8 @@ module Interval ( Interval , interval+ , intervalStart+ , intervalEnd , measure , width) where@@ -11,8 +13,10 @@ import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary) -- nothing on http://hackage.haskell.org/packages/search?terms=interval-data Interval = Interval Integer Integer -- ^ assume from <= to- deriving (Eq, Ord, Show)+data Interval = Interval+ { intervalStart :: Integer -- ^ assume start <= end+ , intervalEnd :: Integer+ } deriving (Eq, Ord, Show) interval :: Integer -> Integer -> Interval interval a b | a <= b = Interval a b