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

[v2][storage] Implement read path for v2 storage interface #6170

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Nov 6, 2024

Which problem is this PR solving?

Description of the changes

  • Implemented the read path for the v2 storage interface. This path currently just wraps a v1 span reader and exposes a static method to access the v1 reader.
  • Change the jaeger query extension to initialize a v2 storage factory and obtain the v1 span reader from it.
  • This will unblock the development of more efficient v2 storage implementations, like ClickHouse.

How was this change tested?

  • Added unit tests for new functionality

Checklist

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.21%. Comparing base (557f149) to head (f4f6cfb).

Files with missing lines Patch % Lines
...md/jaeger/internal/extension/jaegerquery/server.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6170      +/-   ##
==========================================
+ Coverage   96.19%   96.21%   +0.01%     
==========================================
  Files         356      356              
  Lines       20416    20436      +20     
==========================================
+ Hits        19640    19662      +22     
+ Misses        587      585       -2     
  Partials      189      189              
Flag Coverage Δ
badger_v1 8.83% <0.00%> (-0.07%) ⬇️
badger_v2 1.63% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v1-manual 14.73% <0.00%> (-0.11%) ⬇️
cassandra-4.x-v2-auto 1.57% <0.00%> (-0.01%) ⬇️
cassandra-4.x-v2-manual 1.57% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v1-manual 14.73% <0.00%> (-0.11%) ⬇️
cassandra-5.x-v2-auto 1.57% <0.00%> (-0.01%) ⬇️
cassandra-5.x-v2-manual 1.57% <0.00%> (-0.01%) ⬇️
elasticsearch-6.x-v1 18.46% <0.00%> (-0.14%) ⬇️
elasticsearch-7.x-v1 18.54% <0.00%> (-0.15%) ⬇️
elasticsearch-8.x-v1 18.71% <0.00%> (-0.14%) ⬇️
elasticsearch-8.x-v2 1.62% <0.00%> (-0.01%) ⬇️
grpc_v1 10.28% <0.00%> (-0.08%) ⬇️
grpc_v2 7.89% <0.00%> (-0.01%) ⬇️
kafka-v1 8.52% <0.00%> (-0.07%) ⬇️
kafka-v2 1.63% <0.00%> (-0.01%) ⬇️
memory_v2 1.63% <0.00%> (-0.01%) ⬇️
opensearch-1.x-v1 18.59% <0.00%> (-0.14%) ⬇️
opensearch-2.x-v1 18.60% <0.00%> (-0.14%) ⬇️
opensearch-2.x-v2 1.62% <0.00%> (-0.01%) ⬇️
tailsampling-processor 0.45% <0.00%> (-0.01%) ⬇️
unittests 95.12% <94.11%> (+0.01%) ⬆️

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.

@mahadzaryab1 mahadzaryab1 added changelog:bugfix-or-minor-feature changelog:new-feature Change that should be called out as new feature in CHANGELOG and removed changelog:bugfix-or-minor-feature labels Nov 7, 2024
@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review November 7, 2024 01:22
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner November 7, 2024 01:22
@mahadzaryab1 mahadzaryab1 marked this pull request as draft November 10, 2024 20:17
@mahadzaryab1 mahadzaryab1 changed the title [WIP][jaeger-v2][storage] Implement read path for v2 storage interface [jaeger-v2][storage] Implement read path for v2 storage interface Nov 16, 2024
@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review November 16, 2024 17:20
@@ -66,6 +67,7 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
}

spanReader = storageMetrics.NewReadMetricsDecorator(spanReader, queryMetricsFactory)
traceReader := factoryadapter.NewTraceReader(spanReader)
Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Nov 16, 2024

Choose a reason for hiding this comment

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

@yurishkuro should we be getting the trace reader via GetStorageFactoryV2? I wasn't sure if that was sufficient because we decorate the spanreader above. Do we want to create a v2 version of that decorator?

Copy link
Member

Choose a reason for hiding this comment

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

yes, now it should be calling GetStorageFactoryV2. And yes about the decorator. Also, we may want to use otel.MeterProvider in the decorator instead of metrics.Factory (we need to gradually start deprecating metrics.Factory - let's book a ticket for that)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro Changed to call GetStorageFactoryV2. For the deprecation, this is what metrics.Factory currently looks like:

// Factory creates new metrics
type Factory interface {
	Counter(metric Options) Counter
	Timer(metric TimerOptions) Timer
	Gauge(metric Options) Gauge
	Histogram(metric HistogramOptions) Histogram

	// Namespace returns a nested metrics factory.
	Namespace(scope NSOptions) Factory
}

Looking at OTEL's meter, I see it has a counter, gauge, and histogram. I don't see a Timer - what would be the alternative for that? Also, how do we handle the nesting of namespaces?

Copy link
Member

Choose a reason for hiding this comment

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

Are you trying to implement metrics.Factory on top of OTEL MeterProvider? I think it would be great if we could do that, it would minimize our changes across the code base.

Timer doesn't have to be part of the factory API, it can be a util struct done on top of a Histogram - the only difference of timer from Histogram is that its Record() function is strongly typed to Duration.

Name spacing is generally handled by our implementations as a prefix on the metric name, so it would work just the same for OTEL Meter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro Would you able to clarify what you mean by Are you trying to implement metrics.Factory on top of OTEL MeterProvider? I was trying to see if we could remove metrics.Factory and just replace it with OTEL's Meter Provider. Is there a different approach you were thinking of?

Copy link
Member

Choose a reason for hiding this comment

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

I was wrong, we already have internal/metrics/otelmetrics/factory.go

Copy link
Member

Choose a reason for hiding this comment

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

I guess you were simply asking about v2 version of decorator that wraps Storage V2 API - the decorator can still work off our internal pkg/metrics API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sounds good - so do we need to book any work here?

Copy link
Member

Choose a reason for hiding this comment

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

we just need not to drop the metrics for storage - this is related to #6219

if err != nil {
return fmt.Errorf("cannot create span reader: %w", err)
}

spanReader = storageMetrics.NewReadMetricsDecorator(spanReader, queryMetricsFactory)
// TODO: decorate trace reader with metrics
Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Nov 17, 2024

Choose a reason for hiding this comment

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

@yurishkuro How should we do this? The decorator implements spanstore.Reader so if we create a new one that implements spanstore_v2.Reader, it won't work currently since we only ever call the underlying v1 methods. Let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

I would like to defer this if possible - what if we use the existing v1 decorator before creating V2 adapter? I.e. I would wrap the span reader as soon as we get it from the v1 factory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro Do we still want to use GetStorageFactoryV2? If we do, then the tracereader is created from the spanreader there. The other approach would be to just initialize the trace reader here (which is what I was previously doing) using the factoryadapter rather than getting it from the v2 factory. What do you think?

@@ -35,8 +35,12 @@ func (f *Factory) Close(_ context.Context) error {
}

// CreateTraceReader implements spanstore.Factory.
func (*Factory) CreateTraceReader() (spanstore.Reader, error) {
Copy link
Member

Choose a reason for hiding this comment

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

can we move this change to another PR and merge it first?

Copy link
Member

@yurishkuro yurishkuro Nov 18, 2024

Choose a reason for hiding this comment

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

btw this would be a good use case for sapling

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yurishkuro pushed a commit that referenced this pull request Nov 19, 2024
…reader (#6221)

## Which problem is this PR solving?
- Towards #5079 

## Description of the changes
- This PR implements the v2 `spanstore.Reader` interface in the factory
adapter through the `TraceReader`, which is currently just a wrapper
around the v1 `spanstore.Reader`. The `TraceReader` provides a function
`GetV1Reader` that exposes the underlying v1 reader which will be used
in #6170.

## How was this change tested?
- Added unit tests for new functions

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Mahad Zaryab <[email protected]>
@mahadzaryab1 mahadzaryab1 changed the title [jaeger-v2][storage] Implement read path for v2 storage interface [v2][storage] Implement read path for v2 storage interface Nov 30, 2024
@@ -74,17 +74,21 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
Namespace(metrics.NSOptions{Name: "jaeger"}).
Namespace(metrics.NSOptions{Name: "query"})

f, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesPrimary, host)
v1Factory, err := jaegerstorage.GetStorageFactory(s.config.Storage.TracesPrimary, host)
Copy link
Member

Choose a reason for hiding this comment

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

add a comment why v1 is still needed (because of dependencies)

}

depReader, err := f.CreateDependencyReader()
depReader, err := v1Factory.CreateDependencyReader()
Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to create storage_v2/depstore/ before continuing, so that we don't have to keep this bifurcation?

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

a refactoring suggestion:

  • storage_v/spanstore -> storage_v/tracestore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/storage changelog:new-feature Change that should be called out as new feature in CHANGELOG v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants