Thank you very much for taking a look, Brian. I think that's a very good 
perspective, so I will definitely make some changes keeping all that in 
mind.

BoolToBinary really only exists the way it does due to how Grafana's value 
mapping works. But with some of the transformations added in 7.0, perhaps I 
will just stop doing things that way.

On Monday, August 24, 2020 at 8:28:36 AM UTC-4 
[email protected] wrote:

> On Sat, 22 Aug 2020 at 22:18, Jacob Colvin <[email protected]> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/413005b4-c85b-477f-b37e-a54871a6f849n%40googlegroups.com.

Reply via email to