rlopzc
LoggerExporter - Export your logs to Grafana Loki or other external services
Hello!
I build a LoggerExporter for elixir/phoenix. I’m on Heroku and there is no easy way to export your logs to a different logging service of the current options.
I haven’t published the library yet, here is the repo: GitHub - rlopzc/logger_exporter: Export your logs to the service of your choice. · GitHub all the info is in the readme and I still need to write documentation for Hex.pm.
I export logs to Grafana Loki using the http endpoint.
I couldn’t find good documentation on how to build a library and what decisions to make. I have some questions and I’ll be grateful if someone points me in the right direction / gives me feedback.
There are 3 main components in this library:
- Logger backend
- Batcher
- HTTP Client
The Logger backend sends the formatted events to the Batcher. The Batcher enqueues the events and sends it to the HTTP client every 2 seconds.
My question about the current implementation:
If the host part of the configuration is missing, the http client fails because an error is raised here, the exception is propagated to the Batcher GenEvent here and it pollutes the logs with the same error over an over.
The exception is logged as an error, so the same process is repeated: Logger backend → Batcher → Http client → exception → Logger backend. I have thought of these solutions:
- Validate the configuration in the Logger backend
initcallback and if a required config variable is missing return{:error, :ignore}so the backend is not added to the logger backends. - Do not raise that a config is missing and skip the http call (not my favorite)
Same question is for the config variables that raise: app_name and environment_name.
- What’s the best way to handle a required configuration for the library to work?
- Is this the correct way to accept library config variables?
- What do you think of the readme?
Thanks for the feedback!
Most Liked
rlopzc
Bumping it to see if someone has a guide/opinion on the lib config part
Thanks!
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









