riemann.common

Utility functions. Time/date, some flow control constructs, protocol buffer definitions and codecs, some vector set ops, etc.

approx-equal

(approx-equal x y)(approx-equal x y tol)

Returns true if x and y are roughly equal, such that x/y is within tol of unity.

body

(body events)

Constructs a message body for a set of events.

count-character-bytes

(count-character-bytes c)

count-string-bytes

(count-string-bytes s)

custom-attributes

(custom-attributes event)

Returns a Map of the custom attributes of an Event.

decode-inputstream

(decode-inputstream s)

Decode an InputStream to a message. Decodes the protobuf representation of Msg and applies post-load-event to all events.

decode-msg

(decode-msg msg)

Decode a protobuf to a message. Decodes the protocol buffer representation of Msg and applies post-load-event to all events.

deprecated

macro

(deprecated comment & body)

Wraps body in an implicit (do), and logs a deprecation notice when invoked.

deprecations-emitted

disjoint?

(disjoint? a b)

Do a and b (any seqables) have no elements in common?

encode

(encode msg)

Builds and dumps a protobuf message as bytes from a hash.

ensure-event-time

(ensure-event-time e)

Ensures an event has a timestamp.

event

(event opts)

Create a new event from a map.

event-to-json

(event-to-json event)

Convert an event to a JSON string.

exception->event

(exception->event exception)(exception->event e original)

Creates an event from an Exception.

expire

(expire event)

An expired version of an event.

get-hostname

(get-hostname [age val])

Fetches the hostname by shelling out to hostname (1), whenever the given age is stale enough. If the given age is recent, as defined by hostname-refresh-interval, returns age and val instead.

hostname-refresh-interval

How often to allow shelling out to hostname (1), in seconds.

human-uniq

(human-uniq things type)

Returns a human-readable string describing things, e.g.

importer api1, api2, api4 23 services

iso8601->unix

(iso8601->unix iso8601)

Transforms ISO8601 strings to unix timestamps.

localhost

(localhost)

Returns the local host name.

map-matches?

(map-matches? pat obj)

Does the given map pattern match obj?

Match

protocol

members

match

(match pred object)

Does predicate describe object?

member?

(member? r s)

Is r present in seqable s?

middle

(middle s)

Takes the element at the middle of a seq.

overlap?

(overlap? a b)

Do a and b (any seqables) have any elements in common?

pkey

(pkey event)

Primary key for an event.

post-load-event

(post-load-event e)

After events are loaded, we assign default times if none exist.

re-matches?

(re-matches? re string)

Does the given regex match string? Nil if string is nil.

subject

(subject events)

Constructs a subject line for a set of events.

subset?

(subset? required s)

Are all elements of required present in seqable s?

time-at

(time-at unix-time)

Returns the Date of a unix epoch time.

truncate

(truncate s n)

truncate-bytes

(truncate-bytes s n)

unix-to-iso8601

(unix-to-iso8601 unix)

Transforms unix time to iso8601 string