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] Move span reader decorator to storage factories #6280

Merged
merged 22 commits into from
Nov 30, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Nov 29, 2024

Which problem is this PR solving?

Description of the changes

  • This PR moves the decoration of the span readers with the metrics factory to inside the storage factory itself rather than handling it a higher level (ex. all-in-one, query server/extension).
  • For v2, the namespacing of the metrics has been moved from the query extension to the storage extension.
  • For v1, the namespacing of the metrics has been moved from the various binaries to the storage meta-factory.
  • This PR contains a few breaking changes as it changes the namespace under which the following metrics are published:
    • Storage specific metrics were that were being pushed under jaeger_query to will now be pushed undder jaeger_storage
    • Cassandra specific metrics were pushed under jaeger_cassandra and jaeger_cassandra-archive will now be pushed under jaeger_storage with the following tags:
      • kind=cassandra
      • role=primary or role=archive
      • name with the name of the storage (in jaeger-v2 only)
    • ElasticSearch/OpenSearch specific metrics were being pushed under jaeger_index_create will now be pushed under jaeger_storage_index_create with the following tags:
      • kind=elasticsearch/kind=opensearch
      • role=primary or role=archive
      • name with the name of the storage (in jaeger-v2 only)

How was this change tested?

Checklist

@mahadzaryab1 mahadzaryab1 added the changelog:breaking-change Change that is breaking public APIs or established behavior label Nov 29, 2024
@mahadzaryab1
Copy link
Collaborator Author

