-
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
[feat][storage] Add SpanKind support for badger #6376
base: main
Are you sure you want to change the base?
Conversation
I have changed the structure of cache which is leading to these concerns:
Once the correct approach is discussed I will handle some more edge cases and make the e2e tests pass (making |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6376 +/- ##
==========================================
- Coverage 96.24% 96.20% -0.05%
==========================================
Files 375 376 +1
Lines 21397 21530 +133
==========================================
+ Hits 20593 20712 +119
- Misses 612 623 +11
- Partials 192 195 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@yurishkuro Please review the approach and problems! |
@yurishkuro I have added more changes which reduces the iterations in prefill to 1 but it limits the |
I have an idea for old data without using the migration script! We can store the old data in two other data structures in cache (without kind). But then the only question which rises then: What to return when no span kind is given by user? Operations of new data of all kind or operations of old data (kind marked as unspecified) or an addition of both? |
then we should return all operations regardless of the span kind |
That means including all spans of old data also (Whose kind is not there in cache)? |
My current approach is leading to errors in unit test of
This is probably because
The only problem is that, during prefilling 6*NumberOfOperations Get Queries will be called. Please review this approach @yurishkuro and I think we need to discuss about autoCreation of new index or should we skip the creation of any new index and use the function given above? |
@yurishkuro I finally got rid of migration and now I think its ready for review! Please ignore my previous comments. The current commit has no linkage them! |
|
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.
can you revisit the tests by using API methods of the cache instead of manually manipulating its internal data structures? Tests should be validating expected behavior that the user of the cache expects. The only time it's acceptable to go into internal details is when some error conditions cannot be tested otherwise purely from external API.
I have fixed all the tests except that of Update and Prefill, even they are also not manipulating the data structure, they are used just to check whether cache is storing by using the update or prefill |
@yurishkuro Can you please review? |
Q: do we have to maintain two indices forever, or is this only a side-effect of having to be backwards compatible with the existing data? For example, one way I could see this working is:
|
The key :
Then finding the trace ids would also work fine. So either we have to create an extra index or do this extra scanning! |
This index doesn't make sense to me. It cannot effectively support a query that only includes service+operation, you must always know the Wouldn't it make more sense to append the
|
We can try this but then we need to remember that it will break these conventions:
|
Why is it "breaking" if kind introduced after Time but not "breaking" when it's before Time? Whatever we do the changes must be backwards compatible. |
Please see this: jaeger/plugin/storage/badger/spanstore/writer.go Lines 117 to 128 in 1ae9c1a
This is how we are creating a key, when |
why does it matter? We're creating an index with a different layout, we don't have to be restricted by how that specific function is implemented, especially since we are introducing a different look up process (it seems all other indices are doing direct lookup by the prefix up to the timestamp and then scan / parse). |
Ok, will give it a try and get back to you! Thanks for your time! |
@yurishkuro I have tried to take care of all the edge cases, please review! |
@yurishkuro This PR is ready to review, I have added dual lookups and backward compatibility tests in this PR. |
} | ||
err := writer.writeSpanWithOldIndex(&oldSpan) | ||
require.NoError(t, err) | ||
traces, err := reader.FindTraces(context.Background(), &spanstore.TraceQueryParameters{ |
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.
not sure I follow this test. What does FindTraces have to do with span kind in the operations retrieval? Also, backwards compatibility test only makes sense when it is executed against old and new code.
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.
We have changed the key but we need to make sure that traces are also fetched from old key when dual lookup is turned on. Please stress on a fact that operation key is used in getting traces also along with filling in cache, If you will look at this code, we are first writing span with old key and then testing whether it is able to fetch traces associated with that key (please see L42)
} | ||
*/ | ||
// The uint64 value is the expiry time of operation | ||
operations map[string]map[model.SpanKind]map[string]uint64 |
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.
to clarify, CacheStore is used to avoid expensive scans when loading services and operations, correct? In other words, it's all in-memory structure. In this case, why can we not change just the value of the map to be a combo {kind, expiration}
instead of changing the structure? When loading, scanning everything for a give service is still going to be negligible amount of data.
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.
Can't understand this! Are you saying to keep these structures?
services map[string]uint64 // Already in the cache
operations map[string][string]kind
type kind struct {
kind SpanKind
expiry uint64
}
If yes, then how to handle when query is to fetch all operations for a service and kind? Should we iterate all operations and skip those operations which are not of the required kind? (We are using a similar approach currently, i.e iteralting for all kinds and skipping unrequired kinds but this was justified because max kinds can be 6 but number of operations aren't defined, so will this option viable?)
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, this structure.
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.
So iterating all operations and skipping not required kinds will be right?
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
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.
While approaching towards this, I am leading to a conclusion that this approach will lead to the same problem that spans with same operation and service name but different kind will end up in overriding of data. So I don't think that this structure is going to be a correct approach! Rather I could think of only 3D map a viable option. So should we move forward with 3D map or can we have a better idea?
…er (#6575) ## Which problem is this PR solving? Comment: #6376 (comment) ## Description of the changes - Cache was directly contacting the db to prefill itself which is not a good way, now this responsibility is given to reader to read from badger and fill the cache. ## How was this change tested? - Unit and e2e tests ## 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`: `npm run lint` and `npm run test` --------- Signed-off-by: Manik2708 <[email protected]>
Signed-off-by: Manik2708 <[email protected]>
featuregate.StageBeta, // enabed by default | ||
featuregate.WithRegisterFromVersion("v2.2.0"), | ||
featuregate.WithRegisterToVersion("v2.5.0"), | ||
featuregate.WithRegisterDescription("Allows reader to look up for traces from old index key"), |
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 have taken the version values from the PR, currently unclear about these versions. Secondly should I link the PR to this gate or issue? As issue is not directly talking about dual-lookup
|
||
store *badger.DB |
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 couldn't find any use of store in cache now because it is dependent on reader to prefill itself.
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test