Skip to content

Commit 050847c

Browse files
chatbot-rag-app: implements bedrock tracing with langtrace (#374)
Signed-off-by: Adrian Cole <[email protected]>
1 parent fbfe731 commit 050847c

File tree

5 files changed

+61
-49
lines changed

5 files changed

+61
-49
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.venv
2+
*/node_modules

example-apps/chatbot-rag-app/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ FROM node:22-alpine AS build-step
22
WORKDIR /app
33
ENV PATH=/node_modules/.bin:$PATH
44
COPY frontend ./frontend
5-
RUN rm -rf /app/frontend/node_modules
65
RUN cd frontend && yarn install
76
RUN cd frontend && REACT_APP_API_HOST=/api yarn build
87

example-apps/chatbot-rag-app/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ dotenv run -- python api/app.py
127127
If you set `OTEL_SDK_DISABLED=false` in your `.env` file, the app will send
128128
logs, metrics and traces to an OpenTelemetry compatible endpoint.
129129

130+
This happens automatically, when using docker. If running with python directly,
131+
prefix `python` with `opentelemetry-instrument` to enable OpenTelemetry.
132+
133+
```bash
134+
dotenv run -- opentelemetry-instrument python api/app.py
135+
```
136+
130137
[env.example](env.example) defaults to use Elastic APM server, started by
131138
[docker-compose-elastic.yml](../../docker). If you start your Elastic stack
132139
this way, you can access Kibana like this, authenticating with the username
@@ -147,7 +154,7 @@ To update package versions, recreate [requirements.txt](requirements.txt) and
147154
reinstall like this. Once checked in, any commands above will use updates.
148155

149156
```bash
150-
rm -rf .venv
157+
rm -rf .venv requirements.txt
151158
python3 -m venv .venv
152159
source .venv/bin/activate
153160
# Install dev requirements for pip-compile and edot-bootstrap

example-apps/chatbot-rag-app/api/llm_integrations.py

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ def init_azure_chat(temperature):
3636

3737

3838
def init_bedrock(temperature):
39+
# Bedrock is not yet in EDOT. Use the Langtrace Python SDK instead
40+
from langtrace_python_sdk.instrumentation import AWSBedrockInstrumentation
41+
42+
AWSBedrockInstrumentation().instrument()
3943
return ChatBedrock(
4044
model_id=os.getenv("CHAT_MODEL"),
4145
streaming=True,

example-apps/chatbot-rag-app/requirements.txt

+47-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.13
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
55
# pip-compile
@@ -14,17 +14,17 @@ aiosignal==1.3.2
1414
# via aiohttp
1515
annotated-types==0.7.0
1616
# via pydantic
17-
anyio==4.7.0
17+
anyio==4.8.0
1818
# via
1919
# httpx
2020
# openai
2121
attrs==24.3.0
2222
# via aiohttp
2323
blinker==1.9.0
2424
# via flask
25-
boto3==1.35.84
25+
boto3==1.36.2
2626
# via langchain-aws
27-
botocore==1.35.84
27+
botocore==1.36.2
2828
# via
2929
# boto3
3030
# s3transfer
@@ -37,11 +37,11 @@ certifi==2024.12.14
3737
# httpx
3838
# requests
3939
# sentry-sdk
40-
charset-normalizer==3.4.0
40+
charset-normalizer==3.4.1
4141
# via requests
42-
click==8.1.7
42+
click==8.1.8
4343
# via flask
44-
cohere==5.13.3
44+
cohere==5.13.8
4545
# via langchain-cohere
4646
colorama==0.4.6
4747
# via langtrace-python-sdk
@@ -57,15 +57,15 @@ distro==1.9.0
5757
# via openai
5858
docstring-parser==0.16
5959
# via google-cloud-aiplatform
60-
elastic-opentelemetry==0.6.0
60+
elastic-opentelemetry==0.6.1
6161
# via -r requirements.in
62-
elastic-transport==8.15.1
62+
elastic-transport==8.17.0
6363
# via elasticsearch
6464
elasticsearch[vectorstore-mmr]==8.17.0
6565
# via
6666
# -r requirements.in
6767
# langchain-elasticsearch
68-
fastavro==1.9.7
68+
fastavro==1.10.0
6969
# via cohere
7070
filelock==3.16.1
7171
# via
@@ -81,7 +81,7 @@ frozenlist==1.5.0
8181
# via
8282
# aiohttp
8383
# aiosignal
84-
fsspec==2024.10.0
84+
fsspec==2024.12.0
8585
# via
8686
# huggingface-hub
8787
# langtrace-python-sdk
@@ -100,7 +100,7 @@ google-auth==2.37.0
100100
# google-cloud-core
101101
# google-cloud-resource-manager
102102
# google-cloud-storage
103-
google-cloud-aiplatform==1.75.0
103+
google-cloud-aiplatform==1.77.0
104104
# via langchain-google-vertexai
105105
google-cloud-bigquery==3.27.0
106106
# via google-cloud-aiplatform
@@ -129,22 +129,22 @@ googleapis-common-protos[grpc]==1.66.0
129129
# grpcio-status
130130
# opentelemetry-exporter-otlp-proto-grpc
131131
# opentelemetry-exporter-otlp-proto-http
132-
grpc-google-iam-v1==0.13.1
132+
grpc-google-iam-v1==0.14.0
133133
# via google-cloud-resource-manager
134-
grpcio==1.68.1
134+
grpcio==1.69.0
135135
# via
136136
# google-api-core
137137
# googleapis-common-protos
138138
# grpc-google-iam-v1
139139
# grpcio-status
140140
# opentelemetry-exporter-otlp-proto-grpc
141-
grpcio-status==1.68.1
141+
grpcio-status==1.69.0
142142
# via google-api-core
143143
h11==0.14.0
144144
# via httpcore
145145
httpcore==1.0.7
146146
# via httpx
147-
httpx==0.27.2
147+
httpx==0.28.1
148148
# via
149149
# cohere
150150
# langchain-google-vertexai
@@ -157,7 +157,7 @@ httpx-sse==0.4.0
157157
# langchain-community
158158
# langchain-google-vertexai
159159
# langchain-mistralai
160-
huggingface-hub==0.27.0
160+
huggingface-hub==0.27.1
161161
# via
162162
# tokenizers
163163
# transformers
@@ -171,7 +171,7 @@ importlib-metadata==8.5.0
171171
# via opentelemetry-api
172172
itsdangerous==2.2.0
173173
# via flask
174-
jinja2==3.1.4
174+
jinja2==3.1.5
175175
# via flask
176176
jiter==0.8.2
177177
# via openai
@@ -183,17 +183,17 @@ jsonpatch==1.33
183183
# via langchain-core
184184
jsonpointer==3.0.0
185185
# via jsonpatch
186-
langchain==0.3.13
186+
langchain==0.3.14
187187
# via
188188
# -r requirements.in
189189
# langchain-community
190-
langchain-aws==0.2.10
190+
langchain-aws==0.2.11
191191
# via -r requirements.in
192-
langchain-cohere==0.3.3
192+
langchain-cohere==0.3.4
193193
# via -r requirements.in
194-
langchain-community==0.3.12
194+
langchain-community==0.3.14
195195
# via langchain-experimental
196-
langchain-core==0.3.27
196+
langchain-core==0.3.30
197197
# via
198198
# langchain
199199
# langchain-aws
@@ -205,48 +205,47 @@ langchain-core==0.3.27
205205
# langchain-mistralai
206206
# langchain-openai
207207
# langchain-text-splitters
208-
langchain-elasticsearch==0.3.0
208+
langchain-elasticsearch==0.3.2
209209
# via -r requirements.in
210-
langchain-experimental==0.3.3
210+
langchain-experimental==0.3.4
211211
# via langchain-cohere
212-
langchain-google-vertexai==2.0.9
212+
langchain-google-vertexai==2.0.11
213213
# via -r requirements.in
214214
langchain-mistralai==0.2.4
215215
# via -r requirements.in
216-
langchain-openai==0.2.13
216+
langchain-openai==0.3.1
217217
# via -r requirements.in
218-
langchain-text-splitters==0.3.4
218+
langchain-text-splitters==0.3.5
219219
# via langchain
220-
langsmith==0.2.4
220+
langsmith==0.2.11
221221
# via
222222
# langchain
223223
# langchain-community
224224
# langchain-core
225-
langtrace-python-sdk==3.3.16
225+
langtrace-python-sdk==3.3.26
226226
# via -r requirements.in
227227
markupsafe==3.0.2
228228
# via
229229
# jinja2
230230
# werkzeug
231-
marshmallow==3.23.2
231+
marshmallow==3.25.1
232232
# via dataclasses-json
233233
multidict==6.1.0
234234
# via
235235
# aiohttp
236236
# yarl
237237
mypy-extensions==1.0.0
238238
# via typing-inspect
239-
numpy==1.26.4
239+
numpy==2.2.2
240240
# via
241-
# cohere
242241
# elasticsearch
243242
# langchain
244243
# langchain-aws
245244
# langchain-community
246245
# pandas
247246
# shapely
248247
# transformers
249-
openai==1.58.1
248+
openai==1.59.9
250249
# via langchain-openai
251250
opentelemetry-api==1.29.0
252251
# via
@@ -291,7 +290,7 @@ opentelemetry-proto==1.29.0
291290
# opentelemetry-exporter-otlp-proto-http
292291
opentelemetry-resource-detector-azure==0.1.5
293292
# via elastic-opentelemetry
294-
opentelemetry-resourcedetector-gcp==1.7.0a0
293+
opentelemetry-resourcedetector-gcp==1.8.0a0
295294
# via elastic-opentelemetry
296295
opentelemetry-sdk==1.29.0
297296
# via
@@ -302,15 +301,15 @@ opentelemetry-sdk==1.29.0
302301
# opentelemetry-resource-detector-azure
303302
# opentelemetry-resourcedetector-gcp
304303
# opentelemetry-sdk-extension-aws
305-
opentelemetry-sdk-extension-aws==2.0.2
304+
opentelemetry-sdk-extension-aws==2.1.0
306305
# via elastic-opentelemetry
307306
opentelemetry-semantic-conventions==0.50b0
308307
# via
309308
# elastic-opentelemetry
310309
# opentelemetry-instrumentation
311310
# opentelemetry-instrumentation-sqlalchemy
312311
# opentelemetry-sdk
313-
orjson==3.10.12
312+
orjson==3.10.15
314313
# via langsmith
315314
packaging==24.2
316315
# via
@@ -336,7 +335,7 @@ proto-plus==1.25.0
336335
# google-api-core
337336
# google-cloud-aiplatform
338337
# google-cloud-resource-manager
339-
protobuf==5.29.2
338+
protobuf==5.29.3
340339
# via
341340
# google-api-core
342341
# google-cloud-aiplatform
@@ -372,7 +371,7 @@ pydantic-core==2.23.4
372371
# via
373372
# cohere
374373
# pydantic
375-
pydantic-settings==2.7.0
374+
pydantic-settings==2.7.1
376375
# via langchain-community
377376
python-dateutil==2.9.0.post0
378377
# via
@@ -413,11 +412,11 @@ requests-toolbelt==1.0.0
413412
# via langsmith
414413
rsa==4.9
415414
# via google-auth
416-
s3transfer==0.10.4
415+
s3transfer==0.11.1
417416
# via boto3
418-
safetensors==0.4.5
417+
safetensors==0.5.2
419418
# via transformers
420-
sentry-sdk==2.19.2
419+
sentry-sdk==2.20.0
421420
# via langtrace-python-sdk
422421
shapely==2.0.6
423422
# via google-cloud-aiplatform
@@ -428,9 +427,8 @@ six==1.17.0
428427
sniffio==1.3.1
429428
# via
430429
# anyio
431-
# httpx
432430
# openai
433-
sqlalchemy==2.0.36
431+
sqlalchemy==2.0.37
434432
# via
435433
# langchain
436434
# langchain-community
@@ -459,13 +457,15 @@ tqdm==4.67.1
459457
# transformers
460458
trace-attributes==7.1.0
461459
# via langtrace-python-sdk
462-
transformers==4.47.1
460+
transformers==4.48.0
463461
# via langtrace-python-sdk
464462
types-requests==2.32.0.20241016
465463
# via cohere
466464
typing-extensions==4.12.2
467465
# via
466+
# anyio
468467
# cohere
468+
# google-cloud-aiplatform
469469
# huggingface-hub
470470
# langchain-core
471471
# openai
@@ -481,7 +481,7 @@ tzdata==2024.2
481481
# via pandas
482482
ujson==5.10.0
483483
# via langtrace-python-sdk
484-
urllib3==2.2.3
484+
urllib3==2.3.0
485485
# via
486486
# botocore
487487
# elastic-transport
@@ -490,7 +490,7 @@ urllib3==2.2.3
490490
# types-requests
491491
werkzeug==3.1.3
492492
# via flask
493-
wrapt==1.17.0
493+
wrapt==1.17.2
494494
# via
495495
# deprecated
496496
# opentelemetry-instrumentation

0 commit comments

Comments
 (0)