-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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] Add dependency store to v2 storage interface #6297
Conversation
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
@yurishkuro Where should we add the
Let me know what you think and if you have any other ideas. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6297 +/- ##
==========================================
+ Coverage 96.11% 96.14% +0.02%
==========================================
Files 356 356
Lines 20476 20489 +13
==========================================
+ Hits 19681 19699 +18
+ Misses 607 603 -4
+ Partials 188 187 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I like option 3. We always had a split brain on dependencies, it was defined in a different package but part of the same factory interface. +1 to move to a different interface. |
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
@@ -74,7 +73,7 @@ func GetMetricStorageFactory(name string, host component.Host) (storage.MetricSt | |||
return mf, nil | |||
} | |||
|
|||
func GetStorageFactoryV2(name string, host component.Host) (tracestore.Factory, error) { | |||
func GetStorageFactoryV2(name string, host component.Host) (*factoryadapter.Factory, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know about this - adapter is implementation detail, this function should not leak it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurishkuro I was trying to follow's Go's best practice here of returning structs instead of interfaces. If we want to keep the interface return, we'll need to define another function GetDependencyStoreFactory
with a different return type (depstore.Reader
) but it will do the exact same thing. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not the best practice in this case. The return-struct best practice applies to constructors. GetStorageFactoryV2
is not a constructor, it's an accessor that is supposed to return a storage interface. The caller of this function is not supposed to know about the implementation of that interface and accordingly should not be able to take dependency on the concrete returned type, which could be wider than the interface alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - so should we have two accessors here (something like GetTraceStoreFactory
and GetDependencyStoreFactory
)? Their return types would be different but the implementations would be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we should. Implementations are only the same today, not in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me! done
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
df, err := jaegerstorage.GetDependencyStoreFactory(s.config.Storage.TracesPrimary, host) | ||
if err != nil { | ||
return fmt.Errorf("cannot find factory for dependency storage %s: %w", s.config.Storage.TracesPrimary, err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurishkuro is this okay? we're using the traces storage to initialize the dependency storage factory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok for now
@@ -114,7 +114,7 @@ by default uses only in-memory database.`, | |||
if err != nil { | |||
logger.Fatal("Failed to create span writer", zap.Error(err)) | |||
} | |||
dependencyReader, err := storageFactory.CreateDependencyReader() | |||
dependencyReader, err := v2Factory.CreateDependencyReader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurishkuro for v1, the factory adapter is created directly so we have direct access to this function - is this okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
cmd/query/app/grpc_handler_test.go
Outdated
@@ -511,10 +512,13 @@ func TestGetDependenciesSuccessGRPC(t *testing.T) { | |||
withServerAndClient(t, func(server *grpcServer, client *grpcClient) { | |||
expectedDependencies := []model.DependencyLink{{Parent: "killer", Child: "queen", CallCount: 12}} | |||
endTs := time.Now().UTC() | |||
expectedEndTs := endTs.Add(time.Duration(-1) * defaultDependencyLookbackDuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is expectedEndTs offset from endTs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be called startTs perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, does Add(-defaultDependencyLookbackDuration)
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurishkuro Its a bit weird because here startTime is passed into endTs (https://github.com/jaegertracing/jaeger/blob/main/cmd/query/app/grpc_handler.go#L226). Do you know why that is? I thought it would be passed the endTs and then the lookback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like a bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened a patch at #6324
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yurishkuro should be good to go now
Signed-off-by: Mahad Zaryab <[email protected]>
return getV2FactoryAdapter(name, host) | ||
} | ||
|
||
func GetDependencyStoreFactory(name string, host component.Host) (depstore.Factory, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been looking at missing test coverage and realized that it's hard to get error coverage for this code path. We have this Extension API:
type Extension interface {
extension.Extension
TraceStorageFactory(name string) (storage.Factory, bool)
MetricStorageFactory(name string) (storage.MetricStoreFactory, bool)
}
Shouldn't it be exposing v2 factory instead of v1? And either it should have deps-related method OR there shouldn't be a static function for deps and instead it should be a runtime interface check, as we discussed on the ticket.
Maybe this is transitional? I actually don't like that the adapter is being applied by the static functions - I think the right way would be to have the extension itself expose v2 API (instead of v1 API - we could get to v1 via downgreading, if needed).
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Which problem is this PR solving?
Description of the changes
depstore
package for the DependencyReader and exposes aCreateDependencyReader
function in thefactoryadapter
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test