Skip to content
Merged
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
26 changes: 20 additions & 6 deletions packages/proxy/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,26 @@ export async function proxyV1({
baseAttributes.org_name = orgName;
}

// Record total calls with model attributes
logHistogram?.({
name: "aiproxy.requests",
value: 1,
attributes: baseAttributes,
});
let requestLogged = false;
const logRequest = () => {
if (requestLogged) {
return;
}

logHistogram?.({
name: "aiproxy.requests",
value: 1,
attributes: baseAttributes,
});
requestLogged = true;
};

if (orgName) {
logRequest();
}
Comment on lines +393 to +395

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record requests before throw paths without org metadata

aiproxy.requests is now emitted only when orgName is already known or later in the request flow, so requests without an orgName can exit without being counted when proxyV1 throws before the later logRequest() calls (for example the vercel-ai validation error path, or provider/secret lookup exceptions from fetchModelLoop). Before this change, the metric was emitted unconditionally near the start, so this regresses request-count accuracy for failed calls.

Useful? React with 👍 / 👎.


if (url === "/credentials") {
logRequest();
let readable: ReadableStream | null = null;
try {
const key = await makeTempCredentials({
Expand Down Expand Up @@ -635,6 +647,7 @@ export async function proxyV1({
if (secrets.length > 0 && !orgName && secrets[0].org_name) {
baseAttributes.org_name = secrets[0].org_name;
}
logRequest();

if (endpointName) {
return secrets.filter((s) => s.name === endpointName);
Expand Down Expand Up @@ -1122,6 +1135,7 @@ export async function proxyV1({
});
}

logRequest();
logHistogram?.({
name: "aiproxy.requests_completed",
value: 1,
Expand Down