|
1 |
| -This sample contains part of the LangGraph chatbot demo taken from |
2 |
| -https://python.langchain.com/docs/tutorials/chatbot, running with OTel instrumentation. It |
3 |
| -sends traces and logs to the OTel collector which sends them to GCP. Docker compose wraps |
4 |
| -everything to make it easy to run. |
| 1 | +This sample contains a Streamlit + LangGraph chatbot demo. It sends traces and logs to the GCP |
| 2 | +with the OTLP exporter and opentelemetry-exporter-gcp-logging exporters. |
| 3 | + |
| 4 | +The `run_streamlit.py` script allows you to easily run the sample with auto instrumentation |
| 5 | +enabled and sending telemetry to GCP. It just sets some environment variables and runs with |
| 6 | +`opentelemetry-instrument. |
5 | 7 |
|
6 | 8 | ## Running the example
|
7 | 9 |
|
8 |
| -I recommend running in Cloud Shell, it's super simple. You will see GenAI spans in trace |
9 |
| -explorer right away. Make sure the Vertex and Trace APIs are enabled in the project. |
| 10 | +First, make sure you have `uv` installed: https://docs.astral.sh/uv/getting-started/installation/. |
| 11 | + |
| 12 | +Optionally, set a project with `export GOOGLE_CLOUD_PROJECT=...`. The app respects ADC. |
10 | 13 |
|
11 |
| -### Cloud Shell or GCE |
| 14 | +### Without cloning |
12 | 15 |
|
13 | 16 | ```sh
|
14 |
| -git clone --branch=vertex-langgraph https://github.com/aabmass/opentelemetry-python-contrib.git |
15 |
| -cd opentelemetry-python-contrib/instrumentation-genai/opentelemetry-instrumentation-vertexai/examples/langgraph-chatbot-demo |
16 |
| -docker compose up --build --abort-on-container-exit |
| 17 | +uv run --upgrade https://raw.githubusercontent.com/aabmass/opentelemetry-python-contrib/refs/heads/vertex-langgraph/inst rumentation-genai/opentelemetry-instrumentation-vertexai/examples/langgraph-chatbot-demo/run_streamlit.py |
17 | 18 | ```
|
18 | 19 |
|
19 |
| -### Locally with Application Default Credentials |
| 20 | +### With cloned repo |
20 | 21 |
|
21 | 22 | ```sh
|
22 | 23 | git clone --branch=vertex-langgraph https://github.com/aabmass/opentelemetry-python-contrib.git
|
23 | 24 | cd opentelemetry-python-contrib/instrumentation-genai/opentelemetry-instrumentation-vertexai/examples/langgraph-chatbot-demo
|
| 25 | +uv run run_streamlit.py |
| 26 | +``` |
| 27 | + |
| 28 | +### Without auto instrumentation |
24 | 29 |
|
25 |
| -# Export the credentials to `GOOGLE_APPLICATION_CREDENTIALS` environment variable so it is |
26 |
| -# available inside the docker containers |
27 |
| -export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.config/gcloud/application_default_credentials.json |
28 |
| -# Lets collector read mounted config |
29 |
| -export USERID="$(id -u)" |
30 |
| -# Specify the project ID |
31 |
| -export GOOGLE_CLOUD_PROJECT=<your project id> |
32 |
| -docker compose up --build --abort-on-container-exit |
| 30 | +```sh |
| 31 | +uv run streamlit run src/langgraph_chatbot_demo/langchain_history.py |
33 | 32 | ```
|
0 commit comments