Skip to content

Commit 88a0319

Browse files
authored
[adaptive processor] Remove redundant function (#5953)
## Which problem is this PR solving? - The function was a duplicate of another public method ## Description of the changes - Remove the function and redirect callsites to invoke HandleRootSpan instead ## How was this change tested? - CI Signed-off-by: Yuri Shkuro <[email protected]>
1 parent 364832f commit 88a0319

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

cmd/jaeger/internal/processors/adaptivesampling/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (tp *traceProcessor) processTraces(_ context.Context, td ptrace.Traces) (pt
7575
if span.Process == nil {
7676
span.Process = batch.Process
7777
}
78-
adaptive.RecordThroughput(tp.aggregator, span, tp.telset.Logger)
78+
tp.aggregator.HandleRootSpan(span, tp.telset.Logger)
7979
}
8080
}
8181
return td, nil

plugin/sampling/strategyprovider/adaptive/aggregator.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,6 @@ func (a *aggregator) RecordThroughput(service, operation string, samplerType spa
118118
}
119119
}
120120

121-
func RecordThroughput(agg samplingstrategy.Aggregator, span *span_model.Span, logger *zap.Logger) {
122-
// TODO simply checking parentId to determine if a span is a root span is not sufficient. However,
123-
// we can be sure that only a root span will have sampler tags.
124-
if span.ParentSpanID() != span_model.NewSpanID(0) {
125-
return
126-
}
127-
service := span.Process.ServiceName
128-
if service == "" || span.OperationName == "" {
129-
return
130-
}
131-
samplerType, samplerParam := span.GetSamplerParams(logger)
132-
if samplerType == span_model.SamplerTypeUnrecognized {
133-
return
134-
}
135-
agg.RecordThroughput(service, span.OperationName, samplerType, samplerParam)
136-
}
137-
138121
func (a *aggregator) Start() {
139122
a.postAggregator.Start()
140123

plugin/sampling/strategyprovider/adaptive/aggregator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,27 +161,27 @@ func TestRecordThroughputFunc(t *testing.T) {
161161

162162
// Testing non-root span
163163
span := &model.Span{References: []model.SpanRef{{SpanID: model.NewSpanID(1), RefType: model.ChildOf}}}
164-
RecordThroughput(a, span, logger)
164+
a.HandleRootSpan(span, logger)
165165
require.Empty(t, a.(*aggregator).currentThroughput)
166166

167167
// Testing span with service name but no operation
168168
span.References = []model.SpanRef{}
169169
span.Process = &model.Process{
170170
ServiceName: "A",
171171
}
172-
RecordThroughput(a, span, logger)
172+
a.HandleRootSpan(span, logger)
173173
require.Empty(t, a.(*aggregator).currentThroughput)
174174

175175
// Testing span with service name and operation but no probabilistic sampling tags
176176
span.OperationName = "GET"
177-
RecordThroughput(a, span, logger)
177+
a.HandleRootSpan(span, logger)
178178
require.Empty(t, a.(*aggregator).currentThroughput)
179179

180180
// Testing span with service name, operation, and probabilistic sampling tags
181181
span.Tags = model.KeyValues{
182182
model.String("sampler.type", "probabilistic"),
183183
model.String("sampler.param", "0.001"),
184184
}
185-
RecordThroughput(a, span, logger)
185+
a.HandleRootSpan(span, logger)
186186
assert.EqualValues(t, 1, a.(*aggregator).currentThroughput["A"]["GET"].Count)
187187
}

0 commit comments

Comments
 (0)