mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Update proto for v1 backend * Functioning blocklist with new package * Functioning blocklist with existing package * Generate proto to existing package * Add wrapper around google UUID for proto marshaling * Update blocklist for wrapper type * Test WriteTenantIndex * Implement json for uuid * Almost functional backend tests * Passing backend tests * Improve UUID coverage and utility * TempoDB updates for UUID and struct type changes * Update method style for uuid.New() * Update method style for uuid.MustParse() * Add uuid.From helper * Update modules for UUID and proto struct types * Update poller integration test for UUID * Update tempo-cli for UUID and proto struct type changes * Lint and clean up * Fix serverless * Fix cli * Fix cli * Add fixture tests for roundtrip assurance between versions * Clean up notes from proto definition * Update backend/test * Be more specific about unmarshal UUID * Include event for compacted block * Use better json tag for compacted meta * Implement UnmarshalJson on CompcatedBlockMeta for embedded struct * Test for CompactedMeta marshal/unmarshal * Drop benchmark index * Clean commented code * Extend mocks to capture multiple writes * Update backend/test fixtures * Write both proto and json to the backend for all three files in all backends * Fix lint * Back UUID with google.UUID to avoid struct * Relocate pkg/uuid to tempodb/backend * Re-plumb UUID through tempodb * Re-plumb UUID through cmd * Re-plumb UUID through modules * Re-plumb UUID through integration/ * Drop package spec from tempo.proto * Improve encoding marshal performance * Drop block proto and tenantindex json * Drop additional proto include * Implement zstd tenant index compression * Add note about use of json in the dedicatedcolumns * Fix ingester local block * Spell * Revert mock update * Drop json fallback from tenantindex read * Replace single-tenant test fixtures * Update fixture replacement test * Improve error handling and fix test * Extend test for tenantindex round-trip * Small fixes * Revert "Drop json fallback from tenantindex read" This reverts commit 834ff5b85d8a8a4d7eb560fbb67ba8f3a5a3959a. * Add back mocks to capture multiple backend writes * Add back proto & json writitng/reading for tenantindex * Change TotalObjects type from int32 -> int64 The original change was int -> int32, which on 64bit machines is a downgrade that I overlooked. Raising here to int64 to maintain the size. * Store write buffer at object path in mocks to improve readability in tests * Avoid allocation in interface validation * Update note to include intern * Pluralize metas and compacted_metas fields * Fallback to json only on ErrDoesNotExist * Lint * Drop debug * Revert "Pluralize metas and compacted_metas fields" This reverts commit 46a8c36e37ac33e1ffc104287d898930e02cdd97. * Import original tenantindex and test contents for backwards compatibility * Update changelog
85 lines
2.3 KiB
Go
85 lines
2.3 KiB
Go
package backend
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/grafana/tempo/pkg/util"
|
|
)
|
|
|
|
// ContextReader is an io.ReaderAt interface that passes context. It is used to simplify access to backend objects
|
|
// and abstract away the name/meta and other details so that the data can be accessed directly and simply
|
|
type ContextReader interface {
|
|
ReadAt(ctx context.Context, p []byte, off int64) (int, error)
|
|
ReadAll(ctx context.Context) ([]byte, error)
|
|
|
|
// Return an io.Reader representing the underlying. May not be supported by all implementations
|
|
Reader() (io.Reader, error)
|
|
}
|
|
|
|
// backendReader is a shim that allows a backend.Reader to be used as a ContextReader
|
|
type backendReader struct {
|
|
meta *BlockMeta
|
|
name string
|
|
r Reader
|
|
}
|
|
|
|
// NewContextReader creates a ReaderAt for the given BlockMeta
|
|
func NewContextReader(meta *BlockMeta, name string, r Reader) ContextReader {
|
|
return &backendReader{
|
|
meta: meta,
|
|
name: name,
|
|
r: r,
|
|
}
|
|
}
|
|
|
|
// ReadAt implements ContextReader
|
|
func (b *backendReader) ReadAt(ctx context.Context, p []byte, off int64) (int, error) {
|
|
err := b.r.ReadRange(ctx, b.name, (uuid.UUID)(b.meta.BlockID), b.meta.TenantID, uint64(off), p, nil)
|
|
return len(p), err
|
|
}
|
|
|
|
// ReadAll implements ContextReader
|
|
func (b *backendReader) ReadAll(ctx context.Context) ([]byte, error) {
|
|
return b.r.Read(ctx, b.name, (uuid.UUID)(b.meta.BlockID), b.meta.TenantID, nil)
|
|
}
|
|
|
|
// Reader implements ContextReader
|
|
func (b *backendReader) Reader() (io.Reader, error) {
|
|
return nil, util.ErrUnsupported
|
|
}
|
|
|
|
// AllReader is an interface that supports both io.Reader and io.ReaderAt methods
|
|
type AllReader interface {
|
|
io.Reader
|
|
io.ReaderAt
|
|
}
|
|
|
|
// allReader wraps an AllReader and implements backend.ContextReader
|
|
type allReader struct {
|
|
r AllReader
|
|
}
|
|
|
|
// NewContextReaderWithAllReader wraps a normal ReaderAt and drops the context
|
|
func NewContextReaderWithAllReader(r AllReader) ContextReader {
|
|
return &allReader{
|
|
r: r,
|
|
}
|
|
}
|
|
|
|
// ReadAt implements ContextReader
|
|
func (r *allReader) ReadAt(_ context.Context, p []byte, off int64) (int, error) {
|
|
return r.r.ReadAt(p, off)
|
|
}
|
|
|
|
// ReadAll implements ContextReader
|
|
func (r *allReader) ReadAll(_ context.Context) ([]byte, error) {
|
|
return io.ReadAll(r.r)
|
|
}
|
|
|
|
// Reader implements ContextReader
|
|
func (r *allReader) Reader() (io.Reader, error) {
|
|
return r.r, nil
|
|
}
|