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

[hotROD] Upgrade hotrod to support otel tracer #4548

Merged
merged 23 commits into from
Jul 15, 2023

Conversation

afzal442
Copy link
Contributor

@afzal442 afzal442 commented Jun 22, 2023

Which problem is this PR solving?

Short description of the changes

  • Upgrades hotROD application to support otel tracer

@afzal442 afzal442 requested a review from a team as a code owner June 22, 2023 18:47
@afzal442 afzal442 requested a review from vprithvi June 22, 2023 18:47
@codecov
Copy link

codecov bot commented Jun 22, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.02 ⚠️

Comparison is base (e40a3e5) 97.05% compared to head (5dd40a9) 97.03%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4548      +/-   ##
==========================================
- Coverage   97.05%   97.03%   -0.02%     
==========================================
  Files         301      301              
  Lines       17837    17837              
==========================================
- Hits        17311    17308       -3     
- Misses        422      424       +2     
- Partials      104      105       +1     
Flag Coverage Δ
unittests 97.03% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@afzal442
Copy link
Contributor Author

afzal442 commented Jun 22, 2023

Hi @yurishkuro, while I try to update the hotROD app to support otel tracer, logs under gRPC interceptor don't appear like before. Another thing is I wondered if I should make this application otel instrumented as per previous #4533 (comment).

@yurishkuro
Copy link
Member

logs under gRPC interceptor don't appear like before

that's a problem. Can you investigate? Logs are being written to span via OT span.Log() API. You can check what OTEL Bridge does when it implements this method - I assume it should be translating them into OTEL Span Events. If that works fine, the next step to check is what jaeger2otel transformer is doing in otel-collector-contrib, maybe it's missing the logic to take Span Events and convert them back into Jaeger's span logs.

A good way to test this is to write a unit test.

@yurishkuro
Copy link
Member

Please link the description back to the main tracking issue.

examples/hotrod/services/route/client.go Outdated Show resolved Hide resolved
examples/hotrod/pkg/tracing/http.go Outdated Show resolved Hide resolved
@afzal442 afzal442 marked this pull request as ready for review June 28, 2023 17:57
@afzal442 afzal442 requested a review from yurishkuro June 28, 2023 17:57
@afzal442 afzal442 requested a review from yurishkuro June 30, 2023 17:52
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Q: why are we accumulating such a large PR? Can we not fix each service independently?

@afzal442
Copy link
Contributor Author

afzal442 commented Jul 1, 2023

I see, I thought it could be done all at a time. But creating separate PR for each svc would be great though.

@yurishkuro
Copy link
Member

as long as we validate that each PR does not break the functionality (like baggage propagation).

afzal442 and others added 5 commits July 10, 2023 14:57
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com>
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

This looks to be in good shape, subject to some smaller comments.

I would still prefer that this was done in multiple PRs, at minimum separating client / server changes, but at this point I am ok to merge as one PR.

The last remaining task is to test & document everything, to illustrate:

  • that all spans are showing up (connecting) correctly
  • document what is changing, because the number of spans is going to be different than in the original HotROD due to how http instrumentation works in OTEL
  • test & document the baggage scenarios that were described in the original blog post. If memory serves, at least these:
    • session IDs are logged to customer (or SQL) span when transaction are blocking
    • two sets of resource usage metrics are generated

Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com>
Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com>
Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com>
Comment on lines 80 to 82
m, _ := baggage.NewMember("customer", customer.Name)
bag := baggage.FromContext(ctx)
bag, _ = bag.SetMember(m)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
m, _ := baggage.NewMember("customer", customer.Name)
bag := baggage.FromContext(ctx)
bag, _ = bag.SetMember(m)
m, err := baggage.NewMember("customer", customer.Name)
if err != nil {
eta.logger.For(ctx).Error("cannot create baggage member", zap.Error(err))
}
bag := baggage.FromContext(ctx)
bag, err = bag.SetMember(m)
if err != nil {
eta.logger.For(ctx).Error("cannot set baggage member", zap.Error(err))
}

Copy link
Member

Choose a reason for hiding this comment

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

this change will log the errors. We're hitting a bug in OTEL, either the same as open-telemetry/opentelemetry-go#3685 or related. Basically, NewMember requires the value to be escaped, which is an incorrect behavior. But when I tried escaping it with url.EscapeQuery, then the baggage later is not serialized / deserialized at all.

Copy link
Contributor Author

@afzal442 afzal442 Jul 12, 2023

Choose a reason for hiding this comment

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

Cool! ignoring err cost me here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yurishkuro after deep investigation, it came out working with the response in the HTTP request. e.g. Loading customer {"service": "customer", "component": "mysql", "trace_id": "63718f14ff8d04607e60d95da54784ae", "span_id": "b60a6202006008bc", "customer_id": "567"} here, when I try to use any of the items included say "span_id" or customer.ID or customerID or "mysql", I am getting baggage items out of it. Make sure the service should be "customer".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most insane. when I try to add logs into it, it's still not working. INFO customer/database.go:86 Getting customer {"service": "customer", "component": "mysql", "trace_id": "49af5501b6c5c75acfb1e69d19f1e481", "span_id": "e9e53f530cb6aacc", "customer_name": "Amazing Coffee Roasters"}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after making minor changes, I got sth like below

"route.calc.by.customer.sec": {"Amazing_Coffee_Roasters": 0.498, "Japanese_Desserts": 0.486},
"route.calc.by.session.sec": {"1581": 0.498, "7406": 0.486}

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's the bug it OTEL - users are not supposed to mangle the values like this in order to put them into baggage.

Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
@afzal442 afzal442 changed the title [WIP] Upgrade hotrod to support otel tracer [hotROD] Upgrade hotrod to support otel tracer Jul 15, 2023
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

@yurishkuro yurishkuro merged commit 96f7fdc into jaegertracing:main Jul 15, 2023
@afzal442 afzal442 deleted the upgrade-hotrod-to-otel branch July 16, 2023 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants