Bugfix/metrics provider undefined error (#3489)

fix metrics provider undefined error
This commit is contained in:
Henry Heng 2024-11-08 16:22:22 +00:00 committed by GitHub
parent ccc0088d0d
commit d64cb7028b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 9 additions and 9 deletions

View File

@ -112,7 +112,7 @@ const createAssistant = async (requestBody: any): Promise<Assistant> => {
version: await getAppVersion(),
assistantId: dbResponse.id
})
appServer.metricsProvider.incrementCounter(FLOWISE_METRIC_COUNTERS.ASSISTANT_CREATED, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
appServer.metricsProvider?.incrementCounter(FLOWISE_METRIC_COUNTERS.ASSISTANT_CREATED, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
return dbResponse
} catch (error) {
throw new InternalFlowiseError(

View File

@ -192,7 +192,7 @@ const saveChatflow = async (newChatFlow: ChatFlow): Promise<any> => {
chatflowId: dbResponse.id,
flowGraph: getTelemetryFlowObj(JSON.parse(dbResponse.flowData)?.nodes, JSON.parse(dbResponse.flowData)?.edges)
})
appServer.metricsProvider.incrementCounter(
appServer.metricsProvider?.incrementCounter(
dbResponse?.type === 'MULTIAGENT' ? FLOWISE_METRIC_COUNTERS.AGENTFLOW_CREATED : FLOWISE_METRIC_COUNTERS.CHATFLOW_CREATED,
{ status: FLOWISE_COUNTER_STATUS.SUCCESS }
)

View File

@ -996,7 +996,7 @@ const _insertIntoVectorStoreWorkerThread = async (data: ICommonObject) => {
type: ChatType.INTERNAL,
flowGraph: omit(indexResult['result'], ['totalKeys', 'addedDocs'])
})
appServer.metricsProvider.incrementCounter(FLOWISE_METRIC_COUNTERS.VECTORSTORE_UPSERT, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
appServer.metricsProvider?.incrementCounter(FLOWISE_METRIC_COUNTERS.VECTORSTORE_UPSERT, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
entity.status = DocumentStoreStatus.UPSERTED
await appServer.AppDataSource.getRepository(DocumentStore).save(entity)

View File

@ -18,7 +18,7 @@ const createTool = async (requestBody: any): Promise<any> => {
toolId: dbResponse.id,
toolName: dbResponse.name
})
appServer.metricsProvider.incrementCounter(FLOWISE_METRIC_COUNTERS.TOOL_CREATED, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
appServer.metricsProvider?.incrementCounter(FLOWISE_METRIC_COUNTERS.TOOL_CREATED, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
return dbResponse
} catch (error) {
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error: toolsService.createTool - ${getErrorMessage(error)}`)

View File

@ -494,7 +494,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
flowGraph: getTelemetryFlowObj(nodes, edges)
})
appServer.metricsProvider.incrementCounter(
appServer.metricsProvider?.incrementCounter(
isInternal ? FLOWISE_METRIC_COUNTERS.CHATFLOW_PREDICTION_INTERNAL : FLOWISE_METRIC_COUNTERS.CHATFLOW_PREDICTION_EXTERNAL,
{ status: FLOWISE_COUNTER_STATUS.SUCCESS }
)
@ -512,7 +512,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
return result
} catch (e) {
appServer.metricsProvider.incrementCounter(
appServer.metricsProvider?.incrementCounter(
isInternal ? FLOWISE_METRIC_COUNTERS.CHATFLOW_PREDICTION_INTERNAL : FLOWISE_METRIC_COUNTERS.CHATFLOW_PREDICTION_EXTERNAL,
{ status: FLOWISE_COUNTER_STATUS.FAILURE }
)
@ -608,7 +608,7 @@ const utilBuildAgentResponse = async (
type: isInternal ? ChatType.INTERNAL : ChatType.EXTERNAL,
flowGraph: getTelemetryFlowObj(nodes, edges)
})
appServer.metricsProvider.incrementCounter(
appServer.metricsProvider?.incrementCounter(
isInternal ? FLOWISE_METRIC_COUNTERS.AGENTFLOW_PREDICTION_INTERNAL : FLOWISE_METRIC_COUNTERS.AGENTFLOW_PREDICTION_EXTERNAL,
{ status: FLOWISE_COUNTER_STATUS.SUCCESS }
)
@ -658,7 +658,7 @@ const utilBuildAgentResponse = async (
return undefined
} catch (e) {
logger.error('[server]: Error:', e)
appServer.metricsProvider.incrementCounter(
appServer.metricsProvider?.incrementCounter(
isInternal ? FLOWISE_METRIC_COUNTERS.AGENTFLOW_PREDICTION_INTERNAL : FLOWISE_METRIC_COUNTERS.AGENTFLOW_PREDICTION_EXTERNAL,
{ status: FLOWISE_COUNTER_STATUS.FAILURE }
)

View File

@ -197,7 +197,7 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
flowGraph: getTelemetryFlowObj(nodes, edges),
stopNodeId
})
appServer.metricsProvider.incrementCounter(FLOWISE_METRIC_COUNTERS.VECTORSTORE_UPSERT, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
appServer.metricsProvider?.incrementCounter(FLOWISE_METRIC_COUNTERS.VECTORSTORE_UPSERT, { status: FLOWISE_COUNTER_STATUS.SUCCESS })
return upsertedResult['result'] ?? { result: 'Successfully Upserted' }
} catch (e) {