Skip to content

Commit 6d12679

Browse files
authoredOct 15, 2024··
feat: AWS OpenTelemetry Support (#2)
1 parent e34186b commit 6d12679

File tree

5 files changed

+91
-6
lines changed

5 files changed

+91
-6
lines changed
 

‎README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ AzureOpenAI-compatible RESTful APIs for Amazon Bedrock.
77
This is a fork project from [Bedrock Access Gateway](https://github.com/aws-samples/bedrock-access-gateway), with the dedicated support for **AzureOpenAI** client instead of **OpenAI** client.
88

99
**Enhanced Features:**
10+
1011
- [x] AzureOpenAI client
1112
- [x] Deployment on Amazon EKS
1213
- [x] [JSON mode](https://learn.microsoft.com/sv-se/azure/ai-services/openai/how-to/json-mode?tabs=python) response format
14+
- [x] [AWS Distro for OpenTelemetry](https://aws-otel.github.io/) support, helps on debugging and observability.
1315

1416
## Setup
1517
### Happy path for testing
@@ -42,7 +44,7 @@ make build
4244

4345
Make sure to update the image of the k8s deployment under `deployment/k8s/manifest.yaml`, and run `make deploy` to deploy again.
4446

45-
> [!INFO]
47+
> [!TIP]
4648
> Feel free to change the region within the `scripts/push-to-ecr.sh` if you want to change the target ECR repo name and region.
4749
4850
### Verification
@@ -330,4 +332,4 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
330332

331333
## License
332334

333-
This library is licensed under the MIT-0 License. See the LICENSE file.
335+
This library is licensed under the MIT-0 License. See the LICENSE file.

‎docker-compose.yaml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
1-
version: '3'
1+
# version: '3'
22
services:
33
gateway:
44
build:
55
context: ./src
6-
dockerfile: Dockerfile
6+
dockerfile: Dockerfile_otel
77
ports:
88
- 8000:80
99
volumes:
1010
- ./src/:/app/
1111
- ~/.aws:/root/.aws # If not provide AWS credentials from .env, just load your local AWS credentails
12-
command: ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "80", "--reload"]
12+
# command: ["opentelemetry-instrument","uvicorn","api.app:app","--port","8000","--host","0.0.0.0", "--reload"] # reload is not working with Otel instrumented app
13+
command: ["opentelemetry-instrument","uvicorn","api.app:app","--port","8000","--host","0.0.0.0"]
1314
env_file:
1415
- .env
1516
environment:
1617
- DEBUG=true
1718
- AWS_REGION=us-east-1
18-
- AWS_PROFILE=account-b-us
19+
- AWS_PROFILE=bedrock
20+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
21+
depends_on:
22+
- otel-collector
23+
networks:
24+
- app-network
25+
otel-collector:
26+
image: public.ecr.aws/aws-observability/aws-otel-collector:latest
27+
command: ["--config=/etc/otel-collector-config.yaml"]
28+
volumes:
29+
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
30+
- ~/.aws:/home/aoc/.aws
31+
ports:
32+
- "4317:4317" # OTLP gRPC receiver
33+
- "4318:4318" # OTLP HTTP receiver
34+
- "8888:8888" # Prometheus metrics exposed by the collector
35+
- "8889:8889" # Prometheus exporter metrics
36+
- "13133:13133" # Health check extension
37+
environment:
38+
- AWS_REGION=us-west-2
39+
- AWS_PROFILE=default
40+
- AWS_SDK_LOAD_CONFIG=1
41+
- AWS_CONFIG_FILE=/home/aoc/.aws/config
42+
- AWS_SHARED_CREDENTIALS_FILE=/home/aoc/.aws/credentials
43+
networks:
44+
- app-network
45+
networks:
46+
app-network:
47+
driver: bridge

‎otel-collector-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
endpoint: 0.0.0.0:4317
6+
http:
7+
endpoint: 0.0.0.0:4318
8+
9+
processors:
10+
batch:
11+
12+
exporters:
13+
awsxray:
14+
region: "us-west-2"
15+
logging:
16+
verbosity: detailed
17+
18+
service:
19+
pipelines:
20+
traces:
21+
receivers: [otlp]
22+
processors: [batch]
23+
exporters: [awsxray]
24+
metrics:
25+
receivers: [otlp]
26+
processors: [batch]
27+
exporters: [logging]

‎src/Dockerfile_otel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
COPY ./requirements-otel.txt /app/requirements-otel.txt
6+
7+
RUN pip install --no-cache-dir --upgrade -r /app/requirements-otel.txt
8+
9+
COPY ./api /app/api
10+
11+
RUN opentelemetry-bootstrap --action=install
12+
13+
CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "8000"]

‎src/requirements-otel.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fastapi==0.111.0
2+
pydantic==2.7.1
3+
uvicorn==0.29.0
4+
mangum==0.17.0
5+
tiktoken==0.6.0
6+
requests==2.32.3
7+
numpy==1.26.4
8+
boto3==1.35.17
9+
botocore==1.35.17
10+
opentelemetry-api==1.27.0
11+
opentelemetry-sdk==1.27.0
12+
opentelemetry-sdk-extension-aws==2.0.2
13+
opentelemetry-propagator-aws-xray==1.0.2
14+
opentelemetry-distro[otlp]

0 commit comments

Comments
 (0)
Please sign in to comment.