Skip to content

Commit

Permalink
Breadcrumbs for generator to serve a span summary
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Leslie <[email protected]>
  • Loading branch information
zalegrala committed May 3, 2023
1 parent be68ed9 commit a599b13
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/generator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
// MetricsIngestionSlack is the max amount of time passed since a span's start time
// for the span to be considered in metrics generation
MetricsIngestionSlack time.Duration `yaml:"metrics_ingestion_time_range_slack"`
SummaryTimeout time.Duration `yaml:"summary_timeout"`
}

// RegisterFlagsAndApplyDefaults registers the flags.
Expand Down
14 changes: 14 additions & 0 deletions modules/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,17 @@ func (g *Generator) OnRingInstanceStopping(lifecycler *ring.BasicLifecycler) {
// OnRingInstanceHeartbeat implements ring.BasicLifecyclerDelegate
func (g *Generator) OnRingInstanceHeartbeat(lifecycler *ring.BasicLifecycler, ringDesc *ring.Desc, instanceDesc *ring.InstanceDesc) {
}

func (q *Generator) SpanSummary(ctx context.Context, req *tempopb.SpanSummaryRequest) (*tempopb.SpanSummaryResponse, error) {
instanceID, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, err
}

instance, err := q.getOrCreateInstance(instanceID)
if err != nil {
return nil, err
}

return instance.spanSummary(ctx, req)
}
16 changes: 16 additions & 0 deletions modules/generator/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,22 @@ func (i *instance) preprocessSpans(req *tempopb.PushSpansRequest) {
i.updatePushMetrics(size, spanCount, expiredSpanCount)
}

func (i *instance) spanSummary(ctx context.Context, req *tempopb.SpanSummaryRequest) (resp *tempopb.SpanSummaryResponse, err error) {
select {
case <-ctx.Done():
return nil, nil
// case i.spanSummaryCh <- req:
default:
// for _, processor := range i.processors {
// switch p := processor.(type) {
// case *localblocks.Processor:
// processor.GetMetrics(ctx, req)
// }
// }
return nil, fmt.Errorf("not implemented yet")
}
}

func (i *instance) updatePushMetrics(bytesIngested int, spanCount int, expiredSpanCount int) {
metricBytesIngested.WithLabelValues(i.instanceID).Add(float64(bytesIngested))
metricSpansIngested.WithLabelValues(i.instanceID).Add(float64(spanCount))
Expand Down

0 comments on commit a599b13

Please sign in to comment.