swift-server / swift-prometheus

Prometheus client library for Swift

Home Page:https://swiftpackageindex.com/swift-server/swift-prometheus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird collect()-ed formatting, breaking collection

ktoso opened this issue · comments

I'm seeing errors in in collecting metrics using prom.collect(String)

Steps to reproduce

Can't share exact code but will work on reproducer, so far tried to reproduce in tests here but failed, something seems weird.

I got a counter, with some labels and a gauge; Exactly like in the snippet below.

Expected behavior

Scraping should not break.

Actual behavior


# TYPE thingy counter
thingy 0
thingy{a="aaa", b="x"} 9
thingy{a="bbb", b="x"} 6# TYPE my_gauge gauge
my_gauge 0.0

So the thingy{a="bbb", b="x"} 6# TYPE my_gauge gauge is missing a newline and this breaks scraping:

level=warn ts=2019-09-27T08:39:48.356Z caller=scrape.go:930 component="scrape manager" scrape_pool=local target=http://127.0.0.1:8888/metrics msg="append failed" err="strconv.ParseFloat: parsing \"6#\": invalid syntax"

Environment

  • Framework version: master branch right now; 05eed57

I'm serving this with NIO directly:

        prom.collect { (buf: ByteBuffer) in
            //...
            context.write(self.wrapOutboundOut(.body(.byteBuffer(buf))))

So pretty sure I've had no chance to break this somehow manually.

Which milestone should I assign this to @MrLotU ? Tickets should be assigned to a milestone that will become the next released version so we can track what was fixed when :)

What’s the milestone to assign this to @MrLotU ?

Oh, sorry. Missed this question. Would be 1.0.0 :)

Nice, thx 👍

For now I'll depend on master branch until we ship that 1.0 then 👍