Skip to content

Commit

Permalink
Sort fields/tags for line protocol payload
Browse files Browse the repository at this point in the history
  • Loading branch information
mneudert committed Aug 16, 2023
1 parent 5771277 commit 2f74cf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v2.3.0-dev

- Enhancements
- Line protocol encoder sorts fields/tags before generating the payload

## v2.2.1 (2023-04-22)

- Bug fixes
Expand Down
2 changes: 2 additions & 0 deletions lib/instream/encoder/line.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ defmodule Instream.Encoder.Line do
defp append_fields(line, %{fields: fields}) do
content =
fields
|> Enum.sort()
|> Enum.reduce([], fn
{_, nil}, acc -> acc
{field, value}, acc -> [[encode_property(field), "=", encode_value(value)], "," | acc]
Expand All @@ -57,6 +58,7 @@ defmodule Instream.Encoder.Line do
defp append_tags(line, %{tags: tags}) do
content =
tags
|> Enum.sort()
|> Enum.reduce([], fn
{_, nil}, acc -> acc
{tag, value}, acc -> [[encode_property(tag), "=", encode_property(value)], "," | acc]
Expand Down

0 comments on commit 2f74cf6

Please sign in to comment.