File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
samples/langgraph-sql-agent Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ # OpenTelemetry LangGraph instrumentation example
2+
3+ <!-- TODO: link to devsite doc once it is published -->
4+
5+ This sample is a LangGraph agent instrumented with OpenTelemetry to send traces and logs
6+ including GenAI prompts and responses to Google Cloud Observability.
7+
8+ The Agent is a SQL expert that has full access to an ephemeral SQLite database. The database is
9+ initially empty. It is built with the the LangGraph prebuilt [ ReAct
10+ Agent] ( https://langchain-ai.github.io/langgraph/agents/agents/#basic-configuration#code ) and the
11+ [ SQLDatabaseToolkit] ( https://python.langchain.com/docs/integrations/tools/sql_database/ ) .
12+
13+ ## Permissions
14+
15+ This sample writes to Cloud Logging, Cloud Monitoring, and Cloud Trace. Grant yourself the
16+ following roles to run the example:
17+ - ` roles/logging.logWriter ` – see https://cloud.google.com/logging/docs/access-control#permissions_and_roles
18+ - ` roles/monitoring.metricWriter ` – see https://cloud.google.com/monitoring/access-control#predefined_roles
19+ - ` roles/cloudtrace.agent ` – see https://cloud.google.com/trace/docs/iam#trace-roles
20+
21+ ## Running the example
22+
23+ ``` sh
24+ git clone https://github.com/GoogleCloudPlatform/opentelemetry-operations-python.git
25+ cd opentelemetry-operations-python/samples/langgraph-sql-agent
26+
27+ # Capture GenAI prompts and responses
28+ export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
29+ # Capture application logs automatically
30+ export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
31+ uv run main.py
32+ ```
33+
34+ ## Viewing the results
35+
36+ Similarly, to view the generated traces in the GCP console, use the Trace Explorer.
You can’t perform that action at this time.
0 commit comments