Closed gobengo closed 2 years ago
{ duration }
as well as { startTime, endTime }
https://github.com/elastic-ipfs/metrics-collector/issues/34IndexerCompleted#indexing.endTime
, only send startTime
(ISO8601, mostly useful for sorting/human-reading) and duration
(nanosecond units, powers prometheus metrics, etc){ endTime }
(only accept { startTime, duration }
)Can we just get some reasons why we need nanosecond precision?
@alanshaw we don't definitely need nanoseconds duration. happy to drop that. It still feels ideal to send an indexing duration
instead of startTime/endTime pair. At the same time.... if we dont need to change it then we dont need to change it. i.e. maybe this isn't strictly needed for 'mvp'.
@alanshaw should I
duration
?
duration
but use milliseconds precision instead of nanoseconds
I'm flexible either way.
One thing:
It makes calculating the duration complicated in javascript. ... Anyone receiving the event and dealing with it in javascript (like, wanting to do any calculations) has a harder time than if it's milliseconds.
Is it? const durationNs = BigInt(event.indexing.duration.value)
vs const durationMs = Date.parse(event.indexing.endTime) - Date.parse(event.indexing.startTime))
One thing:
It makes calculating the duration complicated in javascript. ... Anyone receiving the event and dealing with it in javascript (like, wanting to do any calculations) has a harder time than if it's milliseconds.
Is it?
const durationNs = BigInt(event.indexing.duration.value)
vsconst durationMs = Date.parse(event.indexing.endTime) - Date.parse(event.indexing.startTime))
* the latter is more characters/logic and less precision. neither is that hard to parse in JS
Not in that case I guess. I think I was angling for duration to be in ms. If it's nanoseconds it's just a bit more difficult to do time maths with because Date
is all in ms. You have to convert to bigints and remember how many zeros in a nanosecond and how to convert between.
@alanshaw and I discussed and we're going to just pause this issue for now and focus on some other priorities. The IndexerCompleted events in elastic-ipfs/indexer-lambda are event.indexing.duration
nanoseconds in addition to event.indexing.{startTime,endTime}
ISO8601 strings. More than enough info. It's not as important that metrics-collector uses duration
ns instead of endTime - startTime
ms
because JSON + ISO8601 can't express nanosecond durations https://nickb.dev/blog/iso8601-and-nanosecond-precision-across-languages/
And
duration
is 1) what we really care about in metrics-collector 2) what we actually have available at time of emitting IndexerCompleted 3) capable of expressing more precise measurement than previousstartTime
,endTime
ISO8601 schemePlan
.indexing.{ startTime, endTime }
properties with only anindexing.duration
that expresses the value in nanoseconds.BigInt(string)
with nanoseconds semantics