Skip to content

Commit f5cfa00

Browse files
OpenTelemetry monitoring (#115)
* fix: minio use ssl * chore: update submodules * perf: add telemetry * fix: app name * chore: update submodules * chore: update telemetry import * ci(fix): drone submodule update * ci(fix): drone submodule update * fix: hanging docker stop * chore: update submodules * perf: enhance monitoring * chore(opentelemetry): update submodules
1 parent 4305eef commit f5cfa00

File tree

6 files changed

+30
-20
lines changed

6 files changed

+30
-20
lines changed

.drone.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ steps:
1111
commands:
1212
- git submodule init
1313
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
14-
- "git submodule update --recursive --remote"
14+
- "git submodule update --recursive"
1515
- name: build and publish
1616
image: plugins/docker
1717
settings:
@@ -73,7 +73,7 @@ steps:
7373
commands:
7474
- git submodule init
7575
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
76-
- "git submodule update --recursive --remote"
76+
- "git submodule update --recursive"
7777
- name: build and publish
7878
image: plugins/docker
7979
settings:
@@ -109,7 +109,7 @@ steps:
109109
commands:
110110
- git submodule init
111111
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
112-
- "git submodule update --recursive --remote"
112+
- "git submodule update --recursive"
113113
- name: build and publish
114114
image: plugins/docker
115115
settings:
@@ -138,7 +138,7 @@ steps:
138138
commands:
139139
- git submodule init
140140
- 'git config --global url."https://github.com/".insteadOf [email protected]:'
141-
- "git submodule update --recursive --remote"
141+
- "git submodule update --recursive"
142142
- name: build and publish
143143
image: plugins/docker
144144
settings:

app.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
import os
2+
import logging
13
from fastapi import FastAPI, responses, status
24
from fastapi.encoders import jsonable_encoder
35
from pydantic import BaseModel
46
from submodules.model.business_objects import general
57
import util
6-
from submodules.model import session
8+
from submodules.model import session, telemetry
79

8-
app = FastAPI()
10+
11+
OTLP_GRPC_ENDPOINT = os.getenv("OTLP_GRPC_ENDPOINT", "tempo:4317")
12+
13+
app_name = "refinery-updater"
14+
app = FastAPI(title=app_name)
15+
16+
if telemetry.ENABLE_TELEMETRY:
17+
print("WARNING: Running telemetry.", flush=True)
18+
telemetry.setting_app_name(app_name)
19+
telemetry.setting_otlp(app, app_name=app_name, endpoint=OTLP_GRPC_ENDPOINT)
20+
app.add_middleware(telemetry.PrometheusMiddleware, app_name=app_name)
21+
app.add_route("/metrics", telemetry.metrics)
22+
23+
# Filter out /metrics
24+
logging.getLogger("uvicorn.access").addFilter(
25+
lambda record: "GET /metrics" not in record.getMessage()
26+
)
927

1028

1129
@app.post("/update_to_newest")

daemon.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-r requirements.txt
2-
httpx==0.25.0
2+
httpx==0.28.1
33
pytest==8.1.1
44
debugpy==1.8.12

start

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
DEBUG_MODE=false
44
DEBUG_PORT=15674
5+
ENABLE_TELEMETRY=false
56

6-
while getopts d flag
7+
while getopts dg flag
78
do
89
case "${flag}" in
910
d) DEBUG_MODE=true;;
11+
g) ENABLE_TELEMETRY=true;;
1012
esac
1113
done
1214

@@ -39,6 +41,7 @@ docker run -d --rm \
3941
-e NEURAL_SEARCH=http://refinery-neural-search:80 \
4042
-e COGNITION_GATEWAY=http://cognition-gateway:80 \
4143
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
44+
-e ENABLE_TELEMETRY=$ENABLE_TELEMETRY \
4245
--mount type=bind,source="$(pwd)"/,target=/app \
4346
-v /var/run/docker.sock:/var/run/docker.sock \
4447
--network dev-setup_default \

0 commit comments

Comments
 (0)