fix tracing

This commit is contained in:
Adil Hafeez 2024-11-13 17:11:35 -08:00
parent 7c8205abc2
commit 295fd85525
6 changed files with 14 additions and 10 deletions

View file

@ -28,5 +28,6 @@ COPY arch/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY arch/stream_traces.py .
RUN pip install requests
RUN touch /var/log/envoy.log
ENTRYPOINT ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View file

@ -21,3 +21,4 @@ services:
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:?error}
- MISTRAL_API_KEY=${MISTRAL_API_KEY:?error}
- OTEL_TRACING_HTTP_ENDPOINT=http://host.docker.internal:4318/v1/traces

View file

@ -16,3 +16,4 @@ services:
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:?error}
- MISTRAL_API_KEY=${MISTRAL_API_KEY:?error}
- OTEL_TRACING_HTTP_ENDPOINT=http://host.docker.internal:4318/v1/traces

View file

@ -13,6 +13,8 @@ services:
- ~/archgw_logs:/var/log/
env_file:
- env.list
environment:
- OTEL_TRACING_HTTP_ENDPOINT=http://host.docker.internal:4318/v1/traces
extra_hosts:
- "host.docker.internal:host-gateway"
healthcheck:

View file

@ -1,4 +1,5 @@
import os
import sys
import time
import requests
import logging
@ -29,12 +30,10 @@ def process_log_line(line):
logging.error(f"Failed to send trace to otel-tracing: {e}")
with open(envoy_log_path, "r") as f:
while True:
line = f.readline()
if not line:
time.sleep(1)
continue
tokens = line.split("gateway: upstream_llm trace details: ")
if len(tokens) > 1:
process_log_line(tokens[1])
for line in sys.stdin:
if not line:
time.sleep(1)
continue
tokens = line.split("gateway: upstream_llm trace details: ")
if len(tokens) > 1:
process_log_line(tokens[1])

View file

@ -2,7 +2,7 @@
nodaemon=true
[program:trace_streamer]
command=python stream_traces.py
command=sh -c "tail -F /var/log/envoy.log | python stream_traces.py"
autostart=true
autorestart=false
startretries=3