On Sat, 22 Aug 2020 at 22:18, Jacob Colvin <jacobcolv...@gmail.com> wrote:

> Hello Prometheus Developers,
>
> I recently created my first exporter in Go, wakatime_exporter, which
> basically just converts data from the Wakatime API into the Prometheus
> exposition format.
>
> https://github.com/MacroPower/wakatime_exporter
>
> I've been running it for a few weeks now and am happy with the results.
> But, I'm sure there are a lot of things I could have done better,
> specifically in terms of the design of the exporter. My code is all based
> on the HAProxy exporter, but my changes have been significant enough that
> it doesn't very closely resemble it anymore.
>
> If any of you have time, I would greatly appreciate any feedback you might
> have.
>



> But, to give one thing I'm specifically concerned about: I feel like there
> is just too much duplication in my code. I separated my exporter into
> different modules for each Wakatime endpoint, because I had seen similar
> architecture in other exporters (and I think it generally makes sense for a
> number of other reasons). But the result is each modules' NewExporter,
> Collect, and Describe functions being nearly identical to each other. Does
> anyone know any way I could solve this?
>

Lots of duplication isn't uncommon, exporters often involve doing lots of
repetitive data munging. Trying to generalise it is likely to make the code
more complicated for no real gain in maintenance terms. I'd aim for
understandable code over the fewest lines of code.

For example the ExportMetric and NewWakaMetric functions add indirection
that only make the code harder to understand for me, as I now have to jump
across several files to figure out what's actually being exposed.
BoolToBinary is also odd, bools should be gauges rather than label values
usually.


-- 
Brian Brazil
www.robustperception.io

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/CAHJKeLp5mP2DdWrN_cpKTxtsqaO11hiud%2B8M3eqG412sOD5QeQ%40mail.gmail.com.

Reply via email to