Maintainer | The Vaultaire Team |
---|---|
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Overview
When communicating with a Vaultaire installation, you need to serialize
requests and deserialize responses. The bytes used over the wire are all
formed by making the various types involved instances of class WireFormat
.
As it happens, these types are also the same ones used in the internals of Vaultaire as it persists measurements and metadata to disk.
- newtype Address = Address {}
- calculateBucketNumber :: Word64 -> Address -> Word64
- isAddressExtended :: Address -> Bool
- newtype TimeStamp = TimeStamp {}
- convertToDiffTime :: TimeStamp -> NominalDiffTime
- convertToTimeStamp :: UTCTime -> TimeStamp
- getCurrentTimeNanoseconds :: IO TimeStamp
- newtype Origin = Origin {}
- makeOrigin :: ByteString -> Either SomeException Origin
- data SourceDict
- unionSource :: SourceDict -> SourceDict -> SourceDict
- diffSource :: SourceDict -> SourceDict -> SourceDict
- lookupSource :: Text -> SourceDict -> Maybe Text
- makeSourceDict :: HashMap Text Text -> Either String SourceDict
- hashSource :: SourceDict -> Word64
- data SourceDictCache
- emptySourceCache :: SourceDictCache
- insertSourceCache :: Word64 -> SourceDictCache -> SourceDictCache
- memberSourceCache :: Word64 -> SourceDictCache -> Bool
- sizeOfSourceCache :: SourceDictCache -> Int
- data ContentsOperation
- data ContentsResponse
- data ContentsListBypass = ContentsListBypass Address ByteString
- data ReadRequest
- data ReadStream
- newtype SimpleBurst = SimpleBurst {}
- newtype ExtendedBurst = ExtendedBurst {}
- data SimplePoint = SimplePoint {
- simpleAddress :: !Address
- simpleTime :: !TimeStamp
- simplePayload :: !Word64
- data ExtendedPoint = ExtendedPoint {}
- data WriteResult
- newtype PassThrough = PassThrough {}
- class WireFormat operation where
- fromWire :: ByteString -> Either SomeException operation
- toWire :: operation -> ByteString
- newtype DayMap = DayMap {}
- data TeleResp = TeleResp {}
- data TeleMsg = TeleMsg {}
- data TeleMsgType
- = WriterSimplePoints
- | WriterExtendedPoints
- | WriterRequest
- | WriterRequestLatency
- | WriterCephLatency
- | ReaderSimplePoints
- | ReaderExtendedPoints
- | ReaderRequest
- | ReaderRequestLatency
- | ReaderCephLatency
- | ContentsEnumerate
- | ContentsUpdate
- | ContentsEnumerateLatency
- | ContentsUpdateLatency
- | ContentsEnumerateCeph
- | ContentsUpdateCeph
- data TeleMsgUOM
- msgTypeUOM :: TeleMsgType -> TeleMsgUOM
- data AgentID
- agentIDLength :: Int
- agentID :: String -> Maybe AgentID
- type Epoch = Word64
- type NumBuckets = Word64
Identification of measurements
calculateBucketNumber :: Word64 -> Address -> Word64 Source
isAddressExtended :: Address -> Bool Source
Time of a measurement
Number of nanoseconds since the Unix epoch, stored in a Word64.
The Show instance displays the TimeStamp as seconds with the nanosecond precision expressed as a decimal amount after the interger, ie:
>>>
t <- getCurrentTimeNanoseconds
>>>
show t
2014-07-31T23:09:35.274387000Z
However this doesn't change the fact the underlying representation counts nanoseconds since epoch:
>>>
show $ unTimeStamp t
1406848175274387000
There is a Read instance that is reasonably accommodating.
>>>
read "2014-07-31T13:05:04.942089001Z" ::TimeStamp
2014-07-31T13:05:04.942089001Z
>>>
read "1406811904.942089001" :: TimeStamp
2014-07-31T13:05:04.942089001Z
>>>
read "1406811904" :: TimeStamp
2014-07-31T13:05:04.000000000Z
convertToDiffTime :: TimeStamp -> NominalDiffTime Source
Utility function to convert nanoseconds since Unix epoch to a
NominalDiffTime
, allowing you to then use the time manipulation
functions in Data.Time.Clock
getCurrentTimeNanoseconds :: IO TimeStamp Source
Get the current system time, expressed as a TimeStamp
(which is to
say, number of nanoseconds since the Unix epoch).
Namespacing and authentication
Origin is a ByteString representing a data origin. It must be between one and eight bytes.
Metadata about sources
data SourceDict Source
unionSource :: SourceDict -> SourceDict -> SourceDict Source
Wrapped HashMap.union for SourceDicts
diffSource :: SourceDict -> SourceDict -> SourceDict Source
Wrapped HashMap.difference for SourceDicts
lookupSource :: Text -> SourceDict -> Maybe Text Source
Wrapped HashMap.lookup for SourceDicts
Caching SourceDicts
hashSource :: SourceDict -> Word64 Source
Hashes the sourcedict using SipHash Hashes are used primarily to avoid redundant updates
memberSourceCache :: Word64 -> SourceDictCache -> Bool Source
Operations with the contents store
data ContentsOperation Source
data ContentsResponse Source
Streaming reads
data ReadRequest Source
newtype ExtendedBurst Source
Decoded reads
data SimplePoint Source
SimplePoints are simply wrapped packets for Vaultaire Each consists of 24 bytes: An 8 byte Address An 8 byte Timestamp (nanoseconds since Unix epoch) An 8 byte Payload
SimplePoint | |
|
data ExtendedPoint Source
ExtendedPoints are simply wrapped packets for Vaultaire
Each consists of 16 + length
bytes:
An 8 byte Address
An 8 byte Time (in nanoseconds since Unix epoch)
A length
byte Payload
On the wire their equivalent representation takes up
24 + length
bytes with format:
8 byte Address, 8 byte Time, 8 byte Length, Payload
Writes
data WriteResult Source
Hacks
newtype PassThrough Source
Conversion to and from wire format
class WireFormat operation where Source
This typeclass encapsulates all wire encoding/decoding, with the possibility of a decode failing.
fromWire :: ByteString -> Either SomeException operation Source
toWire :: operation -> ByteString Source
WireFormat () | Default dummy wire format |
WireFormat Address | There are assumptions made that the encoding of Address is fixed-length (8 bytes). Changing that will break things subtly. |
WireFormat ContentsListBypass | |
WireFormat DayMap | |
WireFormat PassThrough | |
WireFormat ReadStream | |
WireFormat SourceDict | |
WireFormat ContentsOperation | |
WireFormat ContentsResponse | |
WireFormat SourceDictCache | |
WireFormat TimeStamp | |
WireFormat ReadRequest | |
WireFormat TeleMsg | |
WireFormat TeleResp | |
WireFormat AgentID | |
WireFormat WriteResult |
Internal
Response for a telemetry request, sent by the profiler to clients.
The actual telemetric data, reported by Vaultaire worker threads to their profiler.
data TeleMsgType Source
Telemetry types. All counts are absolute and all latencies are in milliseconds.
WriterSimplePoints | Total number of simple points written since last message |
WriterExtendedPoints | Total number of extended points written since last message |
WriterRequest | Total number of write requests received since last message |
WriterRequestLatency | Mean latency for one request |
WriterCephLatency | Mean Ceph latency for one request |
ReaderSimplePoints | Total number of simple points read since last message |
ReaderExtendedPoints | Total number of extended points read since last message |
ReaderRequest | Total number of read requests received since last message |
ReaderRequestLatency | Mean latency for one request |
ReaderCephLatency | Mean Ceph latency for one request |
ContentsEnumerate | Total number of enumerate requests received since last message |
ContentsUpdate | Total number of update requests received since last message |
ContentsEnumerateLatency | Mean latency for one enumerate request |
ContentsUpdateLatency | Mean latency for one update request |
ContentsEnumerateCeph | Mean Ceph latency for one enumerate request |
ContentsUpdateCeph | Mean Ceph latency for one update request |
data TeleMsgUOM Source
msgTypeUOM :: TeleMsgType -> TeleMsgUOM Source
Map a telemetry message type onto its associated UOM.
ID string associated with a running daemon, so telemetry messages can be associated with the processes which sent them.
Agent IDs are a maximum of 64 bytes.
agentID :: String -> Maybe AgentID Source
An agent ID has to fit in 64 characters and does not contain NUL.
Convenience/clarity
type NumBuckets = Word64 Source