Skip to content

Commit

Permalink
read two fields for structured metadata even if there is none included
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Welch <[email protected]>
  • Loading branch information
slim-bean committed Dec 13, 2024
1 parent 4abfce5 commit 1a31b1f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/chunks-inspect/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ func parseLokiChunk(chunkHeader *ChunkHeader, r io.Reader) (*LokiChunk, error) {
block.rawData = data[block.dataOffset : block.dataOffset+dataLength]
block.storedChecksum = binary.BigEndian.Uint32(data[block.dataOffset+dataLength : block.dataOffset+dataLength+4])
block.computedChecksum = crc32.Checksum(block.rawData, castagnoliTable)
block.originalData, block.entries, err = parseLokiBlock(compression, block.rawData, structuredMetadataSymbols)
block.originalData, block.entries, err = parseLokiBlock(f, compression, block.rawData, structuredMetadataSymbols)
lokiChunk.blocks = append(lokiChunk.blocks, block)
}

return lokiChunk, nil
}

func parseLokiBlock(compression Encoding, data []byte, symbols []string) ([]byte, []LokiEntry, error) {
func parseLokiBlock(format byte, compression Encoding, data []byte, symbols []string) ([]byte, []LokiEntry, error) {
r, err := compression.readerFn(bytes.NewReader(data))
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -294,7 +294,7 @@ func parseLokiBlock(compression Encoding, data []byte, symbols []string) ([]byte
decompressed = decompressed[lineLength:]

var structuredMetdata []label
if symbols != nil && len(symbols) > 0 {
if format >= chunkFormatV4 {
// The length of the symbols section is encoded first, but we don't really need it here because everything is a Uvarint
// Read it to advance the buffer to the next element.
_, decompressed, err = readUvarint(err, decompressed)
Expand Down

0 comments on commit 1a31b1f

Please sign in to comment.