← All guidesCodex for Backend Engineering · Future with Shivank
Hands-on guide

25. Observability

Start Part 8. You ask Codex to add OpenTelemetry tracing and Jaeger to the auction app using a single short grilling round, finish and save Part 7, and then let Codex build the whole tracing change as one slice.

Part 8 · start≈ 30–45 min hands-onGrill with docs · 1 round

What you'll do

Before you start

📘 Concept: observability (logs vs metrics vs traces)

Observability means understanding what your running system is doing from the outside, without adding print statements and restarting it. There are three kinds of signal. Logs are text lines a service writes (“bid accepted for auction 42”): good for detail, bad for the big picture. Metrics are numbers over time (requests per second, error rate): good for dashboards and alarms, but they cannot tell you what happened to one specific request. Traces follow one request through several services and show how long each step took. Our app now has an API, a database, Redis, RabbitMQ, two workers and a payment service. Logs from seven places are useless unless you can join them. Tracing joins them. That is what Part 8 adds.

📘 Concept: trace and span

A span is one timed step with a name and a few labels, for example “auction.bid.accept, auction 42, took 12 ms”. A trace is the whole family of spans that belong to one request or one story, even when they happen in different services and minutes apart. Think of a courier parcel: each scan at a depot is a span, and the tracking page that lists every scan in order is the trace. Spans have parents and children: “handle the bid” is the parent, “run the INSERT query” is one of its children. In Jaeger you see this as an indented timeline.

📘 Concept: OpenTelemetry (OTel)

OpenTelemetry, shortened to OTel, is the open-standard library that creates spans inside your code and ships them out of the process. Ours is the Node.js version. It can wrap common libraries (HTTP, PostgreSQL, Redis) so they produce spans automatically, and it lets you create your own named spans for business steps. OTel does not store or display anything; it only produces the data and sends it to a backend you choose. Here that backend is Jaeger.

⚙ Codex settings for this guide
Project / folderworkshop
ModelGPT-5.6 Sol
ReasoningMedium
ApprovalsApprove for me
AlsoNew chat on Local, branch master
1

Send the Part 8 prompt in a new chat

Click New chat in the top-left of the Codex app. In the chips above the message box, make sure the project is workshop, keep Local (not a worktree) and branch master. Then paste the prompt below and press Enter.

Read the prompt before you send it; every line does a job. The first line tells Codex to copy Part 7 into the empty part-8-cross-stack-debugging folder and build there, as every part has copied the one before it. The middle paragraph says what we want (Jaeger for observability) and, more importantly, how much: as little noise as possible, high-signal only, focused on the auction-checkout path. Without that, tracing libraries record every file read, DNS lookup and timer tick, and one bid becomes 300 spans nobody can read. The last line changes how the grilling skill behaves. You can send this while Part 7's Slice 2 is still running in the other chat; Codex does not touch the Part 7 folder until you confirm the slices in step 5.

📘 Concept: Jaeger

Jaeger is a free, open-source tool that receives spans from all your services, stores them and shows them as traces in a web page. Think of it as the CCTV control room for your app: every service sends its footage to one place, and you watch the replay there. In our project Jaeger runs as a Docker container. It listens on one port for incoming spans and serves its web UI on port 16686, so you open http://localhost:16686 to look at traces. You never send data to Jaeger by hand; the OpenTelemetry library in each service does that.

✦Paste into Codexnew chat · Local
work out of part 8 directory, using part 7

we want to add Jaeger for observability. please make it so that it's as little noise as possible inside of our spans and traces - high signal stuff only for the purposes of this workshop. focus on the auction checkout side of things- I want to see a trace that contains spans across auction bids, closes, and communication.

Grill me shorter - just one round of questions please!
📘 Concept: a single short grilling round

The grilling skill normally asks two or three rounds of questions, each digging deeper, before it writes a plan. That is right for a feature with many product decisions, like Part 7's checkout. Adding tracing has far fewer decisions, mostly technical, so I tell the skill up front: one round only. The skill reads that like any other instruction, and Codex says out loud that it is doing a “single, compact round”. Why this matters: each round costs tokens and your time. You are in charge of the grill. Ask for less when the problem is small, and for more when it is not.

✓ You should see

The chat gets a name like Add Jaeger auction tracing. Codex starts with “I'm using the grilling skill for a single, compact round, as requested…”, reads the repo for about 45 seconds, then posts one round of about 8 questions (Q1–Q8), each with a recommended answer marked by an arrow. It may mention that Part 7 already contains some OpenTelemetry scaffolding and that Part 8 is empty. It ends with “Reply with “all recommended” or list any overrides by question number.” No file has changed yet.

2

Answer the single round

Codex words its questions in its own way, and your numbering may not match mine. Read each of your questions and match it to the list below. I said yes to everything except one change in Q4. What each question is really asking:

  • Q1 Golden trace: one trace tells the whole story: winning bid → auction close → outbox publish → RabbitMQ → Socket.IO notification → checkout → Mock Stripe payment → webhook → paid purchase. A “golden trace” is the one you would show a new teammate to explain the whole system end to end.
  • Q2 Trace continuity: save the trace context in the database row and inside the RabbitMQ messages, so Jaeger shows one continuous trace even though the close happens a minute after the bid and the checkout later still.
  • Q3 Which bids: only the winning bid joins the golden trace. Every other bid gets its own short trace, so an auction with 20 bids does not become one giant trace.
  • Q4 Span budget: about 8–10 named business spans, with the automatic Redis, filesystem, DNS, timer and framework spans switched off. But keep the PostgreSQL query spans. This is my one change. The database is where the row locking and the slow inserts live, and where real problems usually show up, so I want to see it.
  • Q5 Checkout boundary: Mock Stripe appears as its own service in Jaeger, so you see the request leave our API and come back, as a real payment provider would.
  • Q6 Business outcomes: a rejected bid, a duplicate message or a declined card is a normal outcome, recorded as a label on the span, not as a red error span. Red is reserved for real failures like a crash or a refused connection.
  • Q7 Trace data: spans carry IDs, the auction slug, amounts, event IDs, user role and outcome, but never names, user handles, card data, message payloads or SQL text. Traces are stored for weeks and seen by many people; personal and card data must not end up there.
  • Q8 Demo surface: a Jaeger startup in the project and a written browser walkthrough. No new screen in the Auction House app. You look at traces in Jaeger at localhost:16686.
📘 Concept: following one request across API → Postgres → RabbitMQ → worker

When the winning bid arrives at the API, OpenTelemetry creates a trace ID, a random identifier for this story. Every span created while handling that request records the same ID, including the Postgres query spans, which become children of the API span. The hard part comes later: the close worker runs a minute afterwards in a different process, and the notification worker in a third. For Jaeger to show one trace, the ID has to travel with the data. It is saved in the auction's database row and put into the headers of the RabbitMQ message; the worker reads it and continues the same trace instead of starting a new one. This is trace context propagation, exactly what Q2 asked for. Without it you would see three unrelated traces and match them by timestamp by hand.

📘 Concept: instrumenting code

Instrumenting means adding small pieces of code that record what the program is doing: “start a span named auction.bid.accept here, attach the auction ID, end it there”. Automatic instrumentation is when the OTel library hooks into packages you already use, such as pg or the HTTP server, and produces spans for every call without you writing a line: quick but noisy. Manual business spans are the ones you create and name after a business step (accept bid, close auction, publish event). Q4 keeps the automatic Postgres spans, turns the other automatic ones off, and adds 8–10 hand-named business spans.

Now type your answers, one per line, numbered to match your questions. “take recommend” means “use your own recommendation”. Line 4 is the only real override. Line 7 is just me being emphatic that the IDs and amounts belong in the spans; Codex reads the intent, not the volume.

✦My answers, adjust the numbers to match your questionsAdd Jaeger auction tracing chat
1. yes
2. yes
3. take recommend
4. everything yes except let's see Postgres
5. yes
6. yes
7. YES!!!!! Spans should OF COURSE INCLUDE THOSE!!
8. yes
✓ You should see

A summary similar to: “Shared understanding: one high-signal trace will follow the winning bid through close, RabbitMQ notification, checkout, Mock Stripe, webhook, and paid purchase. PostgreSQL operations within that path will remain visible; routine framework, Redis-internal, timer, filesystem, and polling noise will be suppressed.”

Then a large Mermaid diagram (a diagram drawn from text; click it to zoom) of the moving parts: Auction Close Worker → RabbitMQ (“AuctionClosed + trace context”) → Notification Worker → Redis → Socket.IO → web app → Fastify API, with the API talking to PostgreSQL and Mock Stripe, and every box feeding OpenTelemetry → Jaeger. Under it, three proposed slices: Winning bid → durable auction close, Auction close → communicated outcome, Outcome → paid winner purchase, and “Confirm these three slices and I'll start Slice 1.”

Do not reply yet. The moment you confirm, Codex copies Part 7 into Part 8. First we make sure Part 7 is finished and saved (step 3).

💡 Tip

Shortcut: when you agree with every recommendation, reply “all recommended”. I wanted the Q4 change, so I answered line by line. Both work.

3

Check that Part 7 Slice 2 is done, then save it

Click Define winner checkout flow in the chat list on the left. Scroll to the bottom and wait until Codex has posted its Slice 2 summary and the running counter has gone. Only then commit Part 7. Why this matters: Part 8 is going to be a copy of Part 7. Committing now gives Git a clean “Part 7 finished” snapshot, so everything Codex changes for Part 8 shows up separately when we review it in the next guide.

Open the Terminal app (Cmd+Space, type Terminal, Enter) and run this line. cd ~/codex-course/workshop moves into your workshop folder, git add -A stages every new, changed and deleted file, and git commit -m "…" saves the snapshot with the message in quotes.

❯Run in TerminalTerminal app · workshop folder
cd ~/codex-course/workshop && git add -A && git commit -m "Part 7 slice 2: seller payment view"
✓ You should see

In Codex, something like: “Slice 2 is complete and verified… Theo won at $107 and completed checkout; Avery's seller view converges to Paid.” Under Implemented: the seller sees only Awaiting payment or Paid, unrelated users see no payment details, and a Mock Stripe session that disappeared after a restart gets replaced. Under Verification: 24 backend, 16 frontend and 4 Mock Stripe tests passed. Then “Both Part 7 slices are now complete.”

In Terminal, a commit summary such as [master 3f9a1c2] Part 7 slice 2: seller payment view followed by the number of files changed. Your hash and counts will differ.

⚠ Heads up

If Slice 2 is still running, wait for it. Do not send the step 5 message until this commit is done, otherwise Part 8 starts from a half-written Part 7 and you will chase strange bugs later.

4

Run the bidding war again and keep it open

Stay in the Define winner checkout flow chat. Slice 2 added the seller's payment view, and I want you to see it live rather than take Codex's word for it. Ask for one more bidding war and tell Codex to leave the windows open.

Reminder: the bidding war is the Playwright test from guides 11–12 that opens four real browser windows, one per demo user, and has them bid against each other until the auction closes. A test normally closes its browsers the moment it finishes; “keep it open” makes Codex run it with a hold, so the windows stay on screen for you.

✦Paste into CodexDefine winner checkout flow chat
do bidding wars again and keep it open
✓ You should see

Four tiled browser windows on http://localhost:5107/items/bidding-war-gpu-…. Codex picks the port; in my run it was 5107. The pattern in this course is 51xx, where xx is the part number, so Part 8 will use 5108. Bids climb to about $107 and the auction closes. The seller's window (Avery Chen) now shows a yellow panel: WINNER PAYMENT · Awaiting payment · The winning bidder has not completed payment yet. That yellow panel is Slice 2. Leave all four windows open for step 6.

💡 Tip

How to tell the windows apart: the seller's window says “Your auction has closed” with the yellow payment panel. The winner's window (Theo Brooks) says “Congratulations” and has a Complete purchase button. The other two just see that the auction ended. Codex also names the winner's window in its reply.

5

Tell Codex to build the slices as one

Go back to the Add Jaeger auction tracing chat. Codex proposed three slices because the grilling skill is designed for product features, where each slice is something a user can see and you can ship on its own. That does not fit here. We are adding recording around code that already works, nothing a user can see. Three slices would mean three rounds of build, test and review for one change. So we push back. Why this matters: the agent proposes, you decide. Accepting a plan that does not fit the work just because the agent wrote it wastes time and tokens.

Two words in the prompt: a refactor is a change to how the code is written that does not change what the app does for the user, and adding tracing is exactly that: bids, closes and payments behave the same, the code just reports what it is doing. OTel is the short form of OpenTelemetry. Send this only after step 3 is committed. This is the message that makes Codex copy Part 7 into Part 8.

✦Paste into CodexAdd Jaeger auction tracing chat
I would do them all together - we're just adding OTel and jaeger. this is a super straightforward refactor
✓ You should see

Something like: “Agreed—this is one cohesive observability slice, not three product increments. I'll implement the full bid → close → communication → checkout trace in Part 8, verify the complete path, and hand it back as one reviewable result.” Codex copies Part 7 into part-8-cross-stack-debugging and starts. A few minutes in, it reports its approach: “Part 8 will use explicit business spans as trace roots, automatic PostgreSQL child spans, and selective HTTP propagation…” and you see a counter like Step 1 / 4.

In plain words: the hand-named business spans sit at the top of each trace (the roots), the Postgres query spans hang under them as children, and the trace ID is passed along only on the HTTP calls that matter, such as the one to Mock Stripe (selective propagation). Let it run. We look at the result in the next guide.

⚠ Heads up

This is a full build with tests and browser checks across five services: API, close worker, notification worker, Mock Stripe and the web app. It is one of the bigger runs in the course, typically 10–20 minutes and a lot of tokens. Keep an eye on platform.openai.com → Usage, and do not interrupt it.

6

Pay as the winner and watch the seller flip to Paid

While Part 8 builds, go back to the four bidding-war windows from step 4. Put the winner's window (Theo Brooks) and the seller's window (Avery Chen) side by side. In the winner's window click Complete purchase. The browser goes to the Mock Stripe checkout page at http://127.0.0.1:7107/checkout/cs_test_…, showing the item and $107.00. Type the card number below, any future expiry and any 3-digit CVC. I typed 03/44 and 334. Click Pay $107.00 and immediately look at the seller's window.

≡Success test cardCard number
4242 4242 4242 4242
📘 Concept: webhook

After the card is accepted, our API does not keep asking Mock Stripe “is it paid yet?”. Mock Stripe makes an HTTP request of its own into our API, carrying a checkout.session.completed event. A request that an outside service sends to your server when something happens is a webhook. It is signed, so the API can check it really came from Mock Stripe. The API then marks the purchase paid in the database and pushes the new state to the seller's browser over the live Socket.IO connection, so the page updates without a reload.

✓ You should see

Within about a second the seller's yellow Awaiting payment panel turns green: WINNER PAYMENT · Paid · The winning bidder completed payment. The winner's window lands back on the auction page with Payment received · Your purchase is paid.

In that blink: the payment went to Mock Stripe, its signed webhook reached our API, the API updated the purchase row in Postgres, and the seller's page received the new state over the live connection. Remember this chain. It is exactly the path Part 8's golden trace records, and in the next guide you see each hop as a span.

💡 Tip

Want the other outcome? In another run, pay first with the decline card 4000 0000 0000 0002: the Mock Stripe page shows an error and lets you retry, and the seller's panel stays yellow. Then pay with 4242 and watch it go green. In Part 8 that decline is recorded as an outcome label on the span, not a red error, as decided in Q6.

7

Optional: the delegate-to-a-cheaper-model trick

One trick I use to stretch my token budget: let the main model (Sol) do the planning, grilling and review, and let a cheaper model write the actual code. Codex has a place for a sentence that gets added to every chat you open. Open Settings with Cmd+, (Command and the comma key). In the search box at the top type instructions. Click Personalization, find the Custom instructions text box and type the line below into it.

📘 Concept: custom instructions and model delegation

Custom instructions are a text box in Codex settings. Whatever you write there is silently added to the start of every chat, in every project. It is like AGENTS.md, but it belongs to you rather than to one repo. Delegating means the main model does not write the code itself; it hands that part to a helper agent on a different model and checks the result. 5.6 Luna is the smallest, cheapest tier. Max is the highest reasoning level, so Luna thinks longer to make up for being smaller. Planning stays on the strong model; the many lines of typing happen on the cheap one.

≡My custom instructionSettings → Personalization → Custom instructions
Please delegate all coding work to 5.6 Luna Max!!!! NO EXCEPTIONS!!!

Click Save (top right of the settings panel) only if you want this in every chat from now on. It is a model change: coding runs on 5.6 Luna at Max reasoning instead of on Sol. If you only want to look, close Settings without saving.

✓ You should see

The box under Custom instructions holds your text, with a Save button at the top right. Nothing changes in existing chats until you save and start a new one.

💡 Tip

With an API key this can lower your bill, but check the per-token prices of Sol and Luna on platform.openai.com first; Max reasoning makes Luna use more tokens per task. It works best when the project has good tests, as ours does, so the cheaper model's mistakes get caught. If you turn it on, your results in the next guide will differ a bit from mine. To turn it off, delete the text and Save again. If your Codex version has no Custom instructions box, put the same line at the top of the root AGENTS.md in the workshop folder instead.

Stuck or got a very different result?

If the Part 8 build fails, runs out of budget, or you want to move on, catch up to the finished Part 8 from the reference copy. The reference folder is the end state of the whole part: Jaeger tracing done and the golden trace documented in its README. The command also restores the finished stripe-service/, which gets its own tracing in Part 8. Afterwards the app is at http://localhost:5108 and Jaeger at http://localhost:16686.

The first line deletes your Part 8 and Mock Stripe folders, copies both from ../reference, and commits the result so Git has a clean “caught up” snapshot. The second moves into Part 8, installs its packages with npm install and starts everything with npm start.

❯Run in TerminalTerminal app
cd ~/codex-course/workshop && rm -rf part-8-cross-stack-debugging stripe-service && cp -R ../reference/part-8-cross-stack-debugging ../reference/stripe-service ./ && git add -A && git commit -m "Catch up: part 8 from reference"
cd part-8-cross-stack-debugging && npm install && npm start

If the grilling comes back as two rounds, Codex ignored the last line of the prompt; reply “one round only please, pick your recommendation for the rest” and carry on. If the bidding war in step 4 opens no windows, check that Microsoft Edge is installed and Docker Desktop is running, then ask again.

Key takeaways