@yurishkuro The decorator is also used for the metrics reader (https://github.com/jaegertracing/jaeger/blob/main/cmd/jaeger/internal/extension/jaegerquery/server.go#L165). Do you have any thoughts on how we should handle this? This one is a bit different because the underlying MetricsFactory does not accept metrics.Factory at the moment.

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 93.70629% with 9 lines in your changes missing coverage. Please review.

Project coverage is 96.22%. Comparing base (e9fac05) to head (d0319f1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
plugin/storage/cassandra/factory.go 81.81% 4 Missing and 2 partials ⚠️
plugin/storage/es/factory.go 90.32% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6280      +/-   ##
==========================================
+ Coverage   96.20%   96.22%   +0.01%     
==========================================
  Files         356      356              
  Lines       20303    20416     +113     
==========================================
+ Hits        19533    19645     +112     
  Misses        583      583              
- Partials      187      188       +1     
Flag Coverage Δ
badger_v1 8.90% <2.80%> (+0.78%) ⬆️
badger_v2 1.63% <0.00%> (-0.02%) ⬇️
cassandra-4.x-v1-manual 14.84% <25.23%> (+0.55%) ⬆️
cassandra-4.x-v2-auto 1.57% <0.00%> (-0.02%) ⬇️
cassandra-4.x-v2-manual 1.57% <0.00%> (-0.02%) ⬇️
cassandra-5.x-v1-manual 14.84% <25.23%> (+0.55%) ⬆️
cassandra-5.x-v2-auto 1.57% <0.00%> (-0.02%) ⬇️
cassandra-5.x-v2-manual 1.57% <0.00%> (-0.02%) ⬇️
elasticsearch-6.x-v1 18.59% <19.62%> (+0.45%) ⬆️
elasticsearch-7.x-v1 18.68% <19.62%> (+0.45%) ⬆️
elasticsearch-8.x-v1 18.84% <19.62%> (+0.44%) ⬆️
elasticsearch-8.x-v2 1.63% <0.00%> (-0.01%) ⬇️
grpc_v1 10.37% <36.44%> (+1.09%) ⬆️
grpc_v2 7.90% <16.08%> (+0.95%) ⬆️
kafka-v1 8.58% <0.00%> (-0.08%) ⬇️
kafka-v2 1.63% <0.00%> (-0.02%) ⬇️
memory_v2 1.63% <0.00%> (-0.02%) ⬇️
opensearch-1.x-v1 18.72% <19.62%> (+0.44%) ⬆️
opensearch-2.x-v1 18.73% <19.62%> (+0.45%) ⬆️
opensearch-2.x-v2 1.62% <0.00%> (-0.03%) ⬇️
tailsampling-processor 0.45% <0.00%> (-0.01%) ⬇️
unittests 95.13% <88.11%> (-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.

Name: "storage",
Tags: map[string]string{
"name": name,
// TODO: how should we get kind?
Copy link
Member

Choose a reason for hiding this comment

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

for name, factory is actually for kind, factory, because in v1 there is notion of storage names. The closest v1 has to names is primary/archive, which you might add to the namespace as a name attribute in CreateReader vs. CreateArchiveReader

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 We're not recording any metrics today for the archive span reader so can we just leave the name tag off?

@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review November 29, 2024 21:17
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner November 29, 2024 21:17
@mahadzaryab1 mahadzaryab1 changed the title [WIP][v2][storage] Move span reader decorator to storage factories [v2][storage] Move span reader decorator to storage factories Nov 29, 2024
@mahadzaryab1
Copy link
Collaborator Author

@yurishkuro do we need to decorate the span reader in blackhole storage?

if err != nil {
return sr, err
}
return spanstoremetrics.NewReaderDecorator(sr, f.metricsFactory), nil
Copy link
Member

Choose a reason for hiding this comment

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

wrap CreateArchiveSpanReader to? This is where you can apply a label name=primary|archive before creating decorator

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 we need to namespace the metric factory again? The factory doesn't expose a way to just label an existing namespace.

Copy link
Member

Choose a reason for hiding this comment

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

why not - you can pass just the tags, with empty name

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.

oh okay got it - but the name label is already provided for v2 and we don't want to override it. Should we give the label a different name? What about type?

Copy link
Member

Choose a reason for hiding this comment

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

maybe role then

Copy link
Member

Choose a reason for hiding this comment

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

type and kind are kind of the same.

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.

@yurishkuro Sounds good. One other thing to note about cassandra is that it currently holds two metrics factories that publish metrics under jaeger_cassandra_*** and jaeger_cassandra-archive_*** (https://github.com/jaegertracing/jaeger/blob/main/plugin/storage/cassandra/factory.go#L136-L137). Do we want to change these namespaces to match the same ones we're using for the decorator? So we could publish under jaeger_storage_*** with the role, kind, and name (only for v2) labels instead of jaeger_cassandra_*** and jaeger_cassandra-archive_*** .

Copy link
Member

Choose a reason for hiding this comment

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

yes, I was thinking that too, since we're making a breaking change anyway let's make them more consistent.

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 Made this change and updated the PR with a summary of the breaking changes

@yurishkuro
Copy link
Member

do we need to decorate the span reader in blackhole storage?

no, it's not used in prod.

@@ -133,8 +133,7 @@ func (f *Factory) configureFromOptions(o *Options) {

// Initialize implements storage.Factory
func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
f.primaryMetricsFactory = metricsFactory.Namespace(metrics.NSOptions{Name: "cassandra", Tags: nil})
f.archiveMetricsFactory = metricsFactory.Namespace(metrics.NSOptions{Name: "cassandra-archive", Tags: nil})
Copy link
Member

Choose a reason for hiding this comment

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

Why not keep these two here? Otherwise you're duplicating namespace assignments twice, which means they can get out of sync.

Copy link
Collaborator Author

@mahadzaryab1 mahadzaryab1 Nov 30, 2024

Choose a reason for hiding this comment

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

@yurishkuro Done. However, CreateSamplingStore (https://github.com/jaegertracing/jaeger/blob/main/plugin/storage/cassandra/factory.go#L211) and CreateDependencyReader (https://github.com/jaegertracing/jaeger/blob/main/plugin/storage/cassandra/factory.go#L175) will now have the role=primary attached to the metrics they emit. Is this fine? or should they just be emitting metrics under the namespace passed into the storage factory without the role tag?

Copy link
Member

Choose a reason for hiding this comment

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

I think sampling store should be kind=cassandra, role=sampling

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 Done. What about the dependency reader? I'm using the base factory for now.

Copy link
Member

Choose a reason for hiding this comment

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

what would it look like? Dependencies technically were always bundled within the spanstore, not a different "role".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the metrics would be published under jaeger_storage_*** with kind=cassandra but no role tag.

Copy link
Member

Choose a reason for hiding this comment

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

that's fine

Copy link
Member

Choose a reason for hiding this comment

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

although since it's using the primary connection / session I would pass it the primary metrics

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@yurishkuro yurishkuro enabled auto-merge (squash) November 30, 2024 19:11
@yurishkuro yurishkuro disabled auto-merge November 30, 2024 20:12
@yurishkuro yurishkuro merged commit 557f149 into jaegertracing:main Nov 30, 2024
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/storage changelog:breaking-change Change that is breaking public APIs or established behavior storage/badger Issues related to badger storage storage/cassandra storage/elasticsearch v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants