prometheus/prometheus

promql: option to preserve comments in parser

Aberta

#15.871 aberto em 28 de jan. de 2025

 (3 comentários) (0 reação) (0 responsável)Go (10.408 forks)batch import
component/promqlhelp wantedkind/featurenot-as-easy-as-it-lookspriority/P3

Métricas do repositório

Stars
 (64.042 estrelas)
Métricas de merge de PR
 (Mesclagem média 11d 5h) (118 fundiu PRs em 30d)

Description

Proposal

I have a requirement to analyse and modify promql expressions to enforce some business-specific rules. This is being achieved by parsing to the AST, analysing the tree through traversal, and optionally applying modifications to the AST before rendering it back to a string.

Comments are currently stripped in this process by a hard-coded skip in the parser.

We would like this to be an option somewhere so that we can preserve these comments through the parse->AST->string process, as these comments can contain useful debugging/tracing information provided by the original query issuer.

Guia do colaborador