Parsing errors in the Prometheus HTTP format parser are very hard to
investigate since they only approximately indicate what is going wrong
in the parser and don't provide any information about the incorrect
input. As such it is very hard to tell what is wrong in the format
exposed by the application.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
Rather than removing the previous implementation of SanitizeLabelName,
offer another version named SanitizeFullLabelName that achieved the
desired requirements, without breaking existing Prometheus code.
Update testing to validate correctness of new variant.
Signed-off-by: Nick Moore <nicholas.moore@grafana.com>
SanitizeLabelName was not correctly sanitizing label names that:
1. Started with a digit (0-9)
2. Were empty
This commit changes the santization code to catch both of these edge
cases and adds new tests to validate it works correctly in them both. In
the first case, a leading digit will be replaced with an underscore, and
in the latter, the function will return a single underscore.
Signed-off-by: Nick Moore <nicholas.moore@grafana.com>
As far as I understand it, we'd never expect to receive a nil span,
and remote.spansProtoToSpans would panic if we received a nil span.
Marking the fields as non-nullable also means the generated Golang
code doesn't use pointers for these fields, reducing allocations.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Export single ith test histogram generation functions
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
* Do not set counter reset hint for non-gauge histograms individually
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
* Apply suggestions from code review
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
---------
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
* Add initial sketch of Codec interface.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Introduce JSON codec.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Expose Response type so that consuming applications (eg. Mimir) can implement their own Codecs.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add sketch of what supporting different codecs could look like.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Rename fallbackCodec to defaultCodec.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Remove defaultCodec as a field on API.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Rename AddCodec() and clarify expected behaviour.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Modify TestRespond to test JsonCodec directly.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Refactor existing respond() test in preparation for content negotiation test cases.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add tests for content negotiation.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add missing documentation comments.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Add another test case.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Rename JsonCodec to JSONCodec.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Fix linting issue.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Fallback to JSON codec if no acceptable codec can be found for the Accept header.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Move custom jsoniter code into json_codec.go.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
---------
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* Correct statement in docs about query results returning either floats or histograms but not both.
* Move documentation for range and instant vectors under their corresponding headings.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
* tsdb: make sharding function a parameter
Instead of relying on `labels.Hash()`, which may change, have the
caller pass in a shard function if required.
For most purposes `tsdb.Options.ShardFunc` is used, but the compactor
may be created independently so `NewLeveledCompactorWithChunkSize` also
takes a shard function parameter.
Regular Prometheus, which does not use block sharding, will have this
parameter as nil.
Rename WithCache functions as WithOptions
Where they now have 2 or more extra parameters.
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>