Add support to `write_to_textfile` for custom tmpdir by aadityadhruv · Pull Request #1115 · prometheus/client_python

@aadityadhruv

While the try/except block does prevent most of the temp files from
persisting, if there is a non catchable exception, those temp files
continue to pollute the directory. Optionally set the temp
directory would let us write to something like /tmp, so the target
directory isn't polluted

Signed-off-by: Aaditya Dhruv <aadityadhruv@mailbox.org>

csmarchbanks

@aadityadhruv

The tmpdir must be on the same filesystem to ensure an atomic operation
takes place. If this is not enforced, there could be partial writes
which can lead to partial/incorrect metrics being exported

Signed-off-by: Aaditya Dhruv <aadityadhruv@mailbox.org>

csmarchbanks