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][metrics] Implement decorator to wrap storage.Factory #6267

Closed
wants to merge 12 commits into from

Conversation

mahadzaryab1
Copy link
Collaborator

Which problem is this PR solving?

Description of the changes

How was this change tested?

  • Unit tests

Checklist

storage/decorator.go Outdated Show resolved Hide resolved
Signed-off-by: Mahad Zaryab <[email protected]>
storage/decorator.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.44%. Comparing base (76593a6) to head (e29e5db).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6267      +/-   ##
==========================================
+ Coverage   96.41%   96.44%   +0.02%     
==========================================
  Files         355      356       +1     
  Lines       20152    20170      +18     
==========================================
+ Hits        19430    19453      +23     
+ Misses        532      528       -4     
+ Partials      190      189       -1     
Flag Coverage Δ
badger_v1 8.31% <ø> (ø)
badger_v2 1.67% <ø> (ø)
cassandra-4.x-v1 14.39% <ø> (ø)
cassandra-4.x-v2 1.61% <ø> (ø)
cassandra-5.x-v1 14.39% <ø> (ø)
cassandra-5.x-v2 1.61% <ø> (ø)
elasticsearch-6.x-v1 18.61% <ø> (ø)
elasticsearch-7.x-v1 18.69% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v1 18.86% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v2 1.66% <ø> (-0.01%) ⬇️
grpc_v1 9.44% <ø> (ø)
grpc_v2 6.98% <ø> (-0.01%) ⬇️
kafka-v1 8.87% <ø> (ø)
kafka-v2 1.67% <ø> (ø)
memory_v2 1.67% <ø> (ø)
opensearch-1.x-v1 18.74% <ø> (ø)
opensearch-2.x-v1 18.73% <ø> (-0.01%) ⬇️
opensearch-2.x-v2 1.67% <ø> (ø)
tailsampling-processor 0.46% <ø> (ø)
unittests 95.35% <100.00%> (+0.02%) ⬆️

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.

@@ -60,14 +60,13 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
if err != nil {
return fmt.Errorf("cannot find primary storage %s: %w", s.config.Storage.TracesPrimary, err)
}
f = storagemetrics.NewDecoratorFactory(f, baseFactory)
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 this is will take in a baseFactory which will have the query namespace and then the decorator will add the query namespace. Just wanted to confirm that this is what we want? Note that the queryMetricsFactory is still being passed in when creating the server.

Copy link
Member

Choose a reason for hiding this comment

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

we don't want query namespace twice. Perhaps we don't want it at all - why is it query and not storage?

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 It was query before which is why I tried to leave it the same. Do we want to change it to storage given that this is only for v2?

Copy link
Member

Choose a reason for hiding this comment

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

yes, if we can do that without affecting v1

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 I changed the decorator factory to namespace with storage and left queryMetricsFactory as is. Let me know what you think.

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review November 28, 2024 18:49
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner November 28, 2024 18:49
@dosubot dosubot bot added the area/storage label Nov 28, 2024
@mahadzaryab1 mahadzaryab1 changed the title [WIP][storage][metrics] Implement decorator to wrap storage.Factory [storage][metrics] Implement decorator to wrap storage.Factory Nov 28, 2024
@@ -60,14 +60,13 @@ func (s *server) Start(ctx context.Context, host component.Host) error {
if err != nil {
return fmt.Errorf("cannot find primary storage %s: %w", s.config.Storage.TracesPrimary, err)
}
f = storagemetrics.NewDecoratorFactory(f, baseFactory)
Copy link
Member

Choose a reason for hiding this comment

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

Why do you apply the decorator in jaegerquery extension? I would do it in the storage extension, and attach a label storage_kind={name}

Comment on lines +51 to +56
func (df *DecoratorFactory) Close() error {
if closer, ok := df.delegate.(io.Closer); ok {
return closer.Close()
}
return nil
}
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 I moved the decorator to the storage extension but it also requires the Close function. Is it fine to implement it here like this?

Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Nov 29, 2024

Choose a reason for hiding this comment

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

It also looks like some tests are failing because some other interfaces aren't implemented here (sampling store, purger, etc.). Do we want to continue with this approach? It looks like we're losing some important information by wrapping this decorator in the extension

metrics.NSOptions{
Name: "storage",
Tags: map[string]string{
"kind": storageName,
Copy link
Member

Choose a reason for hiding this comment

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

"kind" should be something like "cassandra" (which you can save from the switch statement above.

Suggested change
"kind": storageName,
"name": storageName,
"kind": storageKind,

metricsFactory metrics.Factory
}

func NewDecoratorFactory(f storage.Factory, mf metrics.Factory) *DecoratorFactory {
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 add a comment describing what this does. I would also mention that the metrics namespace is used as is, without enrichment, and it's the caller responsibility to define a desired namespace.

@mahadzaryab1
Copy link
Collaborator Author

Going to take a different approach of decorating the span reader within the storage factories

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