-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[ES][v2] Refactor from_dbmodel
and to_dbmodel
to accept and return DB Spans
#6934
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
Conversation
Signed-off-by: Manik2708 <[email protected]>
Signed-off-by: Manik2708 <[email protected]>
Signed-off-by: Manik2708 <[email protected]>
@yurishkuro @mahadzaryab1 Please review this PR, if the changes look good, I will complete the code-coverage. Initially I thought to raise PR seperately for both files but their tests are inter-related, therefore I had to do them in a single PR. |
return traceData, nil | ||
} | ||
|
||
func regroup(batches []*model.Batch) []*model.Batch { |
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.
Grouping is removed and therefore every span has it's own resource.
@@ -183,37 +93,71 @@ type scope struct { | |||
name, version string | |||
} | |||
|
|||
func jSpansToInternal(spans []*model.Span, dest ptrace.ScopeSpansSlice) { | |||
spansByLibrary := make(map[scope]ptrace.SpanSlice) |
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 can't group spans with same scope together as before this they should have the same resource which can't be possible in our case.
case dbmodel.BoolType: | ||
convBoolVal, err := strconv.ParseBool(tagValue) | ||
if err != nil { | ||
putConversionErrKeyValuePair(tag, err, dest) |
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 am confused for this, whether should I return the error or put the error as an attribute in the span?
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 similar conversion implemented in convertKeyValue
in internal/storage/v1/elasticsearch/spanstore/to_domain.go. It doesn't have to be much different here.
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.
That is returning error, so we should also?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6934 +/- ##
==========================================
- Coverage 96.26% 96.18% -0.08%
==========================================
Files 343 344 +1
Lines 20313 20255 -58
==========================================
- Hits 19554 19482 -72
- Misses 574 583 +9
- Partials 185 190 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
if !ok { | ||
// We have to do this as we are unsure that whether bool will be a string or a bool | ||
tagBoolVal, boolOk := tag.Value.(bool) | ||
if boolOk && tag.Type == dbmodel.BoolType { | ||
dest.PutBool(tag.Key, tagBoolVal) | ||
} else { | ||
dest.PutStr(tag.Key, "Got non string value for the key "+tag.Key) | ||
} | ||
continue | ||
} |
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 don't follow what this is doing. Why does bool require different handling that all other types handled in the switch statement?
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.
The Value
of tag is any
not string
and in case of bool the values are in-consistent. Sometimes it is "true"
and sometimes it is true
, so we need to take care of both the cases!
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.
please make high level fixes suggested in the comments, its difficult to review when old/new code is all mixed up.
btw, this is the equivalent for ClickHouse model, which somehow seems a lot cleaner https://github.com/jaegertracing/jaeger/pull/6935/files |
@yurishkuro Thanks for suggestions. When I was modifying the code, I was also concerned about code cleaniness. But then I was also worried about PR becoming excessively large. Therefore I decided to keep the scope of this PR just to replace
|
Signed-off-by: Manik2708 <[email protected]>
Signed-off-by: Manik2708 <[email protected]>
Signed-off-by: Manik2708 <[email protected]>
@yurishkuro @mahadzaryab1 Please review this PR, as it is a blocker for next PRs! |
Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro Thanks for the commit! Should I work on code-coverage now? |
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
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 to merge this but it needs more clean-up. There is too much business logic that should not be present in the db layer. The job of db layer is to capture information without a loss, not to perform business logic translations.
} | ||
|
||
func jProcessToInternalResource(process *model.Process, dest pcommon.Resource) { | ||
if process == nil || process.ServiceName == noServiceName { | ||
func dbProcessToResource(process dbmodel.Process, destinationResource pcommon.Resource) { |
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.
avoid unnecessary complex variable names. In this case what is even the alternative to it being "destination"?
func dbProcessToResource(process dbmodel.Process, destinationResource pcommon.Resource) { | |
func dbProcessToResource(process dbmodel.Process, resource pcommon.Resource) { |
if process.ServiceName == "" || process.ServiceName == noServiceName { | ||
return | ||
} |
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.
there's no point to this check
spansByLibrary := make(map[scope]ptrace.SpanSlice) | ||
|
||
for _, span := range spans { | ||
func setSpansFromDbSpans(dbSpans []*dbmodel.Span, resourceSpans ptrace.ResourceSpansSlice) 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.
use consistent naming, if you have dbProcessToResource
then this should be
func setSpansFromDbSpans(dbSpans []*dbmodel.Span, resourceSpans ptrace.ResourceSpansSlice) error { | |
func dbSpansToSpans(dbSpans []*dbmodel.Span, resourceSpans ptrace.ResourceSpansSlice) error { |
Ok, so should I work on the cleanup? If yes, then what should be the forwarding step for the cleanup? Also code coverage is below threshold, should I complete it in this PR? Or in a different PR? |
Signed-off-by: Manik2708 <[email protected]>
Head branch was pushed to by a user without write access
historically we used snapshot based testing for transformers, where you have a set of JSON fixtures used to perform round-trip conversion and to cover the edge cases. We should switch testing to that mode, e.g. by starting with the fixtures in v1 implementation and creating the corresponding OTLP files from them. |
Got it, should I work on it now or implement the writer/reader for v2? |
you can do both in parallel, they are now independent tasks and won't conflict with the files. |
…n DB Spans (jaegertracing#6934) ## Which problem is this PR solving? Fixes a part of: jaegertracing#6458 ## Description of the changes - This is a prerequisite for the full implementation of converting OTLP Spans to db spans and vice-versa ## How was this change tested? - Unit 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: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
…n DB Spans (jaegertracing#6934) ## Which problem is this PR solving? Fixes a part of: jaegertracing#6458 ## Description of the changes - This is a prerequisite for the full implementation of converting OTLP Spans to db spans and vice-versa ## How was this change tested? - Unit 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: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: amol-verma-allen <[email protected]>
Which problem is this PR solving?
Fixes a part of: #6458
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test