elastic / apm-agent-ruby

https://www.elastic.co/solutions/apm
Apache License 2.0
169 stars 131 forks source link

opbeans-ruby transactions have spurious parent ID #1231

Open axw opened 2 years ago

axw commented 2 years ago

Transactions reported by opbeans-ruby all have a non-empty parent.id which does not correspond to any span or transaction. This results in traces without any root transaction, and breaks tail-based sampling which operates on root transactions.

Steps to reproduce:

  1. In apm-integration-testing, run ./scripts/compose.py start 8.0.0-rc2 --bc --with-opbeans-ruby
  2. Open the APM UI, navigate to the opbeans-ruby service
  3. Select the only transaction group, ApplicationController#index
  4. Enter not parent.id:* in the search bar
  5. Observe that there are no trace samples
felixbarny commented 2 years ago

May be related to the usage of ensure_parent_id.

https://github.com/elastic/opbeans-ruby/blob/5c2226d5443325e80171fff881c2a54f294746ee/app/controllers/application_controller.rb#L41

Enter not parent.id:* in the search bar Observe that there are no trace samples

Isn't that expected as the parent would come from RUM?

axw commented 2 years ago

Good point. I didn't have RUM configured, so that explains why there were no root transactions. We should probably only call ensure_parent_is when the frontend is RUM-instrumented.

That raises the question of why there were only ApplicationController#index transactions though. Shouldn't there be other ones, e.g. for /api/orders? And those ones ones shouldn't invoke ensure_parent_id.

felixbarny commented 2 years ago

I haven't tried with apm-integration-testing but on edge, there were no ApplicationController#index transactions.

axw commented 2 years ago

I see them on edge-oblt:

image

I also see other transactions there, and I see the same issue with a parent.id to nowhere (despite edge-oblt having opbens-rum):

image

felixbarny commented 2 years ago

Right, I can see that too now. Seems like the RUM integration setup doesn't work as expected.