Skip to content

Commit

Permalink
fix(remotewrite2): do not send uninitialized garbage if there's no me…
Browse files Browse the repository at this point in the history
…tadata

Found during testing for
grafana/mimir#9072

Debug printout showed:
KRAJO: seriesName=cortex_request_duration_seconds_bucket,
metricFamily=cortex_request_duration_seconds_bucket,
type=GAUGE,
help=cortex_bucket_index_load_duration_seconds_sum,
unit=

which is nonsense.

I can imagine more cases where this is the case and makes actual sense.
Some targets might miss metadata and if there's a pipeline that loses it.

Signed-off-by: György Krajcsovits <[email protected]>
  • Loading branch information
krajorama authored and Vandit1604 committed Jan 16, 2025
1 parent 829c2b9 commit e02237f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion storage/remote/queue_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1919,12 +1919,17 @@ func populateV2TimeSeries(symbolTable *writev2.SymbolsTable, batch []timeSeries,
var nPendingSamples, nPendingExemplars, nPendingHistograms, nPendingMetadata int
for nPending, d := range batch {
pendingData[nPending].Samples = pendingData[nPending].Samples[:0]
// todo: should we also safeguard against empty metadata here?
if d.metadata != nil {
pendingData[nPending].Metadata.Type = writev2.FromMetadataType(d.metadata.Type)
pendingData[nPending].Metadata.HelpRef = symbolTable.Symbolize(d.metadata.Help)
pendingData[nPending].Metadata.UnitRef = symbolTable.Symbolize(d.metadata.Unit)
nPendingMetadata++
} else {
// Safeguard against sending garbage in case of not having metadata
// for whatever reason.
pendingData[nPending].Metadata.Type = writev2.Metadata_METRIC_TYPE_UNSPECIFIED
pendingData[nPending].Metadata.HelpRef = symbolTable.Symbolize("")
pendingData[nPending].Metadata.UnitRef = symbolTable.Symbolize("")
}

if sendExemplars {
Expand Down

0 comments on commit e02237f

Please sign in to comment.