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

[storage] Remove usages of jaegerstorage.GetStorageFactory #6624

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ary82
Copy link
Contributor

@ary82 ary82 commented Jan 27, 2025

Which problem is this PR solving?

Description of the changes

  • Implement storage_v1 interfaces Purger and SamplingStoreFactor in v1_adapter

How was this change tested?

  • make test

Checklist

@ary82
Copy link
Contributor Author

ary82 commented Jan 27, 2025

Thought of writing a draft PR to help move this issue forward, Hope that's okay?

I read a bit through the v2 proposal and the parent issue. From what I understand, we want to change jaegerstorage.GetStorageFactory to jaegerstorage.GetTraceStoreFactory, which provides the v2 Factory through the storage v1adapter, and implement storage.Purger and storage.SamplingStoreFactory in v1adapter.Factory. We should be able to do this by defining the required methods and casting the v1 Factory to the necessary interfaces and calling their methods. For example, for Purger, in v1adapter/factory:

func (f *Factory) Purge(ctx context.Context) error {
  p, ok := f.ss.(storage_v1.Purger)
  if !ok {
  // storage backend doesn't implement Purger
  }
  err := p.Purge(ctx)
  return err
}

Am I on the right path?

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 27 lines in your changes missing coverage. Please review.

Project coverage is 95.78%. Comparing base (4ac036b) to head (d3bcf8d).

Files with missing lines Patch % Lines
storage_v2/v1adapter/factory.go 0.00% 21 Missing ⚠️
...ger/internal/extension/remotesampling/extension.go 14.28% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6624      +/-   ##
==========================================
- Coverage   95.93%   95.78%   -0.16%     
==========================================
  Files         365      365              
  Lines       20616    20637      +21     
==========================================
- Hits        19778    19767      -11     
- Misses        638      667      +29     
- Partials      200      203       +3     
Flag Coverage Δ
badger_v1 9.90% <0.00%> (-0.03%) ⬇️
badger_v2 1.84% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v1-manual 14.90% <0.00%> (-0.04%) ⬇️
cassandra-4.x-v2-auto 1.83% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v2-manual 1.83% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v1-manual 14.90% <0.00%> (-0.04%) ⬇️
cassandra-5.x-v2-auto 1.83% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v2-manual 1.83% <0.00%> (-0.01%) ⬇️
elasticsearch-6.x-v1 19.26% <0.00%> (-0.05%) ⬇️
elasticsearch-7.x-v1 19.34% <0.00%> (-0.05%) ⬇️
elasticsearch-8.x-v1 19.52% <0.00%> (-0.05%) ⬇️
elasticsearch-8.x-v2 1.84% <0.00%> (-0.01%) ⬇️
grpc_v1 10.87% <0.00%> (-0.03%) ⬇️
grpc_v2 7.87% <0.00%> (-0.02%) ⬇️
kafka-3.x-v1 10.19% <0.00%> (-0.03%) ⬇️
kafka-3.x-v2 1.84% <0.00%> (-0.01%) ⬇️
memory_v2 1.84% <0.00%> (-0.01%) ⬇️
opensearch-1.x-v1 19.39% <0.00%> (-0.05%) ⬇️
opensearch-2.x-v1 19.39% <0.00%> (-0.05%) ⬇️
opensearch-2.x-v2 1.84% <0.00%> (-0.01%) ⬇️
tailsampling-processor 0.48% <0.00%> (-0.01%) ⬇️
unittests 94.66% <25.00%> (-0.15%) ⬇️

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.

@yurishkuro
Copy link
Member

If a PR claims to resolve "Remove usages ..." issue then I expect the actual GetStorageFactory method to be removed as well

@ary82
Copy link
Contributor Author

ary82 commented Jan 28, 2025

I wanted to validate my understanding for this issue first i.e., if implementing storage_v1 interfaces in the v1 factory adapter is the correct approach.
I'll be removing GetStorageFactory function and adding tests shortly

Edit: GetStorageFactory is still used in the v2 factory provider jaegerstorage.GetTraceStoreFactory over the v1_adapter. Should we instead make it an internal function, or directly move its code to GetTraceStoreFactory?

@@ -61,3 +64,33 @@ func (f *Factory) CreateDependencyReader() (depstore.Reader, error) {
}
return NewDependencyReader(dr), nil
}

// CreateLock implements storage_v1.SamplingStoreFactory
func (f *Factory) CreateLock() (distributedlock.Lock, error) {
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 Jan 28, 2025

Choose a reason for hiding this comment

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

@yurishkuro This approach works but there's a slight change in behaviour. Consider the following:

  • Before this PR, if a storage didn't implement the storage.SamplingStoreFactory - it would fail here
  • As a result of the changes PR, the check I linked above will always pass but it would fail in the following check here

I don't see a huge downside to doing it this way except maybe a slightly different/confusing error message. We could mitigate that by returning a specific error here that we check for upstream and return the same error message as before. What do you think? The other approach would be to only construct the factory adapter based on the interfaces the underlying factory implements.

Copy link
Member

Choose a reason for hiding this comment

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

As long as we fail during startup, as opposed to later when processing incoming data, it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could mitigate that by returning a specific error here that we check for upstream and return the same error message as before

I've changed the error checking to something along the lines of this. Please have a look.

@@ -55,7 +56,11 @@ func (c *storageCleaner) Start(_ context.Context, host component.Host) error {
if !ok {
return fmt.Errorf("storage %s does not implement Purger interface", c.config.TraceStorage)
}
if err := purger.Purge(httpContext); err != nil {
err = purger.Purge(httpContext)
if errors.Is(err, v1adapter.ErrPurgerNotImplemented) {
Copy link
Member

Choose a reason for hiding this comment

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

it doesn't make sense to be checking an error from v1adapter here. We need storage_v2 APIs to be self-sufficient. I would recommend moving Sampling/Lock/Purger APIs to storage_v2 and replacing them with type aliases in v1 storage (it should be a separate PR before this one).

Copy link
Contributor Author

@ary82 ary82 Jan 30, 2025

Choose a reason for hiding this comment

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

I'm a bit confused, wouldn't we still need to check for the casting error in the adapter to return an error like storage %s does not implement Purger interface with the correct storage_name that is used?

I would recommend moving Sampling/Lock/Purger APIs to storage_v2 and replacing them with type aliases in v1 storage (it should be a separate PR before this one)

Should each of these APIs be in a different module in storage_v2, in a similar way DependencyStore has been moved to storage_v2/depstore? Or should they be defined in the storage_v2/tracestore? What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove usages of GetStorageFactory
3 participants