Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[adaptive processor] Remove redundant function #5953

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (tp *traceProcessor) processTraces(_ context.Context, td ptrace.Traces) (pt
if span.Process == nil {
span.Process = batch.Process
}
adaptive.RecordThroughput(tp.aggregator, span, tp.telset.Logger)
tp.aggregator.HandleRootSpan(span, tp.telset.Logger)
}
}
return td, nil
Expand Down
17 changes: 0 additions & 17 deletions plugin/sampling/strategyprovider/adaptive/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,6 @@ func (a *aggregator) RecordThroughput(service, operation string, samplerType spa
}
}

func RecordThroughput(agg samplingstrategy.Aggregator, span *span_model.Span, logger *zap.Logger) {
// TODO simply checking parentId to determine if a span is a root span is not sufficient. However,
// we can be sure that only a root span will have sampler tags.
if span.ParentSpanID() != span_model.NewSpanID(0) {
return
}
service := span.Process.ServiceName
if service == "" || span.OperationName == "" {
return
}
samplerType, samplerParam := span.GetSamplerParams(logger)
if samplerType == span_model.SamplerTypeUnrecognized {
return
}
agg.RecordThroughput(service, span.OperationName, samplerType, samplerParam)
}

func (a *aggregator) Start() {
a.postAggregator.Start()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,27 @@ func TestRecordThroughputFunc(t *testing.T) {

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

// Testing span with service name but no operation
span.References = []model.SpanRef{}
span.Process = &model.Process{
ServiceName: "A",
}
RecordThroughput(a, span, logger)
a.HandleRootSpan(span, logger)
require.Empty(t, a.(*aggregator).currentThroughput)

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

// Testing span with service name, operation, and probabilistic sampling tags
span.Tags = model.KeyValues{
model.String("sampler.type", "probabilistic"),
model.String("sampler.param", "0.001"),
}
RecordThroughput(a, span, logger)
a.HandleRootSpan(span, logger)
assert.EqualValues(t, 1, a.(*aggregator).currentThroughput["A"]["GET"].Count)
}
Loading