MCPcopy
hub / github.com/grafana/tempo / Read

Method Read

tempodb/backend/cache/cache.go:82–107  ·  view source on GitHub ↗

Read implements backend.RawReader

(ctx context.Context, name string, keypath backend.KeyPath, cacheInfo *backend.CacheInfo)

Source from the content-addressed store, hash-verified

80
81// Read implements backend.RawReader
82func (r *readerWriter) Read(ctx context.Context, name string, keypath backend.KeyPath, cacheInfo *backend.CacheInfo) (io.ReadCloser, int64, error) {
83 var k string
84 cache := r.cacheFor(cacheInfo)
85 if cache != nil {
86 k = key(keypath, name)
87 b, found := cache.FetchKey(ctx, k)
88 if found {
89 return io.NopCloser(bytes.NewReader(b)), int64(len(b)), nil
90 }
91 }
92
93 // previous implemenation always passed false forward for "shouldCache" so we are matching that behavior by passing nil for cacheInfo
94 // todo: reevaluate. should we pass the cacheInfo forward?
95 object, size, err := r.nextReader.Read(ctx, name, keypath, nil)
96 if err != nil {
97 return nil, 0, err
98 }
99 defer object.Close()
100
101 b, err := tempo_io.ReadAllWithEstimate(object, size)
102 if err == nil && cache != nil {
103 store(ctx, cache, cacheInfo.Role, k, b)
104 }
105
106 return io.NopCloser(bytes.NewReader(b)), size, err
107}
108
109// ReadRange implements backend.RawReader
110func (r *readerWriter) ReadRange(ctx context.Context, name string, keypath backend.KeyPath, offset uint64, buffer []byte, cacheInfo *backend.CacheInfo) error {

Callers

nothing calls this directly

Calls 6

cacheForMethod · 0.95
keyFunction · 0.85
storeFunction · 0.70
FetchKeyMethod · 0.65
ReadMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected