Set and check (and document) a global label_value_length_limit (and potentially label_name_length_limit) based on Prometheus issue #16525. Currently, Prometheus defaults to no limit (0) for these settings. However, due to the encoding of the Labels data structure, a label name or value longer than 16MB will cause Prometheus to crash. The goal is to set a safe default limit globally and check this limit before constructing the Labels data structure in the scrape loop, as well as checking it in other relevant areas like the remote-write receiver, label_replace, and label_join.
Warning
Changing the default limits will be a breaking change for any users currently relying on extremely large labels (which is an anti-pattern but still possible). We need to decide on the default global limit. The issue discussion suggests 1MB or 200 bytes. I am proposing 2048 bytes as a safe, practical default.