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

Move span.GetSamplerParams out of model/ into sampling/aggregator #6583

Merged
merged 5 commits into from
Jan 21, 2025

Conversation

Nabil-Salah
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Separate model files into more independent pieces that are easier to move to jaeger-idl

How was this change tested?

  • go test ./model/
  • go test ./internal/sampling/samplingstrategy/adaptive/

Checklist

@Nabil-Salah Nabil-Salah changed the title fix: delegate some of span model parts into aggregator Delegate some of span model parts into aggregator Jan 21, 2025
@Nabil-Salah Nabil-Salah marked this pull request as ready for review January 21, 2025 19:07
@Nabil-Salah Nabil-Salah requested a review from a team as a code owner January 21, 2025 19:07
@Nabil-Salah Nabil-Salah requested a review from jkowall January 21, 2025 19:07
@@ -150,9 +151,42 @@ func (a *aggregator) HandleRootSpan(span *span_model.Span, logger *zap.Logger) {
if service == "" || span.OperationName == "" {
return
}
samplerType, samplerParam := span.GetSamplerParams(logger)
samplerType, samplerParam := GetSamplerParams(span, logger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not need to be public

Suggested change
samplerType, samplerParam := GetSamplerParams(span, logger)
samplerType, samplerParam := getSamplerParams(span, logger)

The aggregator already has access to logger, no need to pass it, if you make the function have a receiver

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean by using aggregator.postAggregator.logger ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean a.getSamplerParams(span) (a method, not a function)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i understand this but i mean where is the logger function to use in this method?

the only logger in struct aggregator is in a.postAggregator.logger logger

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok. Never mind then. This is a weird design that needs a cleanup externally - there's no reason for the caller of HandleRootSpan to be passing a logger.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just make the function private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I booked #6584

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (22952b8) to head (318132b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6583   +/-   ##
=======================================
  Coverage   96.23%   96.23%           
=======================================
  Files         375      375           
  Lines       21389    21389           
=======================================
  Hits        20583    20583           
  Misses        614      614           
  Partials      192      192           
Flag Coverage Δ
badger_v1 10.68% <ø> (+0.02%) ⬆️
badger_v2 2.78% <ø> (+<0.01%) ⬆️
cassandra-4.x-v1-manual 16.65% <ø> (+0.04%) ⬆️
cassandra-4.x-v2-auto 2.72% <ø> (+<0.01%) ⬆️
cassandra-4.x-v2-manual 2.72% <ø> (+<0.01%) ⬆️
cassandra-5.x-v1-manual 16.65% <ø> (+0.04%) ⬆️
cassandra-5.x-v2-auto 2.72% <ø> (+<0.01%) ⬆️
cassandra-5.x-v2-manual 2.72% <ø> (+<0.01%) ⬆️
elasticsearch-6.x-v1 20.45% <ø> (+0.06%) ⬆️
elasticsearch-7.x-v1 20.53% <ø> (+0.05%) ⬆️
elasticsearch-8.x-v1 20.69% <ø> (+0.06%) ⬆️
elasticsearch-8.x-v2 2.78% <ø> (+0.01%) ⬆️
grpc_v1 12.21% <ø> (+0.03%) ⬆️
grpc_v2 9.05% <ø> (+0.01%) ⬆️
kafka-3.x-v1 10.36% <ø> (+0.02%) ⬆️
kafka-3.x-v2 2.78% <ø> (+<0.01%) ⬆️
memory_v2 2.78% <ø> (+<0.01%) ⬆️
opensearch-1.x-v1 20.56% <ø> (+0.04%) ⬆️
opensearch-2.x-v1 20.56% <ø> (+0.04%) ⬆️
opensearch-2.x-v2 2.78% <ø> (+0.01%) ⬆️
tailsampling-processor 0.51% <ø> (+<0.01%) ⬆️
unittests 95.08% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -335,123 +332,3 @@ func BenchmarkBatchSerialization(b *testing.B) {
}
})
}

func TestGetSamplerParams(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the test to aggregator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by making it private it can't be tested alone but it's test will be part of HandleRootSpan test as it already uses it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the test is in the same package it has access to private functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okaay you can merge code for this #6584 issue

and I will rebase and push changes

Signed-off-by: nabil salah <nabil.salah203@gmail.com>
Signed-off-by: nabil salah <nabil.salah203@gmail.com>
Signed-off-by: nabil salah <nabil.salah203@gmail.com>
Signed-off-by: nabil salah <nabil.salah203@gmail.com>
@yurishkuro yurishkuro changed the title Delegate some of span model parts into aggregator Move span.GetSamplerParams out of model/ into sampling/aggregator Jan 21, 2025
@yurishkuro yurishkuro enabled auto-merge (squash) January 21, 2025 21:33
@yurishkuro yurishkuro merged commit f6c4be1 into jaegertracing:main Jan 21, 2025
55 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants