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

Function NewWeightRequestWare

modules/frontend/pipeline/async_weight_middleware.go:51–67  ·  view source on GitHub ↗

It returns a new weight request middleware

(rt RequestType, cfg WeightsConfig)

Source from the content-addressed store, hash-verified

49
50// It returns a new weight request middleware
51func NewWeightRequestWare(rt RequestType, cfg WeightsConfig) AsyncMiddleware[combiner.PipelineResponse] {
52 weights := Weights{
53 DefaultWeight: 1,
54 TraceQLSearchWeight: 1,
55 TraceByIDWeight: 2,
56 MaxTraceQLConditions: cfg.MaxTraceQLConditions,
57 MaxRegexConditions: cfg.MaxRegexConditions,
58 }
59 return AsyncMiddlewareFunc[combiner.PipelineResponse](func(next AsyncRoundTripper[combiner.PipelineResponse]) AsyncRoundTripper[combiner.PipelineResponse] {
60 return &weightRequestWare{
61 requestType: rt,
62 enabled: cfg.RequestWithWeights,
63 weights: weights,
64 next: next,
65 }
66 })
67}
68
69func (c weightRequestWare) RoundTrip(req Request) (Responses[combiner.PipelineResponse], error) {
70 c.setWeight(req)

Calls

no outgoing calls