-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: Add span adjuster that moves some OTel Resource attributes to Span.Process #4844
Conversation
Signed-off-by: James Ryans <[email protected]>
Signed-off-by: James Ryans <[email protected]>
Codecov ReportAll modified lines are covered by tests ✅
📢 Thoughts on this report? Let us know!. |
model/adjuster/otel_tag.go
Outdated
} | ||
|
||
func OTelTagAdjuster() Adjuster { | ||
return Func(func(trace *model.Trace) (*model.Trace, 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.
nit: please move to a helper function to reduce nesting (you have 5 levels of indentation)
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.
moved it to an anonymous function
model/adjuster/otel_tag.go
Outdated
func OTelTagAdjuster() Adjuster { | ||
return Func(func(trace *model.Trace) (*model.Trace, error) { | ||
for _, span := range trace.Spans { | ||
filteredTags := make([]model.KeyValue, 0) |
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 want to be mindful of allocations & perf overhead. I liked this in-place approach better: https://github.com/jaegertracing/jaeger/pull/4841/files#diff-ca36bdd0bff9f5671449689223699d0029147f11212f797269850af1585aab21R46
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.
optimized 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.
lgtm
Signed-off-by: James Ryans <[email protected]>
is this change breaking HotROD somehow? The integration test failed several times |
Looking into it.. it works normally in my local |
Signed-off-by: James Ryans <[email protected]>
Okay, so I've ran the
So, for this example, I'll just remove the |
Actually, I haven't added the OTel builtin detectors to jaeger components, should I add them? If yes, can you tell me which detector is needed? |
Yeah, this should've been automated -- #4845
Same ones are fine, but let's do it in a separate PR |
trace, err := OTelTagAdjuster().Adjust(trace) | ||
assert.NoError(t, err) | ||
assert.Equal(t, testCase.expected.Tags, trace.Spans[0].Tags) | ||
assert.Equal(t, testCase.expected.Process.Tags, trace.Spans[0].Process.Tags) |
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 suggest adding this sort of test to ensure that Span.tags slice has not been re-allocated: https://go.dev/play/p/euEi6j19DXN
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.
Hmm.. do you have in mind on how to test this? 🤔 I actually can't find out how to ensure this, or can you give me an actual test case?
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.
Pretty much like in the example I pointed to. Before L83 store a reference to beforeTags := testCase.span.Tags
slice. After Adjust is called:
newTag := model.String("new tag", "new value")
beforeTags[0] = newTag
assert.Equal(t, newTag, testCase.span.Tags[0], "span.Tags still points to the same underlying array")
The assert confirms that beforeTags
and testCase.span.Tags
still point to the same underlying slice.
You can even add
assert.NotEqual(t, beforeTags, testCase.span.Tags)
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.
Ahh, now I get what you meant. I've added the test, but I don't think assert.NotEqual(t, beforeTags, testCase.span.Tags)
works since beforeTags
and testCase.span.Tags
point to the same underlying slice?
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.
they point to the same underlying array, but the slices are different - the one after the adjustment is shorter
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.
Ohh right..
## Which problem is this PR solving? - The HotROD CIT was failing in #4844, but no logs were shown to understand why ## Description of the changes - Run container with `--name example-hotrod` - Add `docker logs example-hotrod` to CIT workflow in case of failure Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: James Ryans <[email protected]>
Signed-off-by: James Ryans <[email protected]>
Signed-off-by: James Ryans <[email protected]>
## Which problem is this PR solving? - Resolves #4534 - Continuation from #4844 ## Description of the changes - Add OTel resources to Jaeger components and tracegen tool. ## How was this change tested? - Tested manually in local <img width="1440" alt="image" src="https://github.com/jaegertracing/jaeger/assets/46216691/28bfb121-0c5a-42b1-a3e3-2c5915c90b17"> <img width="1440" alt="image" src="https://github.com/jaegertracing/jaeger/assets/46216691/3b6d993a-2fac-4c65-97c2-e3dca581a3a1"> ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] 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`: `yarn lint` and `yarn test` --------- Signed-off-by: James Ryans <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
Which problem is this PR solving?
Description of the changes
otel.libray.name
andotel.library.version
. Found here https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/adf5bb501bc65d24ae48088bde37f3c0b13353d0/pkg/translator/jaeger/traces_to_jaegerproto.go#L172How was this change tested?
set OTEL_EXPORTER_OTLP_ENDPOINT http://localhost:4318; go run main.go all --otel-exporter=otlp
andmake run-all-in-one
, and ordered a ride in HotROD app.Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test