Skip to content

Commit 72c0c06

Browse files
fix(metrics): label hosted_key.throttled with real provider on exhausted retries
1 parent 2a873e5 commit 72c0c06

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

apps/sim/tools/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ function classifyHostedKeyFailure(error: unknown): 'rate_limited' | 'auth' | 'ot
403403
interface RetryContext {
404404
requestId: string
405405
toolId: string
406+
provider: string
406407
envVarName: string
407408
executionContext?: ExecutionContext
408409
/**
@@ -429,7 +430,7 @@ async function executeWithRetry<T>(
429430
maxRetries = 3,
430431
baseDelayMs = 1000
431432
): Promise<T> {
432-
const { requestId, toolId, envVarName, executionContext, reacquireAfterRetriesExhausted } =
433+
const { requestId, toolId, provider, envVarName, executionContext, reacquireAfterRetriesExhausted } =
433434
context
434435
let lastError: unknown
435436

@@ -461,6 +462,7 @@ async function executeWithRetry<T>(
461462
PlatformEvents.hostedKeyUserThrottled({
462463
toolId,
463464
reason: 'upstream_retries_exhausted',
465+
provider,
464466
userId: executionContext?.userId,
465467
workspaceId: executionContext?.workspaceId,
466468
workflowId: executionContext?.workflowId,
@@ -1209,6 +1211,7 @@ export async function executeTool(
12091211
? await executeWithRetry(() => executeToolRequest(toolId, tool, contextParams, signal), {
12101212
requestId,
12111213
toolId,
1214+
provider: tool.hosting?.byokProviderId || tool.id,
12121215
envVarName: hostedKeyInfo.envVarName!,
12131216
executionContext,
12141217
reacquireAfterRetriesExhausted: async () => {

0 commit comments

Comments
 (0)