Instrument the Application

10 minutes

You can’t observe what you don’t capture. In this chapter you’ll add Splunk Agent Observability tracing to the assistant so that every user turn becomes a trace, with a nested span for each LLM and tool call, and you’ll do it without rewriting the agent.

Persona

As Careful Health Provider’s AI engineer, you want end-to-end visibility into the agent’s decisions with minimal code change and minimal maintenance. Rather than hand-instrument every step, you’ll attach a single LangChain callback at the graph level and let Splunk Agent Observability capture the whole tree automatically.

Instrumentation is remarkably lightweight: a Splunk Agent Observability callback is a standard

LangChain callback handler. Attach it to a LangGraph run and it captures prompts, responses, model names, token usage, timing, and span nesting for you.

Where to work

This chapter works in the ~/workshop/healthcare-assistant/2-app-with-instrumentation folder.

Continue to the subsections to add the SDK, attach the callback, and generate traffic.