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

Method AppendTrace

modules/blockbuilder/tenant_store.go:81–102  ·  view source on GitHub ↗
(traceID []byte, tr []byte, ts time.Time)

Source from the content-addressed store, hash-verified

79}
80
81func (s *tenantStore) AppendTrace(traceID []byte, tr []byte, ts time.Time) error {
82 maxSz := s.overrides.MaxBytesPerTrace(s.tenantID)
83
84 if err := s.liveTraces.PushWithTimestampAndLimits(ts, traceID, tr, 0, uint64(maxSz)); err != nil {
85 // Record dropped spans due to trace too large
86 // We have to unmarhal to count the number of spans.
87 // TODO - There might be a better way
88 t := &tempopb.Trace{}
89 if err := t.Unmarshal(tr); err != nil {
90 return err
91 }
92 count := 0
93 for _, b := range t.ResourceSpans {
94 for _, ss := range b.ScopeSpans {
95 count += len(ss.Spans)
96 }
97 }
98 overrides.RecordDiscardedSpans(count, overrides.ReasonTraceTooLarge, s.tenantID)
99 }
100
101 return nil
102}
103
104func (s *tenantStore) Flush(ctx context.Context, r tempodb.Reader, w tempodb.Writer, c tempodb.Compactor) error {
105 ctx, span := tracer.Start(ctx, "tenantStore.Flush", trace.WithAttributes(attribute.String("tenant", s.tenantID)))

Callers

nothing calls this directly

Calls 4

UnmarshalMethod · 0.95
RecordDiscardedSpansFunction · 0.92
MaxBytesPerTraceMethod · 0.65

Tested by

no test coverage detected