RudolfMan / acme_liveview_pubsub_opentelemetry

Example application to show potential N+1 query when using Phoenix.PubSub
2 stars 1 forks source link

correlation id ? #1

Open setop opened 2 years ago

setop commented 2 years ago

The example app works ! I've been able to reproduce on my app. Thanks you for sharing.

I'm just strangling with one thing : almost all traces have only one span (sometimes two). There is no correlation between the web request and the work done by ecto and then on the DB.

So I'm not able to tell for example that one call to 'DELETE /resources/:id' is performing a select and then a delete.

Do you think there is a way to improve that ?

RudolfMan commented 2 years ago

Hi, @setop! Thank you for stopping by 😄.

Are some of those calls happening asynchronously in separate tasks/processes?

If we have both OpentelemetryPhoenix and OpentelemetryEcto setup https://github.com/RudolfMan/acme_liveview_pubsub_opentelemetry/blob/9c1247f2972eac79b2f4ce2980bbaf7c87ac6bf0/lib/acme/application.ex#L10-L11

Then all spans created in the same process should be together in the same trace.

However, if we do the part of the work in a separate process - we need to make sure that span context is passed properly.

Just like here we are passing context along with the message: https://github.com/RudolfMan/acme_liveview_pubsub_opentelemetry/blob/8f26d9687d56ec7a308c596b7520cf075a2fe43b/lib/acme/orders.ex#L77-L78

And then set it in a different process https://github.com/RudolfMan/acme_liveview_pubsub_opentelemetry/blob/8f26d9687d56ec7a308c596b7520cf075a2fe43b/lib/acme_web/live/order_live/show.ex#L25

I tried to show it halfway though this post