View Source Datadog.DataStreams.Tags (Data Streams Ex v1.1.2)
A helper module to enumerate and filter over data stream tags.
Link to this section Summary
Types
An encoded list of tags. This is the format that Datadog expects when we send
data. It's a list of key value binary joined via :
. For example:
"partition:1", "group:some-consumer-group", "topic:a-topic".
All allowed tag input types. This could be any one of the following examples
The type all tags are internally mapped to.
Functions
Tags a list of tags and converts them to a list of binary tags. This is the format that Datadog expects. This also orders the tags to ensure it matches other languages when hashing.
Filters a list of tags to a known list of allowed tags. This varies based on the context of where it is used.
Parses any type of tag input and normalizes it to our internal t:t
type.
Note this will also filter out invalid data like nil values.
Link to this section Types
@type encoded() :: [binary()]
An encoded list of tags. This is the format that Datadog expects when we send
data. It's a list of key value binary joined via :
. For example:
"partition:1", "group:some-consumer-group", "topic:a-topic".
@type input() :: [{binary() | atom(), binary()}] | %{required(binary() | atom()) => binary()} | [binary()]
All allowed tag input types. This could be any one of the following examples:
[{:key, "value"}, {:key_two, "value_two"}]
[{"key", "value"}, {"key_two", "value_two"}]
%{key: "value", key_two: "value_two"}
%{"key" => "value", "key_two" => "value_two"}
["key:value", "key_two:value_two"]
The type all tags are internally mapped to.
Link to this section Functions
Tags a list of tags and converts them to a list of binary tags. This is the format that Datadog expects. This also orders the tags to ensure it matches other languages when hashing.
examples
Examples
iex> Tags.encode([{"tag_two", "value_two"}, {"tag", "value"}])
["tag:value", "tag_two:value_two"]
Filters a list of tags to a known list of allowed tags. This varies based on the context of where it is used.
examples
Examples
iex> [{"key", "value"}, {"topic", "one"}, {"key_two", "value_two"}]
...> |> Tags.filter(:hash)
[{"topic", "one"}]
Parses any type of tag input and normalizes it to our internal t:t
type.
Note this will also filter out invalid data like nil values.
examples
Examples
iex> [{:key, "value"}, {:key_two, "value_two"}]
...> |> Tags.parse()
[{"key", "value"}, {"key_two", "value_two"}]
iex> [{"key", "value"}, {"key_two", "value_two"}]
...> |> Tags.parse()
[{"key", "value"}, {"key_two", "value_two"}]
iex> %{key: "value", key_two: "value_two"}
...> |> Tags.parse()
[{"key", "value"}, {"key_two", "value_two"}]
iex> %{"key" => "value", "key_two" => "value_two"}
...> |> Tags.parse()
[{"key", "value"}, {"key_two", "value_two"}]
iex> ["key:value", "key_two:value_two"]
...> |> Tags.parse()
[{"key", "value"}, {"key_two", "value_two"}]
iex> [{"key", nil}, {"key_two", "value_two"}]
...> |> Tags.parse()
[{"key_two", "value_two"}]