Skip to content

Commit

Permalink
Enable API
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed May 10, 2023
1 parent 2fc79d6 commit bc1748e
Show file tree
Hide file tree
Showing 7 changed files with 621 additions and 303 deletions.
3 changes: 3 additions & 0 deletions cmd/tempo/app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ func (t *App) initGenerator() (services.Service, error) {
}
t.generator = genSvc

spanStatsHandler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.generator.SpanSummaryHandler))
t.Server.HTTP.Handle(path.Join(api.PathPrefixGenerator, addHTTPAPIPrefix(&t.cfg, api.PathSpanMetrics)), spanStatsHandler)

tempopb.RegisterMetricsGeneratorServer(t.Server.GRPC, t.generator)

return t.generator, nil
Expand Down
2 changes: 1 addition & 1 deletion modules/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,5 @@ func (g *Generator) SpanMetrics(ctx context.Context, req *tempopb.SpanMetricsReq
return nil, err
}

return instance.spanMetrics(ctx, req)
return instance.spanMetricsFromLocalBlocks(ctx, req)
}
3 changes: 1 addition & 2 deletions modules/generator/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ func (i *instance) preprocessSpans(req *tempopb.PushSpansRequest) {
i.updatePushMetrics(size, spanCount, expiredSpanCount)
}

func (i *instance) spanMetrics(ctx context.Context, req *tempopb.SpanMetricsRequest) (resp *tempopb.SpanMetricsResponse, err error) {

func (i *instance) spanMetricsFromLocalBlocks(ctx context.Context, req *tempopb.SpanMetricsRequest) (resp *tempopb.SpanMetricsResponse, err error) {
for _, processor := range i.processors {
switch p := processor.(type) {
case *localblocks.Processor:
Expand Down
3 changes: 3 additions & 0 deletions modules/generator/processor/localblocks/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ func (p *Processor) completeBlock() error {
func (p *Processor) GetMetrics(ctx context.Context, req *tempopb.SpanMetricsRequest) (*tempopb.SpanMetricsResponse, error) {

fetcher := traceql.NewSpansetFetcherWrapper(func(ctx context.Context, req traceql.FetchSpansRequest) (traceql.FetchSpansResponse, error) {
if p.headBlock == nil {
return traceql.FetchSpansResponse{}, fmt.Errorf("head block is nil")
}
return p.headBlock.Fetch(ctx, req, common.DefaultSearchOptions())
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const (
PathSearchTagValues = "/api/search/tag/{" + muxVarTagName + "}/values"
PathEcho = "/api/echo"
PathUsageStats = "/status/usage-stats"
PathSpanSummary = "/api/span-summary"
PathSpanMetrics = "/api/span-metrics"

PathSearchTagValuesV2 = "/api/v2/search/tag/{" + muxVarTagName + "}/values"
PathSearchTagsV2 = "/api/v2/search/tags"
Expand Down
Loading

0 comments on commit bc1748e

Please sign in to comment.