prom-client icon indicating copy to clipboard operation
prom-client copied to clipboard

Support Bigint

Open firasdib opened this issue 5 years ago • 14 comments

Add support for BigInt so we can use high resolution timers and values.

firasdib avatar May 13 '19 07:05 firasdib

PR very much welcome!

Ref https://github.com/siimon/prom-client/pull/223#issuecomment-440979376

SimenB avatar May 13 '19 08:05 SimenB

@SimenB Supporting versions prior to bigint would make the code quite tedious, I reckon. If we can limit ourselves to node >=10, it'd be easier. Then we can just change the internal representation to bigint everywhere, and send it as a string to prometheus.

firasdib avatar May 13 '19 10:05 firasdib

Nah, just check typeof BigInt when serialising (to strip trailing n, isn't that enough? Dropping node 8 is not really an option

SimenB avatar May 13 '19 10:05 SimenB

@SimenB There's a few Number.isFinite here and there as well. I'd recommend keeping the library lean, without too many ifs and typeofs that'll take up valuable time in the event loop.

firasdib avatar May 13 '19 10:05 firasdib

I'll be impressed if you can measure time spent on an if in anything but a synthetic microbenchmark :) That's not really an issue

SimenB avatar May 13 '19 10:05 SimenB

@SimenB Perhaps. I'd still argue that the correct path is to bump the major version number, and work entirely with bigint instead.

firasdib avatar May 13 '19 11:05 firasdib

That's not gonna happen until next year, 8 is LTS and there's not big benefit to dropping it early. When we do drop it we can probably rewrite to use BigInt all over

SimenB avatar May 13 '19 11:05 SimenB

Yeah, we need to support all current official node versions.

siimon avatar May 14 '19 16:05 siimon

Node 10 is LTS now, It's time to use BigInt by default in this client. We can transform Number to BigInt for compatible.

popomore avatar Oct 31 '19 13:10 popomore

Node 8 is also LTS and does not support BigInt. It'll be EOL in January 2020 though, at which point we can revisit

SimenB avatar Nov 01 '19 09:11 SimenB

Is there any news on this matter? I want to set a gauge value with a high value and I'm limited to the size of number on JS, I need to use a BigInt or other representation to hold this value

mario-sangar avatar May 12 '21 15:05 mario-sangar

Boarding the bandwagon :eyes:

drozdziak1 avatar Mar 22 '22 12:03 drozdziak1

PR welcome - our current minimum node version is 10 👍

SimenB avatar Mar 22 '22 14:03 SimenB

lol bump

eL1x00r avatar Feb 05 '24 09:02 eL1x00r