exsentry v0.3.0 ExSentry.Utils

Various utility functions that don’t fit anywhere else. Not intended for end users.

Summary

Functions

Given a list of {headername, value} tuples, returns a map of %{headername => merged_values} pairs suitable for inclusion in a Sentry “Http” object as headers

Merges two maps of tags, returning a JSON-compatible structure like [ [tag1, value1], [tag2, value2], ... ]. Allows duplicates

Returns a copy of map with all nil values (and their keys) removed

Returns the number of seconds since the Unix epoch

Returns the string-formatted version of the given app

Returns a map of {app: version} pairs

Functions

merge_http_headers(headers)

Specs

merge_http_headers([{String.t, String.t}]) :: map

Given a list of {headername, value} tuples, returns a map of %{headername => merged_values} pairs suitable for inclusion in a Sentry “Http” object as headers.

iex> headers = [{"header1", "value1"}, {"header2", "value2"}, {"header1", "value3"}]
iex> headers |> ExSentry.Utils.merge_http_headers
%{"header1" => "value1, value3", "header2" => "value2"}
merge_tags(global_tags, tags)

Specs

merge_tags(map, map) :: [[{:atom, any}]]

Merges two maps of tags, returning a JSON-compatible structure like [ [tag1, value1], [tag2, value2], ... ]. Allows duplicates.

iex> t1 = %{a: 1, b: 2}
iex> t2 = %{a: 3}
iex> ExSentry.Utils.merge_tags(t1, t2)
[[:a, 1], [:b, 2], [:a, 3]]
strip_nils_from_map(map)

Specs

strip_nils_from_map(map) :: map

Returns a copy of map with all nil values (and their keys) removed.

iex> %{a: 1, b: nil, c: 3} |> ExSentry.Utils.strip_nils_from_map
%{a: 1, c: 3}
unixtime()

Specs

unixtime :: integer

Returns the number of seconds since the Unix epoch.

version(app \\ :exsentry)

Specs

version(atom) :: String.t

Returns the string-formatted version of the given app.

versions()

Specs

versions :: map

Returns a map of {app: version} pairs.