Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ft: TCP adaptor #2067

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

ft: TCP adaptor #2067

wants to merge 1 commit into from

Conversation

hauleth
Copy link
Contributor

@hauleth hauleth commented May 11, 2024

No description provided.

@hauleth hauleth force-pushed the ft/tcp-backend branch 2 times, most recently from e7ece77 to e94d475 Compare May 28, 2024 12:16
@hauleth hauleth force-pushed the ft/tcp-backend branch 5 times, most recently from 389a5f7 to efc3721 Compare June 11, 2024 12:30
@hauleth hauleth marked this pull request as ready for review June 14, 2024 07:25
]

# TODO: Add support for non-transparent framing
[to_string(IO.iodata_length(msg)), ?\s, msg]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently only octet-counting framing is implemented as I have no idea how to do nested configuration there. Non-transparent framing (with newline endings) is simple to implement, as all that is needed is simply removing byte count and space.

end

defp header(%LogEvent{} = le, options) do
level = to_level(le.body["level"] || le.body["metadata"]["level"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not have an idea how to extract level from log event in better way. So I am open to having better solution there.


defp header(%LogEvent{} = le, options) do
level = to_level(le.body["level"] || le.body["metadata"]["level"])
facility = options[:facility] || 16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facility is currently not configurable, but honestly I do not know if there is much need for that.


ingested_at = DateTime.from_naive!(le.ingested_at, "Etc/UTC")

id = Ecto.UUID.dump!(le.id) |> Base.encode32(case: :lower, padding: false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of 32 characters limit I decided to encode UUIDs with Base32. Theoretically we could just remove - (dashes) from canonical representation, but I think that this approach is effective enough as well as it reduces amount of data that needs to be transferred.

Comment on lines +42 to +43
# XXX: Unknown hostname?
" -",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left hostname field undefined, though if someone has proposal what could be in this field, then I am open to filling it.

Comment on lines +13 to +14
# TODO: Change it to real value
@pen 62137
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be updated as soon as Supabase or Logflare will have assigned Private Enterprise Number from IANA.

defp structured_data(%LogEvent{} = le, _options) do
[
"[source@#{@pen} name=#{inspect(le.source.name)} id=\"#{le.source.id}\"]"
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are more metadata informations that should be available there, then I am open to suggestions.

@@ -42,6 +42,15 @@ Mimic.copy(ExTwilio.Message)
Mimic.stub(Goth)
Mimic.stub(Finch)

ExUnit.configure(exclude: [integration: true, failing: true, benchmark: true])
has_telegraf? = not is_nil(System.find_executable("telegraf"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Telegraf is currently not installed on CI, so we will automatically skip these tests. There are some GitHub Actions to install it, but I didn't know what are the policies around adding 3rd party actions, so I have left it for the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant