Skip to content

About

LangGraph agent sample instrumented with Datadog Agent Observability

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

LangGraph Sample with Datadog LLM Observability

A sample project integrating Datadog LLM Observability into a LangGraph-based agent.

Overview

An agent that researches user questions via web search, summarizes the results, and sends them to AWS SNS.

  • LLM: Amazon Bedrock (Claude Sonnet 4.6)
  • Framework: LangGraph
  • Tools: Tavily Web Search / AWS SNS
  • Observability: Datadog LLM Observability / APM

Architecture

START → agent → tools → agent → END
                  ↑        |
                  └────────┘
  • agent: LLM decides whether to call a tool
  • tools: Executes web search or SNS publish

Prerequisites

Before setting up the project, prepare the following accounts and resources.

Tavily API Key

  1. Sign up at tavily.com
  2. Go to your dashboard and create an API key
  3. Copy the key — it will be used as TAVILY_API_KEY

AWS Setup

IAM Credentials

Create an IAM user or role with the following permissions:

  • AmazonBedrockFullAccess (or a scoped policy allowing bedrock:InvokeModel)
  • AmazonSNSFullAccess (or a scoped policy allowing sns:Publish on your topic)

Generate an access key and secret for use as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Enable Amazon Bedrock Model Access

This project uses Claude Sonnet 4.6 via Amazon Bedrock in the us-west-2 region.

  1. Open the Amazon Bedrock console in us-west-2
  2. Go to Model access and request access to Anthropic Claude Sonnet 4.6 (cross-region inference model ID: us.anthropic.claude-sonnet-4-6)
  3. Wait for access to be granted (usually instant)

Create an SNS Topic

aws sns create-topic --name langgraph-sample --region us-west-2

Copy the returned TopicArn — it will be used as SNS_TOPIC_ARN.

Optionally, subscribe your email address to receive published messages:

aws sns subscribe \
  --topic-arn <TopicArn> \
  --protocol email \
  --notification-endpoint your@email.com

Confirm the subscription via the email that arrives.

Datadog API Key

  1. Log in to your Datadog account
  2. Go to Organization Settings → API Keys
  3. Create a new API key and copy it — it will be used as DD_API_KEY

Setup

1. Create and activate virtual environment

python -m venv .venv
source .venv/bin/activate

2. Install packages

pip install -r requirements.txt

3. Configure environment variables

cp .env.example .env

Open .env and fill in the following values.

Variable Description
AWS_ACCESS_KEY_ID AWS access key
AWS_SECRET_ACCESS_KEY AWS secret key
AWS_DEFAULT_REGION AWS region (e.g. us-west-2)
SNS_TOPIC_ARN Target SNS topic ARN
TAVILY_API_KEY Tavily API key
DD_API_KEY Datadog API key
DD_HOSTNAME Hostname for the Datadog Agent
ML_APP_NAME App name shown in Datadog LLM Observability

4. Verify AWS credentials

aws sts get-caller-identity

5. Start Datadog Agent

docker run -d --name datadog-agent \
  --env-file .env \
  -p 8126:8126 \
  -p 8125:8125/udp \
  datadog/agent:latest

6. Run

ddtrace-run python 2_graph_agent.py

7. Stop Datadog Agent

docker stop datadog-agent
docker rm datadog-agent

Datadog Observability

  • LLM Observability: Sends LLM traces directly via LLMObs.enable(agentless_enabled=True) without a Datadog Agent
  • APM: Sends traces through the Datadog Agent via ddtrace-run

Reference:

About

LangGraph agent sample instrumented with Datadog Agent Observability

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages