summaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/prometheus/prometheus_decoder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* label size extensionivantsvetkov14 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | **Было:** Prometheus decoder ограничивает длину значений меток метрик максимум 256 символами. Попытка передать метрику с более длинным значением метки приводит к исключению `TPrometheusDecodeException`. **Стало:** Максимальная длина значения метки расширена до 1024 символов. Системы, которые генерируют метрики с более длинными значениями (например, с ID источников данных, URL, или сложных идентификаторов), теперь могут успешно передавать такие метрики в Unified Agent без ошибок. **Практический эффект:** Улучшение совместимости с внешними системами мониторинга и приложениями, которые требуют передачи длинных меток. Существующие системы с метками < 256 символов продолжают работать без изменений. --- ## С точки зрения разработчика ### Структурные изменения Расширение требовало изменения способа хранения длины строки в пуле коротких строк: 1. **Prometheus decoder** (library/cpp/monlib): - `MAX_LABEL_VALUE_LEN`: 256 → 1024 2. **Short string pool** (logbroker/unified_agent/common): - `MaxLabelSize`: 255 → 1024 - **Ключевое изменение:** Размер строки теперь хранится как `ui16` (2 байта) вместо `unsigned char` (1 байт) - Было: `*slot->Payload() = static_cast<unsigned char>(s.size())` - Стало: `memcpy(slot->Payload(), &size, sizeof(ui16))` - Это позволяет хранить строки до 65535 символов (но логически ограничено на уровне валидации) ### Изменённые файлы | Файл | Основные изменения | |------|------------------| | `prometheus_decoder.cpp` | `MAX_LABEL_VALUE_LEN: 256 → 1024` | | `prometheus_decoder_ut.cpp` | +2 юнит-теста для новых граничных значений | | `short_string_pool.h` | `MaxLabelSize: 255 → 1024`, operator[] использует ui16 для чтения размера | | `short_string_pool.cpp` | Allocation и copy логика адаптирована для ui16 | ### Тестирование Добавлены два новых юнит-теста: - **LabelValueAtNewLimitIsAccepted:** Метрика с меткой ровно 1023 символа успешно парсится ``` "m{l=\"" + string(1023, 'a') + "\"} 1\n" ``` - **LabelValueOverNewLimitStillThrows:** Метрика с меткой ≥1024 символов выбрасывает исключение ``` "m{l=\"" + string(1024, 'a') + "\"} 1\n" // → TPrometheusDecodeException: "trying to parse too long label value, size >= 1024" ``` ### Безопасность и совместимость - ✅ Обратно совместимо: строки < 256 символов работают так же - ✅ Валидация: лимит 1024 проверяется на уровне Ref() в пуле - ✅ Граничные случаи: добавлены тесты для 1023 и 1024 символов - ✅ Выделение памяти: правильно рассчитано с учётом новых 2 байт для размера - ✅ Я не нашел ситуации когда закодированная строка (длина + строка) улетала куда-то из пула и потом пыталась раскодироваться. Так что считаю, что миграции никакой не надо и все обратно совместимо. НАДЕЮСЬ Я НЕ ОШИБАЮСЬ commit_hash:b30852954951bd8e65d69777a59ffeb58da76b47
* [cpp/monlib] add ability to mangle name in prometheus decodervvminashkin2026-03-021-5/+18
| | | | commit_hash:ef6584bf0941f50d0833dacd3b5d14cfc1cd30a8
* Fix prometheus nan parsingalexnadtochiy2025-12-121-1/+1
| | | | commit_hash:ea34eba995ae4c386785fe89df58c439a2e3ea63
* Remove Size, Empty and Data usages from librarymikhnenko2024-10-041-2/+2
| | | | commit_hash:ef5ad4cfa9e68bbfc586492e8c376c732d0a48af
* manage prometheusaleksei-le2024-03-191-10/+18
| | | | a543f08a6f2957757c54b3f9e5a095389a51dbeb
* fix prometheus_decoder ConsumeCounteraleksei-le2024-02-061-4/+6
|
* allow multiple equal TYPE in prom metricsvalerybitsoev2023-11-231-2/+4
|
* Y_VERIFY_DEBUG->Y_DEBUG_ABORT_UNLESS at '-v ydb'ilnurkh2023-10-161-4/+4
| | | | https://clubs.at.yandex-team.ru/arcadia/29404
* metrics input: compress number hist bucketsaleksei-le2023-07-131-1/+1
|
* Restoring authorship annotation for <[email protected]>. Commit 2 of 2.rorewillo2022-02-101-1/+1
|
* Restoring authorship annotation for <[email protected]>. Commit 1 of 2.rorewillo2022-02-101-1/+1
|
* Restoring authorship annotation for <[email protected]>. Commit 2 of 2.ivanzhukov2022-02-101-6/+6
|
* Restoring authorship annotation for <[email protected]>. Commit 1 of 2.ivanzhukov2022-02-101-6/+6
|
* Restoring authorship annotation for <[email protected]>. Commit 2 of 2.msherbakov2022-02-101-27/+27
|
* Restoring authorship annotation for <[email protected]>. Commit 1 of 2.msherbakov2022-02-101-27/+27
|
* Restoring authorship annotation for <[email protected]>. Commit 2 of 2.tobo2022-02-101-5/+5
|
* Restoring authorship annotation for <[email protected]>. Commit 1 of 2.tobo2022-02-101-5/+5
|
* Restoring authorship annotation for <[email protected]>. Commit 2 of 2.gusev-p2022-02-101-8/+8
|
* Restoring authorship annotation for <[email protected]>. Commit 1 of 2.gusev-p2022-02-101-8/+8
|
* Restoring authorship annotation for Sergey Polovko <[email protected]>. ↵Sergey Polovko2022-02-101-548/+548
| | | | Commit 2 of 2.
* Restoring authorship annotation for Sergey Polovko <[email protected]>. ↵Sergey Polovko2022-02-101-548/+548
| | | | Commit 1 of 2.
* Restoring authorship annotation for <[email protected]>. Commit 2 of 2.thegeorg2022-02-101-2/+2
|
* Restoring authorship annotation for <[email protected]>. Commit 1 of 2.thegeorg2022-02-101-2/+2
|
* intermediate changesDevtools Arcadia2022-02-071-0/+597
ref:cde9a383711a11544ce7e107a78147fb96cc4029