rlopzc

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:

  1. Validate the configuration in the Logger backend init callback and if a required config variable is missing return {:error, :ignore} so the backend is not added to the logger backends.
  2. 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.

  1. What’s the best way to handle a required configuration for the library to work?
  2. Is this the correct way to accept library config variables?
  3. What do you think of the readme?

Thanks for the feedback!

Most Liked

rlopzc

rlopzc

Bumping it to see if someone has a guide/opinion on the lib config part

Thanks!

Where Next?

Popular in Announcing Top

Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have ...
New
maltoe
Hello! Came here to announce ChromicPDF, a pet project PDF generator I’ve been working on for the past few months. Why another PDF gener...
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
sbs
Only 650 LOC, wrote for fun :slight_smile: https://github.com/sunboshan/qrcode
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Thank...
New
alisinabh
Hey everyone i’ve developed a library for Jalaali calendar for elixir which supports converting Gregorian dates to Jalaali and vice vers...
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement