Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import logging
from fastapi import FastAPI, responses, status, Request
from pydantic import BaseModel
from typing import List, Optional, Dict, Any, Union
Expand All @@ -7,11 +8,26 @@
general,
playground_question as playground_question_db_bo,
)
from submodules.model import session
from submodules.model import session, telemetry

import traceback

app = FastAPI()
OTLP_GRPC_ENDPOINT = os.getenv("OTLP_GRPC_ENDPOINT", "tempo:4317")

app_name = "refinery-neural-search"
app = FastAPI(title=app_name)

if telemetry.ENABLE_TELEMETRY:
print("WARNING: Running telemetry.", flush=True)
telemetry.setting_app_name(app_name)
telemetry.setting_otlp(app, app_name=app_name, endpoint=OTLP_GRPC_ENDPOINT)
app.add_middleware(telemetry.PrometheusMiddleware, app_name=app_name)
app.add_route("/metrics", telemetry.metrics)

# Filter out /metrics
logging.getLogger("uvicorn.access").addFilter(
lambda record: "GET /metrics" not in record.getMessage()
)


@app.middleware("http")
Expand Down
5 changes: 4 additions & 1 deletion start
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

DEBUG_MODE=false
DEBUG_PORT=15676
ENABLE_TELEMETRY=false

while getopts d flag
while getopts dg flag
do
case "${flag}" in
d) DEBUG_MODE=true;;
g) ENABLE_TELEMETRY=true;;
esac
done

Expand All @@ -32,6 +34,7 @@ docker run -d --rm \
-p 7063:80 \
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
-e QDRANT_PORT=6333 \
-e ENABLE_TELEMETRY=$ENABLE_TELEMETRY \
--mount type=bind,source="$(pwd)"/,target=/app \
-v /var/run/docker.sock:/var/run/docker.sock \
--network dev-setup_default \
Expand Down