Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bslabe123 committed Oct 29, 2024
1 parent 7c1ab76 commit 0c2c0f1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import requests
import time
from typing import AsyncGenerator, List, Optional, Tuple, Dict
from prometheus_client import start_http_server, Histogram
from prometheus_client import start_http_server, Histogram, Gauge

import google.auth
import google.auth.transport.requests
Expand All @@ -34,6 +34,7 @@
prompt_length_metric = Histogram("LatencyProfileGenerator:prompt_length", "Input prompt length", buckets=[2**i for i in range(1, 16)])
response_length_metric = Histogram("LatencyProfileGenerator:response_length", "Response length", buckets=[2**i for i in range(1, 16)])
tpot_metric = Histogram('LatencyProfileGenerator:time_per_output_token', 'Time per output token per request')
active_requests_metric = Gauge('LatencyProfileGenerator:active_requests', 'How many requests actively being processed')

def sample_requests(
dataset_path: str,
Expand Down Expand Up @@ -211,8 +212,11 @@ async def send_request(
async with aiohttp.ClientSession(timeout=timeout,trust_env=True) as session:
while True:
try:
active_requests_metric.inc()
async with session.post(api_url, headers=headers, json=pload, ssl=False) as response:

output = await response.json()
active_requests_metric.dec()

# Re-send the request if it failed.
if "error" not in output:
Expand Down

0 comments on commit 0c2c0f1

Please sign in to comment.