kim / opentracing

OpenTracing (https://opentracing.io) for Haskell
Apache License 2.0
40 stars 12 forks source link

Use hex fixed for hex ids to ensure 16 characters #18

Closed mjrussell closed 6 years ago

mjrussell commented 6 years ago

Resolves #17

I thought about switching the Text inside Hex to ByteString entirely, but that looked like a bunch of changes so I figured I'd do this first.

prng <- liftIO createSystemRandom
let newWord :: IO Word64 = liftIO (uniform prng)
idLengths <- map (length . toLazyByteString . word64HexFixed) <$> replicateM 10000 newWord
filter (/= 16) idLengths 
> []
kim commented 6 years ago

Ah nice one, thanks.

switching the Text inside Hex to ByteString entirely

Yeah well, would have to convert to Text at some point to encode to JSON, so not sure there's much to gain.

mjrussell commented 6 years ago

Text at some point to encode to JSON

Not if we use toEncoding right? We could just use id then?

kim commented 6 years ago

if we use toEncoding

Mm yeah, have to give it some thought ... it could optimize the read path from HTTP headers (which are ByteStrings), which currently go through TextMap.