setop / acme_liveview_pubsub_opentelemetry

Example application to show potential N+1 query when using Phoenix.PubSub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

See blog post N+1 problem by misusing Phoenix PubSub and how to spot it with OpenTelemetry.

Start Zipkin

docker run -d -p 9411:9411 openzipkin/zipkin

Set OTEL_SERVICE_NAME environment variable

export OTEL_SERVICE_NAME=acme

Start your Phoenix server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000/orders.

  • Create an order.
  • Open the order page in multpile browser windows (to get multiple concurrent liveview connections established).
  • Edit the order in one window and confirm that it was updated in other windows.
  • Go to Zipkin localhost:9411/zipkin.
  • Add tagQuery in search tagQuery=broadcaster and Run Query.
  • Observe traces and spands.

Learn more

About

Example application to show potential N+1 query when using Phoenix.PubSub


Languages

Language:Elixir 74.3%Language:CSS 16.7%Language:HTML 6.8%Language:JavaScript 2.2%