XDCR metrics for wtavg_docs_latency

I have question regarding this metrics wtavg_docs_latency. Why is it weighted average? How is it calculated internally? Is this the number in millisecond that a document takes to replicate to remote cluster

https://github.com/couchbase/goxdcr/blob/master/service_def/statsMgrIface.go#L78
https://github.com/couchbase/goxdcr/blob/master/service_def/statsMgrIface.go#L275

wtavg_docs_latency appears to be a rolling average (maybe it was meant to be a weighted average at one time).
“The rolling average amount of time it takes for the source cluster to receive the acknowledgement of a SET_WITH_META response after the Memcached request has been composed to be processed by the XDCR outnozzle”

So, the number (in milliseconds) measures the time starting at when the document is put into the outNozzle queue (on the source) to be sent to the target, to the actual acknowledgement from the setWithMeta() command on the target that the document has been written successfully. It includes the time when the document is in the XDCR sending queue, so it’s technically not a pure measurement of network latency. It’s a roundtrip number – XDCR (on the source) issues setWithMeta() for the target, then waits for it to come back from the target with a success.

Hi Hyun
Thanks for the response. So, this is a rolling average of what numbers. Can you please clarify that

Thanks

XDCR’s sample size by default is 1000.
Rolling average means it keeps track of a window of the last 1000 numbers.
Each number represents what Hyun-Ju has already described, essentially the time in millisecond. Her explanation is on point. Each number essentially tells you how long it takes when XDCR is essentially ready send a document and to hear back from the target.
Once each mutation is sent, we take that number and it becomes one number of the 1000 rolling average sample. The oldest sample is considered irrelevant and discarded out of the rolling window.

Thanks a lot, i now understand this completely